You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/15 14:00:12 UTC

[incubator-nuttx] branch master updated: mm/mm_heap: Fix warnings included by #266

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 312ea9f  mm/mm_heap: Fix warnings included by #266
312ea9f is described below

commit 312ea9f99eac4c5ddb63633a68899620c606b8e4
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Sat Feb 15 13:21:43 2020 +0000

    mm/mm_heap: Fix warnings included by #266
---
 mm/mm_heap/mm_mallinfo.c | 16 ++++++++++------
 mm/mm_heap/mm_malloc.c   |  2 +-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/mm/mm_heap/mm_mallinfo.c b/mm/mm_heap/mm_mallinfo.c
index ae3d6b8..dd980d1 100644
--- a/mm/mm_heap/mm_mallinfo.c
+++ b/mm/mm_heap/mm_mallinfo.c
@@ -60,7 +60,9 @@
 int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
 {
   FAR struct mm_allocnode_s *node;
-  FAR struct mm_allocnode_s *prev;
+#ifdef CONFIG_DEBUG_ASSERTIONS
+  FAR struct mm_allocnode_s *prev = NULL;
+#endif
   size_t mxordblk = 0;
   int    ordblks  = 0;  /* Number of non-inuse chunks */
   size_t uordblks = 0;  /* Total allocated space */
@@ -85,9 +87,8 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
 
       mm_takesemaphore(heap);
 
-      for (prev = NULL, node = heap->mm_heapstart[region];
+      for (node = heap->mm_heapstart[region];
            node < heap->mm_heapend[region];
-           prev = node,
            node = (FAR struct mm_allocnode_s *)
                   ((FAR char *)node + node->size))
         {
@@ -105,9 +106,10 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
             }
           else
             {
-              FAR struct mm_freenode_s *fnode;
+#ifdef CONFIG_DEBUG_ASSERTIONS
+              FAR struct mm_freenode_s *fnode = (FAR void *)node;
+#endif
               DEBUGASSERT(node->size >= SIZEOF_MM_FREENODE);
-              fnode = (FAR void *)node;
               DEBUGASSERT(fnode->blink->flink == fnode);
               DEBUGASSERT(fnode->blink->size <= fnode->size);
               DEBUGASSERT(fnode->flink == NULL ||
@@ -122,7 +124,9 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
                   mxordblk = node->size;
                 }
             }
-
+#ifdef CONFIG_DEBUG_ASSERTIONS
+          prev = node;
+#endif
           DEBUGASSERT(prev == NULL ||
                       prev->size == (node->preceding & ~MM_ALLOC_BIT));
         }
diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c
index 6230e4f..b335571 100644
--- a/mm/mm_heap/mm_malloc.c
+++ b/mm/mm_heap/mm_malloc.c
@@ -118,7 +118,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
 
   for (node = heap->mm_nodelist[ndx].flink;
        node && node->size < alignsize;
-       node = node->flink);
+       node = node->flink)
     {
       DEBUGASSERT(node->blink->flink == node);
     }