Enable -Wformat-pedantic and fix fallout.

Differential Revision: https://reviews.llvm.org/D113172
This commit is contained in:
Martin Liska 2021-11-04 08:54:14 +01:00
parent c1e7911c3b
commit 13a442ca49
12 changed files with 26 additions and 22 deletions

View File

@ -443,7 +443,6 @@ append_list_if(COMPILER_RT_HAS_WGNU_FLAG -Wno-gnu SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG -Wno-c99-extensions SANITIZER_COMMON_CFLAGS)
# format-pedantic warns about passing T* for %p, which is not useful.
append_list_if(COMPILER_RT_HAS_WNO_FORMAT_PEDANTIC -Wno-format-pedantic SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WD4146_FLAG /wd4146 SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WD4291_FLAG /wd4291 SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WD4391_FLAG /wd4391 SANITIZER_COMMON_CFLAGS)

View File

@ -538,7 +538,8 @@ static void PrintLegend(InternalScopedString *str) {
static void PrintShadowBytes(InternalScopedString *str, const char *before,
u8 *bytes, u8 *guilty, uptr n) {
Decorator d;
if (before) str->append("%s%p:", before, bytes);
if (before)
str->append("%s%p:", before, (void *)bytes);
for (uptr i = 0; i < n; i++) {
u8 *p = bytes + i;
const char *before =

View File

@ -54,10 +54,11 @@ FakeStack *FakeStack::Create(uptr stack_size_log) {
: MmapOrDie(size, "FakeStack"));
res->stack_size_log_ = stack_size_log;
u8 *p = reinterpret_cast<u8 *>(res);
VReport(1, "T%d: FakeStack created: %p -- %p stack_size_log: %zd; "
VReport(1,
"T%d: FakeStack created: %p -- %p stack_size_log: %zd; "
"mmapped %zdK, noreserve=%d \n",
GetCurrentTidOrInvalid(), p,
p + FakeStack::RequiredSize(stack_size_log), stack_size_log,
GetCurrentTidOrInvalid(), (void *)p,
(void *)(p + FakeStack::RequiredSize(stack_size_log)), stack_size_log,
size >> 10, flags()->uar_noreserve);
return res;
}

View File

@ -89,8 +89,8 @@ static void ReportGlobal(const Global &g, const char *prefix) {
g.module_name, g.has_dynamic_init, (void *)g.odr_indicator);
if (g.location) {
Report(" location (%p): name=%s[%p], %d %d\n", (void *)g.location,
g.location->filename, g.location->filename, g.location->line_no,
g.location->column_no);
g.location->filename, (void *)g.location->filename,
g.location->line_no, g.location->column_no);
}
}

View File

@ -359,7 +359,7 @@ ALWAYS_INLINE void CfiSlowPathCommon(u64 CallSiteTypeId, void *Ptr,
return;
}
CFICheckFn cfi_check = sv.get_cfi_check();
VReport(2, "__cfi_check at %p\n", cfi_check);
VReport(2, "__cfi_check at %p\n", (void *)cfi_check);
cfi_check(CallSiteTypeId, Ptr, DiagData);
}

View File

