Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OESS-168: Remove clang warnings. #1299

Closed
wants to merge 3 commits into from

Conversation

hyoklee
Copy link
Member

@hyoklee hyoklee commented Dec 15, 2021

H5Lint.c:599:32: warning: cast from 'const char *' to 'char *' drops const qualifie\
r [-Wcast-qual]
    udata->lnk->name = (char *)name;
                               ^
H5Lint.c:1379:32: warning: cast from 'const char *' to 'char *' drops const qualifi\
er [-Wcast-qual]
    udata->lnk->name = (char *)name;

udata->lnk->name = strdup(name);
if (NULL == udata->lnk->name) {
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "out of memory")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these changes are in callbacks, it sort of seems like doing a strdup each time probably wouldn't be optimal. This seems like the kind of thing that needs to be fixed somewhere higher up where we correctly differentiate between when the link name should be const and non-const.

If we do go with this change though, the strdup calls should be changed to HDstrdup, or even better, HDstrndup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HDstrndup() is not available in H5private.h.
strndup() is not available for MS VS C compiler.
Thus, I replaced strdup() with HDstrdup().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these changes are in callbacks, it sort of seems like doing a strdup each time probably wouldn't be optimal. This seems like the kind of thing that needs to be fixed somewhere higher up where we correctly differentiate between when the link name should be const and non-const.

Agree

@derobins
Copy link
Member

The strdup is probably too much overhead for simply squashing a warning.

@derobins derobins closed this Apr 15, 2022
@hyoklee hyoklee deleted the OESS-168-H5Lint.c branch July 14, 2022 21:35
@hyoklee hyoklee restored the OESS-168-H5Lint.c branch July 14, 2022 21:35
@hyoklee hyoklee deleted the OESS-168-H5Lint.c branch July 14, 2022 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants