[llvm] r262472 - libfuzzer: fix compiler warnings
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 2 01:54:41 PST 2016
Author: dvyukov
Date: Wed Mar 2 03:54:40 2016
New Revision: 262472
URL: http://llvm.org/viewvc/llvm-project?rev=262472&view=rev
Log:
libfuzzer: fix compiler warnings
- unused sigaction/setitimer result (used in assert)
- unchecked fscanf return value
- signed/unsigned comparison
Modified:
llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp
llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp
Modified: llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp?rev=262472&r1=262471&r2=262472&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp Wed Mar 2 03:54:40 2016
@@ -319,7 +319,7 @@ void TraceState::DFSanCmpCallback(uintpt
AddMutation(Pos, CmpSize, Data - 1);
}
- if (CmpSize > LR.End - LR.Beg)
+ if (CmpSize > (size_t)(LR.End - LR.Beg))
AddMutation(LR.Beg, (unsigned)(LR.End - LR.Beg), Data);
Modified: llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp?rev=262472&r1=262471&r2=262472&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerUtil.cpp Wed Mar 2 03:54:40 2016
@@ -19,6 +19,7 @@
#include <signal.h>
#include <sstream>
#include <unistd.h>
+#include <errno.h>
namespace fuzzer {
@@ -84,14 +85,18 @@ static void SetSigaction(int signum,
struct sigaction sigact;
memset(&sigact, 0, sizeof(sigact));
sigact.sa_sigaction = callback;
- int Res = sigaction(signum, &sigact, 0);
- assert(Res == 0);
+ if (sigaction(signum, &sigact, 0)) {
+ Printf("libFuzzer: sigaction failed with %d\n", errno);
+ exit(1);
+ }
}
void SetTimer(int Seconds) {
struct itimerval T {{Seconds, 0}, {Seconds, 0}};
- int Res = setitimer(ITIMER_REAL, &T, nullptr);
- assert(Res == 0);
+ if (setitimer(ITIMER_REAL, &T, nullptr)) {
+ Printf("libFuzzer: setitimer failed with %d\n", errno);
+ exit(1);
+ }
SetSigaction(SIGALRM, AlarmHandler);
}
@@ -105,7 +110,8 @@ void SetSigIntHandler() { SetSigaction(S
int NumberOfCpuCores() {
FILE *F = popen("nproc", "r");
int N = 0;
- fscanf(F, "%d", &N);
+ if (fscanf(F, "%d", &N) != 1)
+ N = 1;
fclose(F);
return N;
}
More information about the llvm-commits
mailing list