[llvm] r262472 - libfuzzer: fix compiler warnings
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 2 13:14:02 PST 2016
Thanks for the fix.
By default we don't use -Werror when building clang and the libFuzzer
configuration used on bots includes asserts -- so we did not see these.
Added -Werror in r262517.
On Wed, Mar 2, 2016 at 1:54 AM, Dmitry Vyukov via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> 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;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160302/59c3d3a8/attachment.html>
More information about the llvm-commits
mailing list