diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2016-03-02 09:54:40 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2016-03-02 09:54:40 +0000 |
commit | 2eed1218e501354956fe60a060ea0cfe0b3aead0 (patch) | |
tree | 112ad44cee474b610b5084e07139eab46fdaab6b /llvm/lib/Fuzzer/FuzzerUtil.cpp | |
parent | d15c95a793d9cea39c9f6d36aaf02e9106e7b200 (diff) | |
download | bcm5719-llvm-2eed1218e501354956fe60a060ea0cfe0b3aead0.tar.gz bcm5719-llvm-2eed1218e501354956fe60a060ea0cfe0b3aead0.zip |
libfuzzer: fix compiler warnings
- unused sigaction/setitimer result (used in assert)
- unchecked fscanf return value
- signed/unsigned comparison
llvm-svn: 262472
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerUtil.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerUtil.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerUtil.cpp b/llvm/lib/Fuzzer/FuzzerUtil.cpp index 9364955b305..84c4983f991 100644 --- a/llvm/lib/Fuzzer/FuzzerUtil.cpp +++ b/llvm/lib/Fuzzer/FuzzerUtil.cpp @@ -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(SIGINT, InterruptHandler); } 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; } |