[patch] Error on setenv(..., NULL, ...)

Paul Eggert eggert@cs.ucla.edu
Tue Mar 17 00:03:00 GMT 2015


Joseph Myers wrote:
> Are you saying that if you include
> <libc-internal.h>, then use the macros, then include other headers, that
> it doesn't work?

Yes it doesn't work, because libc-internal.h includes string.h before the 
including file can invoke the macros.  For example, the attached patch does not 
work, with the symptoms given below.  (Another issue is that the file is 
supposed to be sharable with Gnulib, which can't assume libc-internal.h.)

In file included from ../include/bits/string2.h:1:0,
                  from ../string/string.h:630,
                  from ../include/string.h:51,
                  from ../sysdeps/generic/hp-timing-common.h:40,
                  from ../sysdeps/x86_64/hp-timing.h:38,
                  from ../include/libc-internal.h:7,
                  from setenv.c:23:
setenv.c: In function ‘__add_to_environ’:
../string/bits/string2.h:206:37: error: ‘vallen’ may be used uninitialized in 
this function [-Werror=maybe-uninitialized]
  #    define __mempcpy(dest, src, n) __builtin_mempcpy (dest, src, n)
                                      ^
setenv.c:135:10: note: ‘vallen’ was declared here
    size_t vallen;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: setenv.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150317/17230eb1/attachment.bin>


More information about the Libc-alpha mailing list