mm: Terminate the backtrace array with one NULL pointer

since one entry is enough to identify the end of back trace

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-11-24 19:36:21 +08:00 committed by Xiang Xiao
parent 29404ef54e
commit 154bb93c45
3 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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)

View File

@ -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