]> Savannah Git Hosting - gnulib.git/commitdiff
careadlinkat: improve warning line number
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 24 Dec 2020 20:06:26 +0000 (12:06 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 24 Dec 2020 20:06:49 +0000 (12:06 -0800)
This propagates an idea first used in canonicalize-lgpl.
* lib/careadlinkat.c (GCC_BOGUS_WRETURN_LOCAL_ADDR):
New macro.
(careadlinkat): Use it.

ChangeLog
lib/careadlinkat.c

index 7b1bcd8ffb0a93a6cac4c3511cf5c9de6d79e3fd..5b05bb31090735b303d5fbacca9cbd198eda4bd9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-12-24  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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.
index 26fe84df55e47ccf61f8e53fa50edbd4984df862..6aaa712b9bef841bab92643481ef057cecd61530 100644 (file)
@@ -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 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93644>."
+#  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 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93644>."
+  #endif
   char stack_buf[STACK_BUF_SIZE];
   return readlink_stk (fd, filename, buffer, buffer_size, alloc,
                        preadlinkat, stack_buf);