From: Paul Eggert Date: Thu, 24 Dec 2020 20:06:26 +0000 (-0800) Subject: careadlinkat: improve warning line number X-Git-Tag: v1.0~3318 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9b1101d6c3b205049c7c104e57327b6696556c5e;p=gnulib.git careadlinkat: improve warning line number This propagates an idea first used in canonicalize-lgpl. * lib/careadlinkat.c (GCC_BOGUS_WRETURN_LOCAL_ADDR): New macro. (careadlinkat): Use it. --- diff --git a/ChangeLog b/ChangeLog index 7b1bcd8ffb..5b05bb3109 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2020-12-24 Paul Eggert + careadlinkat: improve warning line number + This propagates an idea first used in canonicalize-lgpl. + * lib/careadlinkat.c (GCC_BOGUS_WRETURN_LOCAL_ADDR): + New macro. + (careadlinkat): Use it. + linkat: use eloop-threshold * lib/linkat.c: Include eloop-threshold.h. Do not include sys/param.h. diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c index 26fe84df55..6aaa712b9b 100644 --- a/lib/careadlinkat.c +++ b/lib/careadlinkat.c @@ -55,8 +55,7 @@ enum { STACK_BUF_SIZE = 1024 }; # if defined GCC_LINT || defined lint __attribute__ ((__noinline__)) # elif __OPTIMIZE__ && !__NO_INLINE__ -# warning "GCC might issue a bogus -Wreturn-local-addr warning here." -# warning "See ." +# define GCC_BOGUS_WRETURN_LOCAL_ADDR # endif #endif static char * @@ -180,10 +179,11 @@ careadlinkat (int fd, char const *filename, /* Allocate the initial buffer on the stack. This way, in the common case of a symlink of small size, we get away with a single small malloc instead of a big malloc followed by a - shrinking realloc. - - If GCC -Wreturn-local-addr warns about this buffer, the warning - is bogus; see readlink_stk. */ + shrinking realloc. */ + #ifdef GCC_BOGUS_WRETURN_LOCAL_ADDR + #warning "GCC might issue a bogus -Wreturn-local-addr warning here." + #warning "See ." + #endif char stack_buf[STACK_BUF_SIZE]; return readlink_stk (fd, filename, buffer, buffer_size, alloc, preadlinkat, stack_buf);