Skip to content

Conversation

ampandey-1995
Copy link
Contributor

This pull request addresses fixes against violations happening under subcategory 'cpp/wrong-type-format-argument' related to dfsan,fuzzer,hwasan.

@llvmbot
Copy link
Member

llvmbot commented Sep 10, 2025

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

Author: Amit Kumar Pandey (ampandey-1995)

Changes

This pull request addresses fixes against violations happening under subcategory 'cpp/wrong-type-format-argument' related to dfsan,fuzzer,hwasan.


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

5 Files Affected:

  • (modified) compiler-rt/lib/dfsan/dfsan.cpp (+3-3)
  • (modified) compiler-rt/lib/fuzzer/FuzzerCorpus.h (+1-1)
  • (modified) compiler-rt/lib/fuzzer/FuzzerDriver.cpp (+2-2)
  • (modified) compiler-rt/lib/fuzzer/FuzzerLoop.cpp (+2-2)
  • (modified) compiler-rt/lib/hwasan/hwasan_report.cpp (+4-4)
diff --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp
index d09a9a70fd83b..a49e999f702a4 100644
--- a/compiler-rt/lib/dfsan/dfsan.cpp
+++ b/compiler-rt/lib/dfsan/dfsan.cpp
@@ -1128,7 +1128,7 @@ static bool CheckMemoryRangeAvailability(uptr beg, uptr size, bool verbose) {
     uptr end = beg + size - 1;
     if (!MemoryRangeIsAvailable(beg, end)) {
       if (verbose)
-        Printf("FATAL: Memory range %p - %p is not available.\n", beg, end);
+        Printf("FATAL: Memory range %p - %p is not available.\n", (void *)beg, (void *)end);
       return false;
     }
   }
