summaryrefslogtreecommitdiff
path: root/lib/careadlinkat.c
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-12-27 17:54:57 +0100
committerAndrea Corallo <akrl@sdf.org>2020-12-27 17:54:57 +0100
commit8fb94630136700aa4e74c7fc212b019d2db380ae (patch)
tree69b3938a89f450509a7001f45ba3acca057fb40d /lib/careadlinkat.c
parent271fb8a269aff924070b188f23355d0c368356dd (diff)
parentdf882c9701755e2ae063f05d3381de14ae09951e (diff)
downloademacs-8fb94630136700aa4e74c7fc212b019d2db380ae.tar.gz
emacs-8fb94630136700aa4e74c7fc212b019d2db380ae.tar.bz2
emacs-8fb94630136700aa4e74c7fc212b019d2db380ae.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'lib/careadlinkat.c')
-rw-r--r--lib/careadlinkat.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c
index e43aa42d5c4..6aaa712b9be 100644
--- a/lib/careadlinkat.c
+++ b/lib/careadlinkat.c
@@ -51,8 +51,12 @@ enum { STACK_BUF_SIZE = 1024 };
to pacify GCC is known; even an explicit #pragma does not pacify GCC.
When the GCC bug is fixed this workaround should be limited to the
broken GCC versions. */
-#if (defined GCC_LINT || defined lint) && _GL_GNUC_PREREQ (10, 1)
+#if _GL_GNUC_PREREQ (10, 1)
+# if defined GCC_LINT || defined lint
__attribute__ ((__noinline__))
+# elif __OPTIMIZE__ && !__NO_INLINE__
+# define GCC_BOGUS_WRETURN_LOCAL_ADDR
+# endif
#endif
static char *
readlink_stk (int fd, char const *filename,
@@ -85,18 +89,13 @@ readlink_stk (int fd, char const *filename,
size_t link_size;
if (link_length < 0)
{
- /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1
- with errno == ERANGE if the buffer is too small. */
- int readlinkat_errno = errno;
- if (readlinkat_errno != ERANGE)
+ if (buf != buffer)
{
- if (buf != buffer)
- {
- alloc->free (buf);
- errno = readlinkat_errno;
- }
- return NULL;
+ int readlinkat_errno = errno;
+ alloc->free (buf);
+ errno = readlinkat_errno;
}
+ return NULL;
}
link_size = link_length;
@@ -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);