Skip to content

Conversation

DanBlackwell
Copy link
Contributor

Currently there are many warning: format specifies type 'void *' warnings when compiling TSan with debug output.

This patch adds the void * casts where necessary to eliminate the warnings.

@llvmbot
Copy link
Member

llvmbot commented Sep 30, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Dan Blackwell (DanBlackwell)

Changes

Currently there are many warning: format specifies type 'void *' warnings when compiling TSan with debug output.

This patch adds the void * casts where necessary to eliminate the warnings.


Full diff: https://github.com/llvm/llvm-project/pull/161371.diff

3 Files Affected:

  • (modified) compiler-rt/lib/tsan/rtl/tsan_fd.cpp (+2-2)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl.cpp (+3-3)
  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp (+3-2)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_fd.cpp b/compiler-rt/lib/tsan/rtl/tsan_fd.cpp
index ab295a69dce17..86538bbad1138 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_fd.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_fd.cpp
@@ -180,7 +180,7 @@ void FdAcquire(ThreadState *thr, uptr pc, int fd) {
     return;
   FdDesc *d = fddesc(thr, pc, fd);
   FdSync *s = d->sync;
-  DPrintf("#%d: FdAcquire(%d) -> %p\n", thr->tid, fd, s);
+  DPrintf("#%d: FdAcquire(%d) -> %p\n", thr->tid, fd, (void *)s);
   MemoryAccess(thr, pc, (uptr)d, 8, kAccessRead);
   if (s)
     Acquire(thr, pc, (uptr)s);
@@ -191,7 +191,7 @@ void FdRelease(ThreadState *thr, uptr pc, int fd) {
     return;
   FdDesc *d = fddesc(thr, pc, fd);
   FdSync *s = d->sync;
-  DPrintf("#%d: FdRelease(%d) -> %p\n", thr->tid, fd, s);
+  DPrintf("#%d: FdRelease(%d) -> %p\n", thr->tid, fd, (void *)s);
   MemoryAccess(thr, pc, (uptr)d, 8, kAccessRead);
   if (s)
     Release(thr, pc, (uptr)s);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index 0d7247a56a4c2..3008f28ab764b 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -86,7 +86,7 @@ static TracePart* TracePartAlloc(ThreadState* thr) {
     if (trace->parts_allocated == max_parts ||
         ctx->trace_part_finished_excess) {
       part = ctx->trace_part_recycle.PopFront();
-      DPrintf("#%d: TracePartAlloc: part=%p\n", thr->tid, part);
+      DPrintf("#%d: TracePartAlloc: part=%p\n", thr->tid, (void*)part);
       if (part && part->trace) {
         Trace* trace1 = part->trace;
         Lock trace_lock(&trace1->mtx);
@@ -938,7 +938,7 @@ static bool TraceSkipGap(ThreadState* thr) {
   DCHECK_EQ(reinterpret_cast<uptr>(pos + 1) & TracePart::kAlignment, 0);
   auto *part = trace->parts.Back();
   DPrintf("#%d: TraceSwitchPart enter trace=%p parts=%p-%p pos=%p\n", thr->tid,
-          trace, trace->parts.Front(), part, pos);
+          (void*)trace, (void*)trace->parts.Front(), (void*)part, (void*)pos);
   if (!part)
     return false;
   // We can get here when we still have space in the current trace part.
@@ -1052,7 +1052,7 @@ void TraceSwitchPartImpl(ThreadState* thr) {
       ctx->trace_part_recycle.PushBack(recycle);
   }
   DPrintf("#%d: TraceSwitchPart exit parts=%p-%p pos=0x%zx\n", thr->tid,
-          trace->parts.Front(), trace->parts.Back(),
+          (void*)trace->parts.Front(), (void*)trace->parts.Back(),
           atomic_load_relaxed(&thr->trace_pos));
 }
 
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
index 43aef30d2f3b3..edfb3373ea036 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
@@ -511,7 +511,8 @@ bool RestoreStack(EventType type, Sid sid, Epoch epoch, uptr addr, uptr size,
     Lock lock(&trace->mtx);
     first_part = trace->parts.Front();
     if (!first_part) {
-      DPrintf2("RestoreStack: tid=%d trace=%p no trace parts\n", tid, trace);
+      DPrintf2("RestoreStack: tid=%d trace=%p no trace parts\n", tid,
+               (void *)trace);
       return false;
     }
     last_part = trace->parts.Back();
@@ -527,7 +528,7 @@ bool RestoreStack(EventType type, Sid sid, Epoch epoch, uptr addr, uptr size,
   bool is_atomic = typ & kAccessAtomic;
   bool is_free = typ & kAccessFree;
   DPrintf2("RestoreStack: tid=%d parts=[%p-%p] last_pos=%p\n", tid,
-           trace->parts.Front(), last_part, last_pos);
+           (void *)trace->parts.Front(), (void *)last_part, (void *)last_pos);
   TraceReplay(
       trace, last_part, last_pos, sid, epoch,
       [&](Sid ev_sid, Epoch ev_epoch, Event *evp) {

Copy link

github-actions bot commented Sep 30, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Currently there are many `warning: format specifies type 'void *'` warnings when compiling TSan with debug output.

This patch adds the `void *` casts where necessary to eliminate the warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants