[U-Boot] [PATCH 1/1] malloc: compare pointer to NULL not to 0.

Heinrich Schuchardt xypron.glpk at gmx.de
Fri Nov 10 19:51:35 UTC 2017


victim is defined as:

typedef struct malloc_chunk* mchunkptr;
mchunkptr victim;

So victim should be compared to NULL and not to 0.

Problem identified with Coccinelle.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 common/dlmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index c37979b43f..86bbd57a4c 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1461,7 +1461,7 @@ Void_t* mALLOc(bytes) size_t bytes;
 #if HAVE_MMAP
     /* If big and would otherwise need to extend, try to use mmap instead */
     if ((unsigned long)nb >= (unsigned long)mmap_threshold &&
-	(victim = mmap_chunk(nb)) != 0)
+	(victim = mmap_chunk(nb)) != NULL)
       return chunk2mem(victim);
 #endif
 
-- 
2.14.2



More information about the U-Boot mailing list