1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/malloc_tracing: fix calloc printouts

This commit is contained in:
Benjamin Valentin 2023-11-07 16:29:43 +01:00
parent 616932f24b
commit f731ec7bff

View File

@ -53,7 +53,7 @@ void __attribute__((used)) __wrap_free(void *ptr)
{ {
if (IS_USED(MODULE_MALLOC_TRACING)) { if (IS_USED(MODULE_MALLOC_TRACING)) {
uinttxtptr_t pc = cpu_get_caller_pc(); uinttxtptr_t pc = cpu_get_caller_pc();
printf("free(%p) @0x%" PRIxTXTPTR ")\n", ptr, pc); printf("free(%p) @ 0x%" PRIxTXTPTR ")\n", ptr, pc);
} }
assert(!irq_is_in()); assert(!irq_is_in());
mutex_lock(&_lock); mutex_lock(&_lock);
@ -73,7 +73,7 @@ void * __attribute__((used)) __wrap_calloc(size_t nmemb, size_t size)
size_t total_size; size_t total_size;
if (__builtin_mul_overflow(nmemb, size, &total_size)) { if (__builtin_mul_overflow(nmemb, size, &total_size)) {
if (IS_USED(MODULE_MALLOC_TRACING)) { if (IS_USED(MODULE_MALLOC_TRACING)) {
printf("calloc(%u, %u) @0x%" PRIxTXTPTR " overflowed\n", printf("calloc(%u, %u) @ 0x%" PRIxTXTPTR " overflowed\n",
(unsigned)nmemb, (unsigned)size, pc); (unsigned)nmemb, (unsigned)size, pc);
} }
return NULL; return NULL;
@ -87,7 +87,7 @@ void * __attribute__((used)) __wrap_calloc(size_t nmemb, size_t size)
} }
if (IS_USED(MODULE_MALLOC_TRACING)) { if (IS_USED(MODULE_MALLOC_TRACING)) {
printf("calloc(%u, %u) @0x%" PRIxTXTPTR " returned %p\n", printf("calloc(%u, %u) @ 0x%" PRIxTXTPTR " returned %p\n",
(unsigned)nmemb, (unsigned)size, pc, res); (unsigned)nmemb, (unsigned)size, pc, res);
} }