From: Hugo Lefeuvre Date: Sun, 16 Apr 2023 08:53:17 +0000 (+0200) Subject: lib/ukalloc: Remove unreachable NULL checks X-Git-Tag: RELEASE-0.13.0~92 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=12836a6f3aad94b6904091824e6b46eb7621f4d9;p=unikraft%2Funikraft.git lib/ukalloc: Remove unreachable NULL checks These if (ptr && ...) will always turn out true due to the preceding if (!ptr) This was found by Coccinelle [0]. [0] https://coccinelle.gitlabpages.inria.fr/website/rules/notnull.cocci Signed-off-by: Hugo Lefeuvre Reviewed-by: Luca Seritan Reviewed-by: Delia Pavel Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #840 --- diff --git a/lib/ukalloc/alloc.c b/lib/ukalloc/alloc.c index 5b2848330..4c580bfd7 100644 --- a/lib/ukalloc/alloc.c +++ b/lib/ukalloc/alloc.c @@ -212,7 +212,7 @@ void *uk_realloc_ifpages(struct uk_alloc *a, void *ptr, __sz size) if (!ptr) return uk_malloc_ifpages(a, size); - if (ptr && !size) { + if (!size) { uk_free_ifpages(a, ptr); return __NULL; } @@ -423,7 +423,7 @@ void *uk_realloc_ifmalloc(struct uk_alloc *a, void *ptr, __sz size) if (!ptr) return uk_malloc_ifmalloc(a, size); - if (ptr && !size) { + if (!size) { uk_free_ifmalloc(a, ptr); return __NULL; } @@ -529,7 +529,7 @@ void *uk_realloc_compat(struct uk_alloc *a, void *ptr, __sz size) if (!ptr) return uk_malloc(a, size); - if (ptr && !size) { + if (!size) { uk_free(a, ptr); return __NULL; }