diff options
author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-07-28 16:58:17 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-07-28 17:45:14 +0530 |
commit | b8e8bb324a376cd99bb61b6c21f63c395cae9b5d (patch) | |
tree | 890c19c4c34237fbe40d0dac187189cd2e83626a /include | |
parent | 4aedc25f55eda50010f2932fdb0a533db6f89f61 (diff) | |
download | glibc-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 'include')
-rw-r--r-- | include/programs/xmalloc.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/include/programs/xmalloc.h b/include/programs/xmalloc.h index 33871e2..5dc6aac 100644 --- a/include/programs/xmalloc.h +++ b/include/programs/xmalloc.h @@ -23,11 +23,14 @@ /* Prototypes for a few program-wide used functions. */ extern void *xmalloc (size_t n) - __attribute_malloc__ __attribute_alloc_size__ ((1)) __attr_dealloc_free; + __attribute_malloc__ __attribute_alloc_size__ ((1)) __attr_dealloc_free + __returns_nonnull; extern void *xcalloc (size_t n, size_t s) - __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __attr_dealloc_free; + __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __attr_dealloc_free + __returns_nonnull; extern void *xrealloc (void *o, size_t n) __attribute_malloc__ __attribute_alloc_size__ ((2)) __attr_dealloc_free; -extern char *xstrdup (const char *) __attribute_malloc__ __attr_dealloc_free; +extern char *xstrdup (const char *) __attribute_malloc__ __attr_dealloc_free + __returns_nonnull; #endif /* xmalloc.h */ |