diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index 04bbc0148f..b89a21868f 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -111,9 +111,9 @@ static inline void mempool_add_backtrace(FAR struct mempool_s *pool, if (pool->procfs.backtrace) { int result = backtrace(buf->backtrace, CONFIG_MM_BACKTRACE); - while (result < CONFIG_MM_BACKTRACE) + if (result < CONFIG_MM_BACKTRACE) { - buf->backtrace[result++] = NULL; + buf->backtrace[result] = NULL; } } else diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index 10ee0596ac..952f2ed459 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -89,14 +89,14 @@ if ((heap)->mm_procfs.backtrace || (tcb && tcb->flags & TCB_FLAG_HEAP_DUMP)) \ { \ int n = backtrace(tmp->backtrace, CONFIG_MM_BACKTRACE); \ - while (n < CONFIG_MM_BACKTRACE) \ + if (n < CONFIG_MM_BACKTRACE) \ { \ - tmp->backtrace[n++] = NULL; \ + tmp->backtrace[n] = NULL; \ } \ } \ else \ { \ - tmp->backtrace[0] = 0; \ + tmp->backtrace[0] = NULL; \ } \ } \ while (0) diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 46afac384e..291a7ace30 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -156,9 +156,9 @@ static void memdump_backtrace(FAR struct mm_heap_s *heap, (tcb && tcb->flags & TCB_FLAG_HEAPDUMP)) { int ret = backtrace(dump->backtrace, CONFIG_MM_BACKTRACE); - while (ret < CONFIG_MM_BACKTRACE) + if (ret < CONFIG_MM_BACKTRACE) { - dump->backtrace[ret++] = NULL; + dump->backtrace[ret] = NULL; } } # endif