@ -916,7 +916,7 @@ static bool ProtectMemoryRange(uptr beg, uptr size, const char *name) {
// Consider refactoring these into a shared implementation.
bool InitShadow(bool init_origins) {
// Let user know mapping parameters first.
VPrintf(1, "dfsan_init %p\n", &__dfsan::dfsan_init);
VPrintf(1, "dfsan_init %p\n", (void *)&__dfsan::dfsan_init);
for (unsigned i = 0; i < kMemoryLayoutSize; ++i)
VPrintf(1, "%s: %zx - %zx\n", kMemoryLayout[i].name, kMemoryLayout[i].start,
kMemoryLayout[i].end - 1);

View File

@ -518,7 +518,7 @@ static void PrintTagInfoAroundAddr(tag_t *tag_ptr, uptr num_rows,
InternalScopedString s;
for (tag_t *row = beg_row; row < end_row; row += row_len) {
s.append("%s", row == center_row_beg ? "=>" : " ");
s.append("%p:", row);
s.append("%p:", (void *)row);
for (uptr i = 0; i < row_len; i++) {
s.append("%s", row + i == tag_ptr ? "[" : " ");
print_tag(s, &row[i]);

View File

@ -108,10 +108,9 @@ void Thread::Destroy() {
}
void Thread::Print(const char *Prefix) {
Printf("%sT%zd %p stack: [%p,%p) sz: %zd tls: [%p,%p)\n", Prefix,
unique_id_, this, stack_bottom(), stack_top(),
stack_top() - stack_bottom(),
tls_begin(), tls_end());
Printf("%sT%zd %p stack: [%p,%p) sz: %zd tls: [%p,%p)\n", Prefix, unique_id_,
(void *)this, stack_bottom(), stack_top(),
stack_top() - stack_bottom(), tls_begin(), tls_end());
}
static u32 xorshift(u32 state) {

View File

@ -131,7 +131,7 @@ void MemprofThread::Init(const InitOptions *options) {
int local = 0;
VReport(1, "T%d: stack [%p,%p) size 0x%zx; local=%p\n", tid(),
(void *)stack_bottom_, (void *)stack_top_, stack_top_ - stack_bottom_,
&local);
(void *)&local);
}
thread_return_t
@ -198,7 +198,7 @@ MemprofThread *GetCurrentThread() {
void SetCurrentThread(MemprofThread *t) {
CHECK(t->context());
VReport(2, "SetCurrentThread: %p for thread %p\n", t->context(),
VReport(2, "SetCurrentThread: %p for thread %p\n", (void *)t->context(),
(void *)GetThreadSelf());
// Make sure we do not reset the current MemprofThread.
CHECK_EQ(0, TSDGet());

View File

@ -515,7 +515,7 @@ void __msan_dump_shadow(const void *x, uptr size) {
}
unsigned char *s = (unsigned char*)MEM_TO_SHADOW(x);
Printf("%p[%p] ", s, x);
Printf("%p[%p] ", (void *)s, x);
for (uptr i = 0; i < size; i++)
Printf("%x%x ", s[i] >> 4, s[i] & 0xf);
Printf("\n");

View File

@ -198,7 +198,8 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
}
break;
default:
Report("Unsupported specifier in stack frame format: %c (%p)!\n", *p, p);
Report("Unsupported specifier in stack frame format: %c (%p)!\n", *p,
(void *)p);
Die();
}
}
@ -250,7 +251,7 @@ void RenderData(InternalScopedString *buffer, const char *format,
break;
default:
Report("Unsupported specifier in stack frame format: %c (%p)!\n", *p,
p);
(void *)p);
Die();
}
}

View File

@ -148,7 +148,8 @@ bool patchFunctionEntry(const bool Enable, const uint32_t FuncId,
int64_t TrampolineOffset = reinterpret_cast<int64_t>(Trampoline) -
(static_cast<int64_t>(Address) + 11);
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
Report("XRay Entry trampoline (%p) too far from sled (%p)\n", Trampoline,
Report("XRay Entry trampoline (%p) too far from sled (%p)\n",
reinterpret_cast<void *>(Trampoline),
reinterpret_cast<void *>(Address));
return false;
}
@ -195,7 +196,8 @@ bool patchFunctionExit(const bool Enable, const uint32_t FuncId,
(static_cast<int64_t>(Address) + 11);
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
Report("XRay Exit trampoline (%p) too far from sled (%p)\n",
__xray_FunctionExit, reinterpret_cast<void *>(Address));
reinterpret_cast<void *>(__xray_FunctionExit),
reinterpret_cast<void *>(Address));
return false;
}
if (Enable) {
@ -224,7 +226,8 @@ bool patchFunctionTailExit(const bool Enable, const uint32_t FuncId,
(static_cast<int64_t>(Address) + 11);
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
Report("XRay Tail Exit trampoline (%p) too far from sled (%p)\n",
__xray_FunctionTailExit, reinterpret_cast<void *>(Address));
reinterpret_cast<void *>(__xray_FunctionTailExit),
reinterpret_cast<void *>(Address));
return false;
}
if (Enable) {