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

common/module.c: do not use strerror_r the GNU way. #12363

Merged
merged 1 commit into from Dec 30, 2016

Conversation

Projects
None yet
3 participants
@wjwithagen
Contributor

wjwithagen commented Dec 7, 2016

FreeBSD compile generates:

[  0%] Building C object src/CMakeFiles/common_mountcephfs_objs.dir/common/module.c.o
/home/jenkins/workspace/ceph-freebsd/src/common/module.c:44:4: warning: format specifies type 'char *' but the argument has type 'int' [-Wformat]
                        strerror_r(errno, error_buf, sizeof(error_buf)));
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

From the manpage:

       char *strerror(int errnum);

       int strerror_r(int errnum, char *buf, size_t buflen);
                   /* XSI-compliant */

       char *strerror_r(int errnum, char *buf, size_t buflen);
                   /* GNU-specific */

So changed the strerror_r() version to where the buffer is filled separately
and the result is ignored, instead of being used for printing.

Signed-off-by: Willem Jan Withagen wjw@digiware.nl

POSIX/src/common/module.c: do not use strerror_r the GNU way.
From the manpage:
       char *strerror(int errnum);

       int strerror_r(int errnum, char *buf, size_t buflen);
                   /* XSI-compliant */

       char *strerror_r(int errnum, char *buf, size_t buflen);
                   /* GNU-specific */

So changed the strerror_r() version to a version where we ignore the
the result of the function call

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>

@liewegas liewegas added the build/ops label Dec 29, 2016

@liewegas liewegas changed the title from POSIX/src/common/module.c: do not use strerror_r the GNU way. to common/module.c: do not use strerror_r the GNU way. Dec 29, 2016

@liewegas liewegas merged commit 1a3fc9c into ceph:master Dec 30, 2016

3 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodifed Submodules submodules for project are unmodified
Details
default Build finished.
Details
@Liuchang0812

This comment has been minimized.

Contributor

Liuchang0812 commented Jan 1, 2017

/home/liuchang/WorkSpace/ceph/src/common/module.c:43:3: warning: ignoring return value of ‘strerror_r’, declared with attribute warn_unused_result [-Wunused-result]
   strerror_r(errno, error_buf, sizeof(error_buf));

Hi, here is a warn message.

@wjwithagen wjwithagen deleted the wjwithagen:wip-wjw-freebsd-strerror branch Jan 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment