[PATCH] D27281: [libFuzzer] Diff 9 - 1 - Properly use unsigned for Process ID.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 13:07:55 PST 2016


mpividori updated this revision to Diff 81129.
mpividori added a comment.

@kcc Ok. I updated the diff and Revision title to include the changes related to the Process ID.


Repository:
  rL LLVM

https://reviews.llvm.org/D27281

Files:
  lib/Fuzzer/FuzzerLoop.cpp
  lib/Fuzzer/FuzzerUtil.h
  lib/Fuzzer/FuzzerUtilPosix.cpp
  lib/Fuzzer/FuzzerUtilWindows.cpp


Index: lib/Fuzzer/FuzzerUtilWindows.cpp
===================================================================
--- lib/Fuzzer/FuzzerUtilWindows.cpp
+++ lib/Fuzzer/FuzzerUtilWindows.cpp
@@ -144,7 +144,7 @@
   Sleep(Seconds * 1000);
 }
 
-int GetPid() { return GetCurrentProcessId(); }
+unsigned long GetPid() { return GetCurrentProcessId(); }
 
 size_t GetPeakRSSMb() {
   PROCESS_MEMORY_COUNTERS info;
Index: lib/Fuzzer/FuzzerUtilPosix.cpp
===================================================================
--- lib/Fuzzer/FuzzerUtilPosix.cpp
+++ lib/Fuzzer/FuzzerUtilPosix.cpp
@@ -85,7 +85,7 @@
   sleep(Seconds);  // Use C API to avoid coverage from instrumented libc++.
 }
 
-int GetPid() { return getpid(); }
+unsigned long GetPid() { return (unsigned long)getpid(); }
 
 size_t GetPeakRSSMb() {
   struct rusage usage;
Index: lib/Fuzzer/FuzzerUtil.h
===================================================================
--- lib/Fuzzer/FuzzerUtil.h
+++ lib/Fuzzer/FuzzerUtil.h
@@ -47,7 +47,7 @@
 
 void SleepSeconds(int Seconds);
 
-int GetPid();
+unsigned long GetPid();
 
 size_t GetPeakRSSMb();
 
Index: lib/Fuzzer/FuzzerLoop.cpp
===================================================================
--- lib/Fuzzer/FuzzerLoop.cpp
+++ lib/Fuzzer/FuzzerLoop.cpp
@@ -263,7 +263,7 @@
 }
 
 void Fuzzer::CrashCallback() {
-  Printf("==%d== ERROR: libFuzzer: deadly signal\n", GetPid());
+  Printf("==%lu== ERROR: libFuzzer: deadly signal\n", GetPid());
   if (EF->__sanitizer_print_stack_trace)
     EF->__sanitizer_print_stack_trace();
   Printf("NOTE: libFuzzer has rudimentary signal handlers.\n"
@@ -276,7 +276,7 @@
 }
 
 void Fuzzer::InterruptCallback() {
-  Printf("==%d== libFuzzer: run interrupted; exiting\n", GetPid());
+  Printf("==%lu== libFuzzer: run interrupted; exiting\n", GetPid());
   PrintFinalStats();
   _Exit(0);  // Stop right now, don't perform any at-exit actions.
 }
@@ -298,7 +298,7 @@
     Printf("       and the timeout value is %d (use -timeout=N to change)\n",
            Options.UnitTimeoutSec);
     DumpCurrentUnit("timeout-");
-    Printf("==%d== ERROR: libFuzzer: timeout after %d seconds\n", GetPid(),
+    Printf("==%lu== ERROR: libFuzzer: timeout after %d seconds\n", GetPid(),
            Seconds);
     if (EF->__sanitizer_print_stack_trace)
       EF->__sanitizer_print_stack_trace();
@@ -310,7 +310,7 @@
 
 void Fuzzer::RssLimitCallback() {
   Printf(
-      "==%d== ERROR: libFuzzer: out-of-memory (used: %zdMb; limit: %zdMb)\n",
+      "==%lu== ERROR: libFuzzer: out-of-memory (used: %zdMb; limit: %zdMb)\n",
       GetPid(), GetPeakRSSMb(), Options.RssLimitMb);
   Printf("   To change the out-of-memory limit use -rss_limit_mb=<N>\n\n");
   if (EF->__sanitizer_print_memory_profile)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27281.81129.patch
Type: text/x-patch
Size: 2726 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161212/89c62d6b/attachment.bin>


More information about the llvm-commits mailing list