mm/tlsf: Change "memdump_backtrace_s *dump" to memdump_backtrace_s *buf"

avoid the conflict with "mm_memdump_s *dump"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-05-28 19:40:46 +08:00 committed by Petro Karashchenko
parent 66c2d2ecc4
commit 3edff9d323

View File

@ -138,23 +138,23 @@ struct mm_mallinfo_handler_s
****************************************************************************/ ****************************************************************************/
static void memdump_backtrace(FAR struct mm_heap_s *heap, static void memdump_backtrace(FAR struct mm_heap_s *heap,
FAR struct memdump_backtrace_s *dump) FAR struct memdump_backtrace_s *buf)
{ {
# if CONFIG_MM_BACKTRACE > 0 # if CONFIG_MM_BACKTRACE > 0
FAR struct tcb_s *tcb; FAR struct tcb_s *tcb;
# endif # endif
dump->pid = _SCHED_GETTID(); buf->pid = _SCHED_GETTID();
dump->seqno = g_mm_seqno++; buf->seqno = g_mm_seqno++;
# if CONFIG_MM_BACKTRACE > 0 # if CONFIG_MM_BACKTRACE > 0
tcb = nxsched_get_tcb(dump->pid); tcb = nxsched_get_tcb(buf->pid);
if (heap->mm_procfs.backtrace || if (heap->mm_procfs.backtrace ||
(tcb && tcb->flags & TCB_FLAG_HEAPDUMP)) (tcb && tcb->flags & TCB_FLAG_HEAPDUMP))
{ {
int ret = backtrace(dump->backtrace, CONFIG_MM_BACKTRACE); int ret = backtrace(buf->backtrace, CONFIG_MM_BACKTRACE);
if (ret < CONFIG_MM_BACKTRACE) if (ret < CONFIG_MM_BACKTRACE)
{ {
dump->backtrace[ret] = NULL; buf->backtrace[ret] = NULL;
} }
} }
# endif # endif
@ -234,14 +234,14 @@ static void free_delaylist(FAR struct mm_heap_s *heap)
static FAR void *mempool_memalign(FAR void *arg, size_t alignment, static FAR void *mempool_memalign(FAR void *arg, size_t alignment,
size_t size) size_t size)
{ {
FAR struct memdump_backtrace_s *dump; FAR struct memdump_backtrace_s *buf;
FAR void *ret; FAR void *ret;
ret = mm_memalign(arg, alignment, size); ret = mm_memalign(arg, alignment, size);
if (ret) if (ret)
{ {
dump = ret + mm_malloc_size(arg, ret); buf = ret + mm_malloc_size(arg, ret);
dump->pid = MM_BACKTRACE_MEMPOOL_PID; buf->pid = MM_BACKTRACE_MEMPOOL_PID;
} }
return ret; return ret;
@ -282,13 +282,13 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
FAR void *user) FAR void *user)
{ {
#if CONFIG_MM_BACKTRACE >= 0 #if CONFIG_MM_BACKTRACE >= 0
FAR struct memdump_backtrace_s *dump; FAR struct memdump_backtrace_s *buf;
#endif #endif
FAR struct mm_mallinfo_handler_s *handler = user; FAR struct mm_mallinfo_handler_s *handler = user;
#if CONFIG_MM_BACKTRACE >= 0 #if CONFIG_MM_BACKTRACE >= 0
size -= sizeof(struct memdump_backtrace_s); size -= sizeof(struct memdump_backtrace_s);
dump = ptr + size; buf = ptr + size;
if (used) if (used)
{ {
@ -300,12 +300,12 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
} }
#else #else
if (handler->dump->pid == MM_BACKTRACE_ALLOC_PID || if (handler->dump->pid == MM_BACKTRACE_ALLOC_PID ||
handler->dump->pid == dump->pid || handler->dump->pid == buf->pid ||
(handler->dump->pid == MM_BACKTRACE_INVALID_PID && (handler->dump->pid == MM_BACKTRACE_INVALID_PID &&
nxsched_get_tcb(dump->pid) == NULL)) nxsched_get_tcb(buf->pid) == NULL))
{ {
if (dump->seqno >= handler->dump->seqmin && if (buf->seqno >= handler->dump->seqmin &&
dump->seqno <= handler->dump->seqmax) buf->seqno <= handler->dump->seqmax)
{ {
handler->info->aordblks++; handler->info->aordblks++;
handler->info->uordblks += size; handler->info->uordblks += size;
@ -409,10 +409,10 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
{ {
FAR const struct mm_memdump_s *dump = user; FAR const struct mm_memdump_s *dump = user;
#if CONFIG_MM_BACKTRACE >= 0 #if CONFIG_MM_BACKTRACE >= 0
FAR struct memdump_backtrace_s *bt; FAR struct memdump_backtrace_s *buf;
size -= sizeof(struct memdump_backtrace_s); size -= sizeof(struct memdump_backtrace_s);
bt = ptr + size; buf = ptr + size;
#endif #endif
if (used) if (used)
@ -421,9 +421,9 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
if (pid == MM_BACKTRACE_ALLOC_PID) if (pid == MM_BACKTRACE_ALLOC_PID)
#else #else
if ((dump->pid == MM_BACKTRACE_ALLOC_PID || if ((dump->pid == MM_BACKTRACE_ALLOC_PID ||
bt->pid == dump->pid) && buf->pid == dump->pid) &&
bt->seqno >= dump->seqmin && buf->seqno >= dump->seqmin &&
bt->seqno <= dump->seqmax) buf->seqno <= dump->seqmax)
#endif #endif
{ {
#if CONFIG_MM_BACKTRACE < 0 #if CONFIG_MM_BACKTRACE < 0
@ -433,21 +433,21 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
int i; int i;
FAR const char *format = " %0*p"; FAR const char *format = " %0*p";
# endif # endif
char buf[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1]; char tmp[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1];
buf[0] = '\0'; tmp[0] = '\0';
# if CONFIG_MM_BACKTRACE > 0 # if CONFIG_MM_BACKTRACE > 0
for (i = 0; i < CONFIG_MM_BACKTRACE && dump->backtrace[i]; i++) for (i = 0; i < CONFIG_MM_BACKTRACE && buf->backtrace[i]; i++)
{ {
snprintf(buf + i * MM_PTR_FMT_WIDTH, snprintf(tmp + i * MM_PTR_FMT_WIDTH,
sizeof(buf) - i * MM_PTR_FMT_WIDTH, sizeof(tmp) - i * MM_PTR_FMT_WIDTH,
format, MM_PTR_FMT_WIDTH - 1, dump->backtrace[i]); format, MM_PTR_FMT_WIDTH - 1, buf->backtrace[i]);
} }
# endif # endif
syslog(LOG_INFO, "%6d%12zu%12lu%*p%s\n", syslog(LOG_INFO, "%6d%12zu%12lu%*p%s\n",
(int)bt->pid, size, bt->seqno, MM_PTR_FMT_WIDTH, (int)buf->pid, size, buf->seqno, MM_PTR_FMT_WIDTH,
ptr, buf); ptr, tmp);
#endif #endif
} }
} }
@ -1058,9 +1058,9 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
if (ret) if (ret)
{ {
#if CONFIG_MM_BACKTRACE >= 0 #if CONFIG_MM_BACKTRACE >= 0
FAR struct memdump_backtrace_s *dump = ret + mm_malloc_size(heap, ret); FAR struct memdump_backtrace_s *buf = ret + mm_malloc_size(heap, ret);
memdump_backtrace(heap, dump); memdump_backtrace(heap, buf);
#endif #endif
kasan_unpoison(ret, mm_malloc_size(heap, ret)); kasan_unpoison(ret, mm_malloc_size(heap, ret));
} }
@ -1112,9 +1112,9 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
if (ret) if (ret)
{ {
#if CONFIG_MM_BACKTRACE >= 0 #if CONFIG_MM_BACKTRACE >= 0
FAR struct memdump_backtrace_s *dump = ret + mm_malloc_size(heap, ret); FAR struct memdump_backtrace_s *buf = ret + mm_malloc_size(heap, ret);
memdump_backtrace(heap, dump); memdump_backtrace(heap, buf);
#endif #endif
kasan_unpoison(ret, mm_malloc_size(heap, ret)); kasan_unpoison(ret, mm_malloc_size(heap, ret));
} }
@ -1216,10 +1216,10 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
#if CONFIG_MM_BACKTRACE >= 0 #if CONFIG_MM_BACKTRACE >= 0
if (newmem) if (newmem)
{ {
FAR struct memdump_backtrace_s *dump = newmem + FAR struct memdump_backtrace_s *buf =
mm_malloc_size(heap, newmem); newmem + mm_malloc_size(heap, newmem);
memdump_backtrace(heap, dump); memdump_backtrace(heap, buf);
} }
#endif #endif