aboutsummaryrefslogtreecommitdiff
path: root/misc/sys/cdefs.h
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2021-07-28 16:58:17 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2021-07-28 17:45:14 +0530
commitb8e8bb324a376cd99bb61b6c21f63c395cae9b5d (patch)
tree890c19c4c34237fbe40d0dac187189cd2e83626a /misc/sys/cdefs.h
parent4aedc25f55eda50010f2932fdb0a533db6f89f61 (diff)
downloadglibc-b8e8bb324a376cd99bb61b6c21f63c395cae9b5d.zip
glibc-b8e8bb324a376cd99bb61b6c21f63c395cae9b5d.tar.gz
glibc-b8e8bb324a376cd99bb61b6c21f63c395cae9b5d.tar.bz2
xmalloc: Fix warnings with gcc analyzer
Tell the compiler that xmalloc family of allocators always return non-NULL. xrealloc in locale/programs also always returns non-NULL, but that conflicts with default realloc behaviour and that of xrealloc in libsupport, so keep it as is for now and resolve the differences later. Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'misc/sys/cdefs.h')
-rw-r--r--misc/sys/cdefs.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 30a621a..e490fc1 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -330,6 +330,16 @@
# define __nonnull(params) _GL_ATTRIBUTE_NONNULL (params)
#endif
+/* The returns_nonnull function attribute marks the return type of the function
+ as always being non-null. */
+#ifndef __returns_nonnull
+# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
+# define __returns_nonnull __attribute__ ((__returns_nonnull__))
+# else
+# define __returns_nonnull
+# endif
+#endif
+
/* If fortification mode, we warn about unused results of certain
function calls which can lead to problems. */
#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)