diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index 924bea2abe..f4c1ab03d0 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -516,11 +516,11 @@ static ssize_t memdump_write(FAR struct file *filep, FAR const char *buffer, switch (buffer[0]) { case 'u': - pid = (pid_t)-1; + pid = MM_BACKTRACE_ALLOC_PID; break; case 'f': - pid = (pid_t)-2; + pid = MM_BACKTRACE_FREE_PID; break; #if CONFIG_MM_BACKTRACE >= 0 default: diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h index f8788a3dee..3ca86d1e47 100644 --- a/include/nuttx/mm/mm.h +++ b/include/nuttx/mm/mm.h @@ -98,6 +98,9 @@ # endif #endif +#define MM_BACKTRACE_FREE_PID ((pid_t)-2) +#define MM_BACKTRACE_ALLOC_PID ((pid_t)-1) + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index 22aa61ca27..182b3b1193 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -398,7 +398,7 @@ int mempool_info_task(FAR struct mempool_s *pool, irqstate_t flags = spin_lock_irqsave(&pool->lock); DEBUGASSERT(info); - if (info->pid == -2) + if (info->pid == MM_BACKTRACE_FREE_PID) { size_t count = mempool_queue_lenth(&pool->queue) + mempool_queue_lenth(&pool->iqueue); @@ -411,7 +411,7 @@ int mempool_info_task(FAR struct mempool_s *pool, info->uordblks -= pool->totalsize; } } - else if (info->pid == -1) + else if (info->pid == MM_BACKTRACE_ALLOC_PID) { #if CONFIG_MM_BACKTRACE >= 0 size_t count = list_length(&pool->alist); @@ -466,7 +466,7 @@ int mempool_info_task(FAR struct mempool_s *pool, void mempool_memdump(FAR struct mempool_s *pool, pid_t pid) { - if (pid == -2) + if (pid == MM_BACKTRACE_FREE_PID) { FAR sq_entry_t *entry; @@ -492,7 +492,7 @@ void mempool_memdump(FAR struct mempool_s *pool, pid_t pid) list_for_every_entry(&pool->alist, buf, struct mempool_backtrace_s, node) { - if (buf->pid == pid || pid == -1) + if (buf->pid == pid || pid == MM_BACKTRACE_ALLOC_PID) { # if CONFIG_MM_BACKTRACE > 0 int i; diff --git a/mm/mm_heap/mm_mallinfo.c b/mm/mm_heap/mm_mallinfo.c index 85dd2e3b74..78f52f4cdb 100644 --- a/mm/mm_heap/mm_mallinfo.c +++ b/mm/mm_heap/mm_mallinfo.c @@ -87,16 +87,16 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node, { DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE); #if CONFIG_MM_BACKTRACE < 0 - if (info->pid == -1) + if (info->pid == MM_BACKTRACE_ALLOC_PID) #else - if (info->pid == -1 || node->pid == info->pid) + if (info->pid == MM_BACKTRACE_ALLOC_PID || node->pid == info->pid) #endif { info->aordblks++; info->uordblks += nodesize; } } - else if (info->pid == -2) + else if (info->pid == MM_BACKTRACE_FREE_PID) { info->aordblks++; info->uordblks += nodesize; diff --git a/mm/mm_heap/mm_memdump.c b/mm/mm_heap/mm_memdump.c index 55c8722abd..6abf0b3b52 100644 --- a/mm/mm_heap/mm_memdump.c +++ b/mm/mm_heap/mm_memdump.c @@ -60,9 +60,9 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg) { DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE); #if CONFIG_MM_BACKTRACE < 0 - if (pid == -1) + if (pid == MM_BACKTRACE_ALLOC_PID) #else - if (pid == -1 || node->pid == pid) + if (pid == MM_BACKTRACE_ALLOC_PID || node->pid == pid) #endif { #if CONFIG_MM_BACKTRACE < 0 @@ -104,7 +104,7 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg) SIZEOF_MM_NODE(fnode->flink) == 0 || SIZEOF_MM_NODE(fnode->flink) >= nodesize); - if (pid <= -2) + if (pid <= MM_BACKTRACE_FREE_PID) { syslog(LOG_INFO, "%12zu%*p\n", nodesize, MM_PTR_FMT_WIDTH, diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 7954d5a10c..25b111a163 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -263,16 +263,16 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used, if (used) { #if CONFIG_MM_BACKTRACE < 0 - if (info->pid = -1) + if (info->pid = MM_BACKTRACE_ALLOC_PID) #else - if (info->pid == -1 || info->pid == dump->pid) + if (info->pid == MM_BACKTRACE_ALLOC_PID || info->pid == dump->pid) #endif { info->aordblks++; info->uordblks += size; } } - else if (info->pid == -2) + else if (info->pid == MM_BACKTRACE_FREE_PID) { info->aordblks++; info->uordblks += size; @@ -377,9 +377,9 @@ static void memdump_handler(FAR void *ptr, size_t size, int used, if (used) { #if CONFIG_MM_BACKTRACE < 0 - if (pid == -1) + if (pid == MM_BACKTRACE_ALLOC_PID) #else - if (pid == -1 || dump->pid == pid) + if (pid == MM_BACKTRACE_ALLOC_PID || dump->pid == pid) #endif { #if CONFIG_MM_BACKTRACE < 0 @@ -406,7 +406,7 @@ static void memdump_handler(FAR void *ptr, size_t size, int used, #endif } } - else if (pid <= -2) + else if (pid <= MM_BACKTRACE_FREE_PID) { syslog(LOG_INFO, "%12zu%*p\n", size, MM_PTR_FMT_WIDTH, ptr); } @@ -904,7 +904,7 @@ void mm_memdump(FAR struct mm_heap_s *heap, pid_t pid) #endif struct memdump_info_s info; - if (pid >= -1) + if (pid >= MM_BACKTRACE_ALLOC_PID) { syslog(LOG_INFO, "Dump all used memory node info:\n"); #if CONFIG_MM_BACKTRACE < 0