>From db9f824d01287d7b78330c7d34bc291fa6b9ccad Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 24 Dec 2020 12:06:26 -0800 Subject: [PATCH 10/10] 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. --- ChangeLog | 6 ++++++ lib/careadlinkat.c | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b1bcd8ff..5b05bb310 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 26fe84df5..6aaa712b9 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); -- 2.27.0