From 8f72e6940c0bdf5cc1f1e0faf13b9e7a781161c6 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 17 May 2021 16:35:54 -0400 Subject: [PATCH] Fix some minor compiler warnings Signed-off-by: Kent Overstreet --- include/linux/slab.h | 10 ++++++---- tools-util.h | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 6628d5e4..ef861538 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -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; } diff --git a/tools-util.h b/tools-util.h index 01898e21..568707bc 100644 --- a/tools-util.h +++ b/tools-util.h @@ -20,7 +20,9 @@ #include #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);