From ec8550e87fcd72c32f832e8ca40dad36bc7ba73c Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 22 Jun 2022 12:06:33 +0200 Subject: [PATCH] Fix unwind backtrace warnings --- winpr/libwinpr/utils/unwind/debug.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/winpr/libwinpr/utils/unwind/debug.c b/winpr/libwinpr/utils/unwind/debug.c index 4e86f7b1f..8b49b22b9 100644 --- a/winpr/libwinpr/utils/unwind/debug.c +++ b/winpr/libwinpr/utils/unwind/debug.c @@ -95,14 +95,19 @@ void winpr_unwind_backtrace_free(void* buffer) char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used) { size_t x; - char** str = NULL; + union + { + char* cp; + char** cpp; + } cnv; unwind_context_t* ctx = buffer; + cnv.cpp = NULL; if (!ctx) return NULL; - str = calloc(ctx->pos * (sizeof(char*) + UNWIND_MAX_LINE_SIZE), sizeof(char*)); - if (!str) + cnv.cpp = calloc(ctx->pos * (sizeof(char*) + UNWIND_MAX_LINE_SIZE), sizeof(char*)); + if (!cnv.cpp) return NULL; if (used) @@ -110,19 +115,19 @@ char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used) for (x = 0; x < ctx->pos; x++) { - char* msg = str + ctx->pos * sizeof(char*) + x * UNWIND_MAX_LINE_SIZE; + char* msg = cnv.cp + ctx->pos * sizeof(char*) + x * UNWIND_MAX_LINE_SIZE; const unwind_info_t* info = &ctx->info[x]; Dl_info dlinfo = { 0 }; - int rc = dladdr(info->pc, &dlinfo); + int rc = dladdr((void*)info->pc, &dlinfo); - str[x] = msg; + cnv.cpp[x] = msg; if (rc == 0) - _snprintf(msg, UNWIND_MAX_LINE_SIZE, "unresolvable, address=%p", info->pc); + _snprintf(msg, UNWIND_MAX_LINE_SIZE, "unresolvable, address=%p", (void*)info->pc); else _snprintf(msg, UNWIND_MAX_LINE_SIZE, "dli_fname=%s [%p], dli_sname=%s [%p]", dlinfo.dli_fname, dlinfo.dli_fbase, dlinfo.dli_sname, dlinfo.dli_saddr); } - return str; + return cnv.cpp; }