bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a bad use of strerror_r


From: Eric Blake
Subject: Re: a bad use of strerror_r
Date: Fri, 4 Nov 2016 11:06:40 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 10/16/2016 11:17 AM, Bruno Haible wrote:

> There are two problems:
> 
> 1) argp-help.c uses STRERROR_R_CHAR_P, which is defined by the macro
>    AC_FUNC_STRERROR_R, but argp.m4 does not require it (only error.m4 does).
> 
> 2) When the strerror_r-posix module is in place, the results of
>    AC_FUNC_STRERROR_R have to be ignored, because they don't reflect the
>    situation after
>      #define strerror_r rpl_strerror_r
> 
> With the following proposed patches, we arrive at a sane situation without
> warning, and
> 
> $ gcc ... -E argp-help.c | grep strerror_r
> extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
> extern int rpl_strerror_r (int errnum, char *buf, size_t buflen) 
> __attribute__ ((__nonnull__ (2)))
>               if (rpl_strerror_r (errnum, buf, sizeof buf) == 0)
> 
> 

> 
> 2016-10-16  Bruno Haible  <address@hidden>
> 
>       Fix conflict between strerror_r-posix module and AC_FUNC_STRERROR_R.
>       * m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Override the values set by the
>       AC_FUNC_STRERROR_R macro. Define HAVE_DECL_STRERROR_R_ORIG.
>       * lib/strerror_r.c: Use HAVE_DECL_STRERROR_R_ORIG instead of
>       HAVE_DECL_STRERROR_R.

This commit causes weird compilation failures; in particular, trying to
use it on libvirt causes -Wformat to no longer be used.  Why? Because it
interferes with all future configure probes:

> +
> +  # Overwrite the findings of AC_FUNC_STRERROR_R (for code that uses that).
> +  AC_REQUIRE([AC_FUNC_STRERROR_R])
> +  AC_DEFINE([HAVE_DECL_STRERROR_R], [1])
> +  AC_DEFINE([STRERROR_R_CHAR_P], [0])

Symptoms of the failure, as seen in config.log, are as follows:

configure:17696: checking for strerror_r
configure:17696: result: yes
configure:17705: checking whether strerror_r returns char *
configure:17729: gcc -c -g  conftest.c >&5
configure:17729: $? = 0
configure:17767: result: yes
configure:17818: checking for external symbol _system_configuration
configure:17836: gcc -o conftest -g   conftest.c  >&5
conftest.c:216:0: warning: "STRERROR_R_CHAR_P" redefined
 #define STRERROR_R_CHAR_P 0

conftest.c:213:0: note: this is the location of the previous definition
 #define STRERROR_R_CHAR_P 1

conftest.c:218:27: fatal error: sys/systemcfg.h: No such file or directory
 #include <sys/systemcfg.h>
                           ^

which then results in probes for -Werror failing where they used to
succeed, and in libvirt's case this causes a probe for '-Wformat
-Werror' to be incorrectly diagnosed.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]