Index: lib/Fuzzer/FuzzerDriver.cpp =================================================================== --- lib/Fuzzer/FuzzerDriver.cpp +++ lib/Fuzzer/FuzzerDriver.cpp @@ -200,10 +200,10 @@ } } -static void WorkerThread(const std::string &Cmd, std::atomic *Counter, - int NumJobs, std::atomic *HasErrors) { +static void WorkerThread(const std::string &Cmd, std::atomic *Counter, + unsigned NumJobs, std::atomic *HasErrors) { while (true) { - int C = (*Counter)++; + unsigned C = (*Counter)++; if (C >= NumJobs) break; std::string Log = "fuzz-" + std::to_string(C) + ".log"; std::string ToRun = Cmd + " > " + Log + " 2>&1\n"; @@ -213,7 +213,7 @@ if (ExitCode != 0) *HasErrors = true; std::lock_guard Lock(Mu); - Printf("================== Job %d exited with exit code %d ============\n", + Printf("================== Job %u exited with exit code %d ============\n", C, ExitCode); fuzzer::CopyFileToErr(Log); } @@ -236,14 +236,14 @@ } static int RunInMultipleProcesses(const std::vector &Args, - int NumWorkers, int NumJobs) { - std::atomic Counter(0); + unsigned NumWorkers, unsigned NumJobs) { + std::atomic Counter(0); std::atomic HasErrors(false); std::string Cmd = CloneArgsWithoutX(Args, "jobs", "workers"); std::vector V; std::thread Pulse(PulseThread); Pulse.detach(); - for (int i = 0; i < NumWorkers; i++) + for (unsigned i = 0; i < NumWorkers; i++) V.push_back(std::thread(WorkerThread, Cmd, &Counter, NumJobs, &HasErrors)); for (auto &T : V) T.join(); @@ -378,7 +378,7 @@ if (Flags.jobs > 0 && Flags.workers == 0) { Flags.workers = std::min(NumberOfCpuCores() / 2, Flags.jobs); if (Flags.workers > 1) - Printf("Running %d workers\n", Flags.workers); + Printf("Running %u workers\n", Flags.workers); } if (Flags.workers > 0 && Flags.jobs > 0) Index: lib/Fuzzer/FuzzerFlags.def =================================================================== --- lib/Fuzzer/FuzzerFlags.def +++ lib/Fuzzer/FuzzerFlags.def @@ -51,10 +51,10 @@ "Experimental. Use value profile to guide fuzzing.") FUZZER_FLAG_INT(use_cmp, 1, "Use CMP traces to guide mutations") FUZZER_FLAG_INT(shrink, 0, "Experimental. Try to shrink corpus elements.") -FUZZER_FLAG_INT(jobs, 0, "Number of jobs to run. If jobs >= 1 we spawn" +FUZZER_FLAG_UNSIGNED(jobs, 0, "Number of jobs to run. If jobs >= 1 we spawn" " this number of jobs in separate worker processes" " with stdout/stderr redirected to fuzz-JOB.log.") -FUZZER_FLAG_INT(workers, 0, +FUZZER_FLAG_UNSIGNED(workers, 0, "Number of simultaneous worker processes to run the jobs." " If zero, \"min(jobs,NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload, 1, Index: lib/Fuzzer/FuzzerLoop.cpp =================================================================== --- lib/Fuzzer/FuzzerLoop.cpp +++ lib/Fuzzer/FuzzerLoop.cpp @@ -247,7 +247,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" @@ -262,7 +262,7 @@ } void Fuzzer::InterruptCallback() { - Printf("==%d== libFuzzer: run interrupted; exiting\n", GetPid()); + Printf("==%lu== libFuzzer: run interrupted; exiting\n", GetPid()); std::lock_guard Lock(RunningCBMtx); if (RunningCB) // The fuzzer is in a consistent state. PrintFinalStats(); @@ -286,7 +286,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(); @@ -298,7 +298,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"); if (EF->__sanitizer_print_memory_profile) Index: lib/Fuzzer/FuzzerUtil.h =================================================================== --- lib/Fuzzer/FuzzerUtil.h +++ lib/Fuzzer/FuzzerUtil.h @@ -38,7 +38,7 @@ std::string DescribePC(const char *SymbolizedFMT, uintptr_t PC); -int NumberOfCpuCores(); +unsigned NumberOfCpuCores(); // Platform specific functions. struct SignalHandlerOptions { @@ -58,7 +58,7 @@ void SleepSeconds(int Seconds); -int GetPid(); +unsigned long GetPid(); size_t GetPeakRSSMb(); Index: lib/Fuzzer/FuzzerUtil.cpp =================================================================== --- lib/Fuzzer/FuzzerUtil.cpp +++ lib/Fuzzer/FuzzerUtil.cpp @@ -195,7 +195,7 @@ Printf(FallbackFMT, PC); } -int NumberOfCpuCores() { +unsigned NumberOfCpuCores() { unsigned N = std::thread::hardware_concurrency(); if (!N) { Printf("WARNING: std::thread::hardware_concurrency not well defined for " Index: lib/Fuzzer/FuzzerUtilPosix.cpp =================================================================== --- lib/Fuzzer/FuzzerUtilPosix.cpp +++ lib/Fuzzer/FuzzerUtilPosix.cpp @@ -109,7 +109,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/FuzzerUtilWindows.cpp =================================================================== --- lib/Fuzzer/FuzzerUtilWindows.cpp +++ lib/Fuzzer/FuzzerUtilWindows.cpp @@ -139,7 +139,7 @@ Sleep(Seconds * 1000); } -int GetPid() { return GetCurrentProcessId(); } +unsigned long GetPid() { return GetCurrentProcessId(); } size_t GetPeakRSSMb() { PROCESS_MEMORY_COUNTERS info;