]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/xalloc: add warn_unused_result to allocation functions
authorKarel Zak <kzak@redhat.com>
Tue, 9 Jul 2013 08:44:06 +0000 (10:44 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 9 Jul 2013 08:44:06 +0000 (10:44 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/c.h
include/xalloc.h

index a50e8a5933d0bdca6269b3ae99a36f0f3ae4dca1..4a9bf3d42e5e99c3472056deac7b0f15a7356d3c 100644 (file)
@@ -56,7 +56,7 @@
  */
 #ifndef __ul_alloc_size
 # if __GNUC_PREREQ (4, 3)
-#  define __ul_alloc_size(s) __attribute__((alloc_size(s)))
+#  define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result))
 # else
 #  define __ul_alloc_size(s)
 # endif
@@ -64,7 +64,7 @@
 
 #ifndef __ul_calloc_size
 # if __GNUC_PREREQ (4, 3)
-#  define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s)))
+#  define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result))
 # else
 #  define __ul_calloc_size(n, s)
 # endif
index 6342793e4f1279c580f1edc5f3bd7f682789d9c3..105d713b15d66b27ba0710cb2c3257850881b0df 100644 (file)
@@ -49,7 +49,7 @@ void *xcalloc(const size_t nelems, const size_t size)
         return ret;
 }
 
-static inline char *xstrdup(const char *str)
+static inline char __attribute__((warn_unused_result)) *xstrdup(const char *str)
 {
         char *ret;
 
@@ -63,7 +63,7 @@ static inline char *xstrdup(const char *str)
         return ret;
 }
 
-static inline char *xstrndup(const char *str, size_t size)
+static inline char * __attribute__((warn_unused_result)) xstrndup(const char *str, size_t size)
 {
         char *ret;
 
@@ -92,7 +92,7 @@ static inline int __attribute__ ((__format__(printf, 2, 3)))
 }
 
 
-static inline char *xgethostname(void)
+static inline char * __attribute__((warn_unused_result)) xgethostname(void)
 {
        char *name;
        size_t sz = get_hostname_max() + 1;