@@ -1150,7 +1150,7 @@ static bool ProtectMemoryRange(uptr beg, uptr size, const char *name) {
     }
     if ((uptr)addr != beg) {
       uptr end = beg + size - 1;
-      Printf("FATAL: Cannot protect memory range %p - %p (%s).\n", beg, end,
+      Printf("FATAL: Cannot protect memory range %p - %p (%s).\n", (void *)beg, (void *)end,
              name);
       return false;
     }
@@ -1172,7 +1172,7 @@ static bool InitShadow(bool init_origins, bool dry_run) {
   if (!MEM_IS_APP(&__dfsan::dfsan_init)) {
     if (!dry_run)
       Printf("FATAL: Code %p is out of application range. Non-PIE build?\n",
-             (uptr)&__dfsan::dfsan_init);
+             (void *)&__dfsan::dfsan_init);
     return false;
   }
 
diff --git a/compiler-rt/lib/fuzzer/FuzzerCorpus.h b/compiler-rt/lib/fuzzer/FuzzerCorpus.h
index 48b5a2cff02e2..87948c1b023d6 100644
--- a/compiler-rt/lib/fuzzer/FuzzerCorpus.h
+++ b/compiler-rt/lib/fuzzer/FuzzerCorpus.h
@@ -336,7 +336,7 @@ class InputCorpus {
   void PrintFeatureSet() {
     for (size_t i = 0; i < kFeatureSetSize; i++) {
       if(size_t Sz = GetFeature(i))
-        Printf("[%zd: id %zd sz%zd] ", i, SmallestElementPerFeature[i], Sz);
+        Printf("[%zd: id %zd sz%zd] ", i, (size_t)SmallestElementPerFeature[i], Sz);
     }
     Printf("\n\t");
     for (size_t i = 0; i < Inputs.size(); i++)
diff --git a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
index af9c260537e2f..32b7eca84e9c3 100644
--- a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -163,13 +163,13 @@ static bool ParseOneFlag(const char *Param) {
         auto Val = MyStol(Str);
         *FlagDescriptions[F].IntFlag = static_cast<int>(Val);
         if (Flags.verbosity >= 2)
-          Printf("Flag: %s %d\n", Name, Val);
+          Printf("Flag: %s %d\n", Name, (int)Val);
         return true;
       } else if (FlagDescriptions[F].UIntFlag) {
         auto Val = std::stoul(Str);
         *FlagDescriptions[F].UIntFlag = static_cast<unsigned int>(Val);
         if (Flags.verbosity >= 2)
-          Printf("Flag: %s %u\n", Name, Val);
+          Printf("Flag: %s %u\n", Name, (uint)Val);
         return true;
       } else if (FlagDescriptions[F].StrFlag) {
         *FlagDescriptions[F].StrFlag = Str;
diff --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
index 6f415dd5763ac..4a44988112960 100644
--- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
@@ -125,7 +125,7 @@ void FreeHook(const volatile void *ptr) {
 void Fuzzer::HandleMalloc(size_t Size) {
   if (!Options.MallocLimitMb || (Size >> 20) < (size_t)Options.MallocLimitMb)
     return;
-  Printf("==%d== ERROR: libFuzzer: out-of-memory (malloc(%zd))\n", GetPid(),
+  Printf("==%d== ERROR: libFuzzer: out-of-memory (malloc(%zd))\n", (int)GetPid(),
          Size);
   Printf("   To change the out-of-memory limit use -rss_limit_mb=<N>\n\n");
   PrintStackTrace();
@@ -568,7 +568,7 @@ size_t Fuzzer::GetCurrentUnitInFuzzingThead(const uint8_t **Data) const {
 
 void Fuzzer::CrashOnOverwrittenData() {
   Printf("==%d== ERROR: libFuzzer: fuzz target overwrites its const input\n",
-         GetPid());
+         (int)GetPid());
   PrintStackTrace();
   Printf("SUMMARY: libFuzzer: overwrites-const-input\n");
   DumpCurrentUnit("crash-");
diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index 6eafcf9163afa..ce5d253dfd6f1 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -738,7 +738,7 @@ void BaseReport::PrintHeapOrGlobalCandidate() const {
     Printf("%s", d.Default());
     Printf("%s", d.Location());
     Printf("%p is located %zd bytes %s a %zd-byte region [%p,%p)\n",
-           untagged_addr, offset, whence,
+           (void *)untagged_addr, offset, whence,
            candidate.heap.end - candidate.heap.begin,
            (void *)candidate.heap.begin, (void *)candidate.heap.end);
     Printf("%s", d.Allocation());
@@ -776,13 +776,13 @@ void BaseReport::PrintHeapOrGlobalCandidate() const {
             "%p is located %s a global variable in "
             "\n    #0 0x%x (%s+0x%x)\n",
             (void *)untagged_addr, candidate.after ? "after" : "before",
-            (void *)candidate.untagged_addr, module_name, (u32)module_address);
+            (u32)candidate.untagged_addr, module_name, (u32)module_address);
       else
         Printf(
             "%p is located %s a %zd-byte global variable in "
             "\n    #0 0x%x (%s+0x%x)\n",
             (void *)untagged_addr, candidate.after ? "after" : "before", size,
-            (void *)candidate.untagged_addr, module_name, (u32)module_address);
+            (u32)candidate.untagged_addr, module_name, (u32)module_address);
     }
     Printf("%s", d.Default());
   }
@@ -844,7 +844,7 @@ void BaseReport::PrintAddressDescription() const {
     Printf("%s", d.Location());
     Printf("%p is located %zd bytes inside a %zd-byte region [%p,%p)\n",
            (void *)untagged_addr, untagged_addr - UntagAddr(har.tagged_addr),
-           (ssize)har.requested_size, UntagAddr(har.tagged_addr),
+           (ssize)har.requested_size, (void *)UntagAddr(har.tagged_addr),
            (void *)(UntagAddr(har.tagged_addr) + har.requested_size));
     Printf("%s", d.Allocation());
     Printf("freed by thread T%u here:\n", ha.free_thread_id);

Copy link

github-actions bot commented Sep 10, 2025

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

This pull request addresses fixes against violations happening under
subcategory 'cpp/wrong-type-format-argument' related to
dfsan,fuzzer,hwasan.
@ampandey-1995
Copy link
Contributor Author

Thanks @thurstond for the review & approval.

@ampandey-1995 ampandey-1995 merged commit b44e6e0 into llvm:main Sep 10, 2025
9 checks passed
@andjo403
Copy link
Contributor

I think this PR is the reason for the failure in https://lab.llvm.org/buildbot/#/builders/11/builds/23679

@ampandey-1995
Copy link
Contributor Author

ampandey-1995 commented Sep 10, 2025

Hi @andjo403 or @thurstond ,

Can you please revert this PR I am having some techincal issues with the internet.

Thanks

ampandey-1995 added a commit that referenced this pull request Sep 10, 2025
ampandey-1995 added a commit to ampandey-1995/llvm-project that referenced this pull request Sep 10, 2025
ampandey-1995 added a commit that referenced this pull request Sep 10, 2025
@ampandey-1995
Copy link
Contributor Author

Hi @andjo403 or @thurstond ,

Can you please revert this PR I am having some techincal issues with the internet.

Thanks

Reverted the PR ampandey-1995@c312795 . Will investigate failure in detail. Currently just reverting the PR.

ampandey-1995 added a commit to ampandey-1995/llvm-project that referenced this pull request Sep 16, 2025
…lvm#157913)

Fix below buildbot failure.

```
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:172:42: error: use of undeclared identifier 'uint'
  172 |           Printf("Flag: %s %u\n", Name, (uint)Val);
```

Replace uint with uint32_t cast.

This reverts commit 8062b16.
thurstond pushed a commit that referenced this pull request Sep 16, 2025
) (#159097)

Fix below buildbot failure.

```
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:172:42: error: use of undeclared identifier 'uint'
  172 |           Printf("Flag: %s %u\n", Name, (uint)Val);
```

Replace uint with uint32_t cast.

This reverts commit 8062b16.
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.

4 participants