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

Hal Murray hmurray at megapathdsl.net
Sun Apr 7 04:43:31 UTC 2019


../../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?


>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.

Typical code is:
    char errbuf[100];
        strerror_r(errno, errbuf, sizeof(errbuf));
        msyslog(LOG_INFO, "NTS: SSL_read error: %s", errbuf);


-- 
These are my opinions.  I hate spam.





More information about the devel mailing list