From f28eff61aeb62c867249c8cb21162dbd3c60cc37 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 25 Nov 2014 13:46:14 -0600 Subject: More fixes to problems noted by cppcheck. Some are kind of risky; some are real bugs. --- nuttx/mm/mm_heap/mm_malloc.c | 2 +- nuttx/mm/mm_heap/mm_realloc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'nuttx/mm') diff --git a/nuttx/mm/mm_heap/mm_malloc.c b/nuttx/mm/mm_heap/mm_malloc.c index 20b1916c8..9890e5712 100644 --- a/nuttx/mm/mm_heap/mm_malloc.c +++ b/nuttx/mm/mm_heap/mm_malloc.c @@ -91,7 +91,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) /* Handle bad sizes */ - if (size <= 0) + if (size < 1) { return NULL; } diff --git a/nuttx/mm/mm_heap/mm_realloc.c b/nuttx/mm/mm_heap/mm_realloc.c index f41d019b5..5778975f5 100644 --- a/nuttx/mm/mm_heap/mm_realloc.c +++ b/nuttx/mm/mm_heap/mm_realloc.c @@ -101,7 +101,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, /* If size is zero, then realloc is equivalent to free */ - if (size <= 0) + if (size < 1) { mm_free(heap, oldmem); return NULL; @@ -170,7 +170,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, * previous chunk is smaller than the next chunk. */ - if (prevsize > 0 && (nextsize >= prevsize || nextsize <= 0)) + if (prevsize > 0 && (nextsize >= prevsize || nextsize < 1)) { /* Can we get everything we need from the previous chunk? */ -- cgit v1.2.3