[libunwind] r351876 - Fix warnings about printf format strings
Martin Storsjo via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 22 12:50:39 PST 2019
Author: mstorsjo
Date: Tue Jan 22 12:50:39 2019
New Revision: 351876
URL: http://llvm.org/viewvc/llvm-project?rev=351876&view=rev
Log:
Fix warnings about printf format strings
Either adjust the format string to use a more exact type, or add casts
(for cases when printing pointers to structs/objects with a %p
format specifier).
Differential Revision: https://reviews.llvm.org/D56982
Modified:
libunwind/trunk/src/Unwind-seh.cpp
libunwind/trunk/src/Unwind-sjlj.c
Modified: libunwind/trunk/src/Unwind-seh.cpp
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-seh.cpp?rev=351876&r1=351875&r2=351876&view=diff
==============================================================================
--- libunwind/trunk/src/Unwind-seh.cpp (original)
+++ libunwind/trunk/src/Unwind-seh.cpp Tue Jan 22 12:50:39 2019
@@ -77,7 +77,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD
uintptr_t retval, target;
bool ours = false;
- _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler(%#010x(%x), %p)", ms_exc->ExceptionCode, ms_exc->ExceptionFlags, frame);
+ _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler(%#010lx(%lx), %p)",
+ ms_exc->ExceptionCode, ms_exc->ExceptionFlags,
+ (void *)frame);
if (ms_exc->ExceptionCode == STATUS_GCC_UNWIND) {
if (IS_TARGET_UNWIND(ms_exc->ExceptionFlags)) {
// Set up the upper return value (the lower one and the target PC
@@ -129,7 +131,10 @@ _GCC_specific_handler(PEXCEPTION_RECORD
}
}
- _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() calling personality function %p(1, %d, %llx, %p, %p)", pers, action, exc->exception_class, exc, ctx);
+ _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() calling personality "
+ "function %p(1, %d, %llx, %p, %p)",
+ (void *)pers, action, exc->exception_class,
+ (void *)exc, (void *)ctx);
urc = pers(1, action, exc->exception_class, exc, ctx);
_LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() personality returned %d", urc);
switch (urc) {
Modified: libunwind/trunk/src/Unwind-sjlj.c
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-sjlj.c?rev=351876&r1=351875&r2=351876&view=diff
==============================================================================
--- libunwind/trunk/src/Unwind-sjlj.c (original)
+++ libunwind/trunk/src/Unwind-sjlj.c Tue Jan 22 12:50:39 2019
@@ -11,6 +11,7 @@
#include <unwind.h>
+#include <inttypes.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -107,7 +108,8 @@ _Unwind_SjLj_Unregister(struct _Unwind_F
static _Unwind_Reason_Code
unwind_phase1(struct _Unwind_Exception *exception_object) {
_Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack();
- _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: initial function-context=%p", c);
+ _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: initial function-context=%p",
+ (void *)c);
// walk each frame looking for a place to stop
for (bool handlerNotFound = true; handlerNotFound; c = c->prev) {
@@ -116,17 +118,18 @@ unwind_phase1(struct _Unwind_Exception *
if (c == NULL) {
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): reached "
"bottom => _URC_END_OF_STACK",
- exception_object);
+ (void *)exception_object);
return _URC_END_OF_STACK;
}
- _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", c);
+ _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", (void *)c);
// if there is a personality routine, ask it if it will want to stop at this
// frame
if (c->personality != NULL) {
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): calling "
- "personality function %p",
- exception_object, c->personality);
+ "personality function %p",
+ (void *)exception_object,
+ (void *)c->personality);
_Unwind_Reason_Code personalityResult = (*c->personality)(
1, _UA_SEARCH_PHASE, exception_object->exception_class,
exception_object, (struct _Unwind_Context *)c);
@@ -137,12 +140,14 @@ unwind_phase1(struct _Unwind_Exception *
handlerNotFound = false;
exception_object->private_2 = (uintptr_t) c;
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "
- "_URC_HANDLER_FOUND", exception_object);
+ "_URC_HANDLER_FOUND",
+ (void *)exception_object);
return _URC_NO_REASON;
case _URC_CONTINUE_UNWIND:
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "
- "_URC_CONTINUE_UNWIND", exception_object);
+ "_URC_CONTINUE_UNWIND",
+ (void *)exception_object);
// continue unwinding
break;
@@ -150,7 +155,7 @@ unwind_phase1(struct _Unwind_Exception *
// something went wrong
_LIBUNWIND_TRACE_UNWINDING(
"unwind_phase1(ex_ojb=%p): _URC_FATAL_PHASE1_ERROR",
- exception_object);
+ (void *)exception_object);
return _URC_FATAL_PHASE1_ERROR;
}
}
@@ -161,19 +166,20 @@ unwind_phase1(struct _Unwind_Exception *
static _Unwind_Reason_Code
unwind_phase2(struct _Unwind_Exception *exception_object) {
- _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)", exception_object);
+ _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",
+ (void *)exception_object);
// walk each frame until we reach where search phase said to stop
_Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack();
while (true) {
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2s(ex_ojb=%p): context=%p",
- exception_object, c);
+ (void *)exception_object, (void *)c);
// check for no more frames
if (c == NULL) {
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
- "bottom => _URC_END_OF_STACK",
- exception_object);
+ "bottom => _URC_END_OF_STACK",
+ (void *)exception_object);
return _URC_END_OF_STACK;
}
@@ -193,7 +199,7 @@ unwind_phase2(struct _Unwind_Exception *
// continue unwinding
_LIBUNWIND_TRACE_UNWINDING(
"unwind_phase2(ex_ojb=%p): _URC_CONTINUE_UNWIND",
- exception_object);
+ (void *)exception_object);
if ((uintptr_t) c == exception_object->private_2) {
// phase 1 said we would stop at this frame, but we did not...
_LIBUNWIND_ABORT("during phase1 personality function said it would "
@@ -202,9 +208,9 @@ unwind_phase2(struct _Unwind_Exception *
break;
case _URC_INSTALL_CONTEXT:
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): "
- "_URC_INSTALL_CONTEXT, will resume at "
- "landing pad %p",
- exception_object, c->jbuf[1]);
+ "_URC_INSTALL_CONTEXT, will resume at "
+ "landing pad %p",
+ (void *)exception_object, c->jbuf[1]);
// personality routine says to transfer control to landing pad
// we may get control back if landing pad calls _Unwind_Resume()
__Unwind_SjLj_SetTopOfFunctionStack(c);
@@ -238,7 +244,7 @@ unwind_phase2_forced(struct _Unwind_Exce
if (c == NULL) {
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
"bottom => _URC_END_OF_STACK",
- exception_object);
+ (void *)exception_object);
return _URC_END_OF_STACK;
}
@@ -250,11 +256,11 @@ unwind_phase2_forced(struct _Unwind_Exce
(struct _Unwind_Context *)c, stop_parameter);
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
"stop function returned %d",
- exception_object, stopResult);
+ (void *)exception_object, stopResult);
if (stopResult != _URC_NO_REASON) {
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
"stopped by stop function",
- exception_object);
+ (void *)exception_object);
return _URC_FATAL_PHASE2_ERROR;
}
@@ -263,7 +269,7 @@ unwind_phase2_forced(struct _Unwind_Exce
__personality_routine p = (__personality_routine) c->personality;
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
"calling personality function %p",
- exception_object, p);
+ (void *)exception_object, (void *)p);
_Unwind_Reason_Code personalityResult =
(*p)(1, action, exception_object->exception_class, exception_object,
(struct _Unwind_Context *)c);
@@ -271,13 +277,13 @@ unwind_phase2_forced(struct _Unwind_Exce
case _URC_CONTINUE_UNWIND:
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
"personality returned _URC_CONTINUE_UNWIND",
- exception_object);
+ (void *)exception_object);
// destructors called, continue unwinding
break;
case _URC_INSTALL_CONTEXT:
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
"personality returned _URC_INSTALL_CONTEXT",
- exception_object);
+ (void *)exception_object);
// we may get control back if landing pad calls _Unwind_Resume()
__Unwind_SjLj_SetTopOfFunctionStack(c);
__builtin_longjmp(c->jbuf, 1);
@@ -287,7 +293,7 @@ unwind_phase2_forced(struct _Unwind_Exce
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
"personality returned %d, "
"_URC_FATAL_PHASE2_ERROR",
- exception_object, personalityResult);
+ (void *)exception_object, personalityResult);
return _URC_FATAL_PHASE2_ERROR;
}
}
@@ -297,8 +303,8 @@ unwind_phase2_forced(struct _Unwind_Exce
// call stop function one last time and tell it we've reached the end of the
// stack
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop "
- "function with _UA_END_OF_STACK",
- exception_object);
+ "function with _UA_END_OF_STACK",
+ (void *)exception_object);
_Unwind_Action lastAction =
(_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK);
(*stop)(1, lastAction, exception_object->exception_class, exception_object,
@@ -313,7 +319,8 @@ unwind_phase2_forced(struct _Unwind_Exce
/// Called by __cxa_throw. Only returns if there is a fatal error
_LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) {
- _LIBUNWIND_TRACE_API("_Unwind_SjLj_RaiseException(ex_obj=%p)", exception_object);
+ _LIBUNWIND_TRACE_API("_Unwind_SjLj_RaiseException(ex_obj=%p)",
+ (void *)exception_object);
// mark that this is a non-forced unwind, so _Unwind_Resume() can do the right
// thing
@@ -343,7 +350,8 @@ _Unwind_SjLj_RaiseException(struct _Unwi
/// __cxa_rethrow() which in turn calls _Unwind_Resume_or_Rethrow()
_LIBUNWIND_EXPORT void
_Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) {
- _LIBUNWIND_TRACE_API("_Unwind_SjLj_Resume(ex_obj=%p)", exception_object);
+ _LIBUNWIND_TRACE_API("_Unwind_SjLj_Resume(ex_obj=%p)",
+ (void *)exception_object);
if (exception_object->private_1 != 0)
unwind_phase2_forced(exception_object,
@@ -361,8 +369,8 @@ _Unwind_SjLj_Resume(struct _Unwind_Excep
_LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception *exception_object) {
_LIBUNWIND_TRACE_API("__Unwind_SjLj_Resume_or_Rethrow(ex_obj=%p), "
- "private_1=%ld",
- exception_object, exception_object->private_1);
+ "private_1=%" PRIuPTR,
+ (void *)exception_object, exception_object->private_1);
// If this is non-forced and a stopping place was found, then this is a
// re-throw.
// Call _Unwind_RaiseException() as if this was a new exception.
@@ -385,7 +393,8 @@ _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
_LIBUNWIND_TRACE_API("_Unwind_GetLanguageSpecificData(context=%p) "
- "=> 0x%0lX", context, ufc->lsda);
+ "=> 0x%" PRIuPTR,
+ (void *)context, ufc->lsda);
return ufc->lsda;
}
@@ -393,8 +402,8 @@ _Unwind_GetLanguageSpecificData(struct _
/// Called by personality handler during phase 2 to get register values.
_LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,
int index) {
- _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d)",
- context, index);
+ _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d)", (void *)context,
+ index);
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
return ufc->resumeParameters[index];
}
@@ -403,8 +412,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetG
/// Called by personality handler during phase 2 to alter register values.
_LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
uintptr_t new_value) {
- _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%0lX)"
- , context, index, new_value);
+ _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%" PRIuPTR
+ ")",
+ (void *)context, index, new_value);
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
ufc->resumeParameters[index] = new_value;
}
@@ -413,8 +423,8 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(str
/// Called by personality handler during phase 2 to get instruction pointer.
_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
- _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%lX", context,
- ufc->resumeLocation + 1);
+ _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIu32,
+ (void *)context, ufc->resumeLocation + 1);
return ufc->resumeLocation + 1;
}
@@ -426,8 +436,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetI
int *ipBefore) {
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
*ipBefore = 0;
- _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%lX",
- context, ipBefore, ufc->resumeLocation + 1);
+ _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%" PRIu32,
+ (void *)context, (void *)ipBefore,
+ ufc->resumeLocation + 1);
return ufc->resumeLocation + 1;
}
@@ -435,8 +446,8 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetI
/// Called by personality handler during phase 2 to alter instruction pointer.
_LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
uintptr_t new_value) {
- _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0lX)",
- context, new_value);
+ _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%" PRIuPTR ")",
+ (void *)context, new_value);
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
ufc->resumeLocation = new_value - 1;
}
@@ -448,7 +459,7 @@ _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetRegionStart(struct _Unwind_Context *context) {
// Not supported or needed for sjlj based unwinding
(void)context;
- _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", context);
+ _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", (void *)context);
return 0;
}
@@ -458,7 +469,7 @@ _Unwind_GetRegionStart(struct _Unwind_Co
_LIBUNWIND_EXPORT void
_Unwind_DeleteException(struct _Unwind_Exception *exception_object) {
_LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)",
- exception_object);
+ (void *)exception_object);
if (exception_object->exception_cleanup != NULL)
(*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT,
exception_object);
@@ -472,7 +483,7 @@ _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetDataRelBase(struct _Unwind_Context *context) {
// Not supported or needed for sjlj based unwinding
(void)context;
- _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", context);
+ _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", (void *)context);
_LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented");
}
@@ -483,14 +494,14 @@ _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetTextRelBase(struct _Unwind_Context *context) {
// Not supported or needed for sjlj based unwinding
(void)context;
- _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", context);
+ _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", (void *)context);
_LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented");
}
/// Called by personality handler to get "Call Frame Area" for current frame.
_LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {
- _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p)", context);
+ _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p)", (void *)context);
if (context != NULL) {
_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
// Setjmp/longjmp based exceptions don't have a true CFA.
More information about the cfe-commits
mailing list