What's the best way to fix warnings from unused result

Eric S. Raymond esr at thyrsus.com
Sun Apr 7 07:57:19 UTC 2019


Hal Murray via devel <devel at ntpsec.org>:
> ../../ntpd/nts.c:213:9: warning: ignoring return value of ‘strerror_r’, 
> declared with attribute warn_unused_result [-Wunused-result]
> 
> I'm only getting this on Ubuntu, so a secondary question is why isn't that 
> check happening on other systems?

Probablty compiler version. As GCC has evolved it has gotten stricter
about this sort of thing.

> >From the man page:
>        int strerror_r(int errnum, char *buf, size_t buflen);
>                    /* XSI-compliant */
> 
>        char *strerror_r(int errnum, char *buf, size_t buflen);
>                    /* GNU-specific */
> 
> I don't know or care which version we get.  It's different on different 
> systems, so to save the result then say UNUSED_LOCAL gets slightly complicated.

This is probably what you want:

./include/ntp_stdlib.h:162:#define IGNORE(r) do{if(r){}}while(0)
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>




More information about the devel mailing list