From 12836a6f3aad94b6904091824e6b46eb7621f4d9 Mon Sep 17 00:00:00 2001 From: Hugo Lefeuvre Date: Sun, 16 Apr 2023 10:53:17 +0200 Subject: [PATCH] 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 --- lib/ukalloc/alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; } -- 2.39.5