]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Fix some minor compiler warnings
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 17 May 2021 20:35:54 +0000 (16:35 -0400)
committerKent Overstreet <kent.overstreet@gmail.com>
Mon, 17 May 2021 20:35:54 +0000 (16:35 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
include/linux/slab.h
tools-util.h

index 6628d5e44a7914a4dc4d4679b86604b05ccd79cf..ef86153898130432d8119f9373546f7cb13124ec 100644 (file)
@@ -47,10 +47,12 @@ static inline void *krealloc(void *old, size_t size, gfp_t flags)
        if (flags & __GFP_ZERO)
                memset(new, 0, size);
 
-       memcpy(new, old,
-              min(malloc_usable_size(old),
-                  malloc_usable_size(new)));
-       free(old);
+       if (old) {
+               memcpy(new, old,
+                      min(malloc_usable_size(old),
+                          malloc_usable_size(new)));
+               free(old);
+       }
 
        return new;
 }
index 01898e21d050c275d0b03c732237d1731d21c5a0..568707bc2f54b9fe6ba4e82a07fab8a8f23eab11 100644 (file)
@@ -20,7 +20,9 @@
 #include <linux/uuid.h>
 #include "ccan/darray/darray.h"
 
-void die(const char *, ...);
+#define noreturn __attribute__((noreturn))
+
+void die(const char *, ...) noreturn;
 char *mprintf(const char *, ...)
        __attribute__ ((format (printf, 1, 2)));
 void *xcalloc(size_t, size_t);