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: get rid of "warning: ignoring return value of ‘strerror_r’" #12775

Merged
merged 1 commit into from Jan 5, 2017

Conversation

Projects
None yet
3 participants
@xiexingguo
Member

xiexingguo commented Jan 4, 2017

Signed-off-by: xie xingguo xie.xingguo@zte.com.cn

@xiexingguo xiexingguo requested a review from tchaikov Jan 4, 2017

@@ -40,7 +40,8 @@ static int run_command(const char *command)
if (status < 0) {
char error_buf[80];
strerror_r(errno, error_buf, sizeof(error_buf));
char* dummy = strerror_r(errno, error_buf, sizeof(error_buf));

This comment has been minimized.

@Liuchang0812

Liuchang0812 Jan 4, 2017

Contributor

it seems that freeBSD will compile error. strerror_r returns int in freeBSD。 ref: https://linux.die.net/man/3/strerror_r

is auto better?

This comment has been minimized.

@tchaikov

tchaikov Jan 4, 2017

Contributor

could also put

(void) strerror_r(errno, error_buf, sizeof(error_buf));

to silence the warning.

wondering why the strerror_r() call in errno.cc didn't pop up.

This comment has been minimized.

@xiexingguo

xiexingguo Jan 4, 2017

Member

Actually I've tried both before posting this pr but none of them worked.

By applying @Liuchang0812 change, I get:

/home/xxg/dev/ceph-dev/src/common/module.c: In function ‘run_command’:
/home/xxg/dev/ceph-dev/src/common/module.c:43:8: warning: type defaults to ‘int’ in declaration of ‘dummy’ [enabled by default]
   auto dummy = strerror_r(errno, error_buf, sizeof(error_buf));
        ^
/home/xxg/dev/ceph-dev/src/common/module.c:43:16: warning: initialization makes integer from pointer without a cast [enabled by default]
   auto dummy = strerror_r(errno, error_buf, sizeof(error_buf));
                ^

and by applying @tchaikov change instead I get:

/home/xxg/dev/ceph-dev/src/common/module.c: In function ‘run_command’:
/home/xxg/dev/ceph-dev/src/common/module.c:44:3: warning: ignoring return value of ‘strerror_r’, declared with attribute warn_unused_result [-Wunused-result]
   (void)strerror_r(errno, error_buf, sizeof(error_buf));
   ^
@xiexingguo

This comment has been minimized.

Member

xiexingguo commented Jan 4, 2017

@tchaikov Check again?

@@ -40,7 +40,12 @@ static int run_command(const char *command)
if (status < 0) {
char error_buf[80];
strerror_r(errno, error_buf, sizeof(error_buf));
#if defined(__FreeBSD__)

This comment has been minimized.

@tchaikov

tchaikov Jan 4, 2017

Contributor

@xiexingguo if you want to differentiate the XSI and GNU strerror_r(), better off using STRERROR_R_CHAR_P instead of __FreeBSD__.

This comment has been minimized.

@tchaikov

tchaikov Jan 4, 2017

Contributor

and please do not indent #if

This comment has been minimized.

@xiexingguo

xiexingguo Jan 4, 2017

Member

Upgraded. Thanks!

common: get rid of "warning: ignoring return value of ‘strerror_r’"
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>

@tchaikov tchaikov added the needs-qa label Jan 4, 2017

@tchaikov tchaikov self-assigned this Jan 4, 2017

@tchaikov tchaikov merged commit 14d8d5d into ceph:master Jan 5, 2017

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

@xiexingguo xiexingguo deleted the xiexingguo:xxg-wip-shutup-warning branch Jan 5, 2017

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