Fix some minor compiler warnings

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-05-17 16:35:54 -04:00
parent a76f36fc6e
commit 8f72e6940c
2 changed files with 9 additions and 5 deletions

View 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;
}

View 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);