Bug 1414394 Mark write()'s in libfuzzer as Unused to silence a warning r=njn
authorTom Ritter <tom@mozilla.com>
Fri, 03 Nov 2017 23:17:27 -0500
changeset 693808 a0712da71d64d75d0db129abe481e93a5df13e70
parent 693807 f8903937a76ea6e614ac2624838e1cb8ec0625f6
child 693809 62aeebcc676e93dc56a97d44753f4e2f963d43c3
push id87924
push userbmo:mozilla@hocat.ca
push dateMon, 06 Nov 2017 22:10:10 +0000
reviewersnjn
bugs1414394
milestone58.0a1
Bug 1414394 Mark write()'s in libfuzzer as Unused to silence a warning r=njn MozReview-Commit-ID: GbWTgrndfoa
tools/fuzzing/libfuzzer/FuzzerIO.cpp
tools/fuzzing/libfuzzer/FuzzerIOPosix.cpp
--- a/tools/fuzzing/libfuzzer/FuzzerIO.cpp
+++ b/tools/fuzzing/libfuzzer/FuzzerIO.cpp
@@ -4,16 +4,17 @@
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 // IO functions.
 //===----------------------------------------------------------------------===//
 
+#include "mozilla/Unused.h"
 #include "FuzzerIO.h"
 #include "FuzzerDefs.h"
 #include "FuzzerExtFunctions.h"
 #include <algorithm>
 #include <cstdarg>
 #include <fstream>
 #include <iterator>
 #include <sys/stat.h>
@@ -57,17 +58,17 @@ std::string FileToString(const std::stri
 void CopyFileToErr(const std::string &Path) {
   Printf("%s", FileToString(Path).c_str());
 }
 
 void WriteToFile(const Unit &U, const std::string &Path) {
   // Use raw C interface because this function may be called from a sig handler.
   FILE *Out = fopen(Path.c_str(), "w");
   if (!Out) return;
-  fwrite(U.data(), sizeof(U[0]), U.size(), Out);
+  mozilla::Unused << fwrite(U.data(), sizeof(U[0]), U.size(), Out);
   fclose(Out);
 }
 
 void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit> *V,
                             long *Epoch, size_t MaxSize, bool ExitOnError) {
   long E = Epoch ? *Epoch : 0;
   std::vector<std::string> Files;
   ListFilesInDirRecursive(Path, Epoch, &Files, /*TopDir*/true);
--- a/tools/fuzzing/libfuzzer/FuzzerIOPosix.cpp
+++ b/tools/fuzzing/libfuzzer/FuzzerIOPosix.cpp
@@ -6,16 +6,17 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 // IO functions implementation using Posix API.
 //===----------------------------------------------------------------------===//
 #include "FuzzerDefs.h"
 #if LIBFUZZER_POSIX
 
+#include "mozilla/Unused.h"
 #include "FuzzerExtFunctions.h"
 #include "FuzzerIO.h"
 #include <cstdarg>
 #include <cstdio>
 #include <dirent.h>
 #include <fstream>
 #include <iterator>
 #include <libgen.h>
@@ -110,14 +111,14 @@ bool IsInterestingCoverageFile(const std
     return false;
   if (FileName == "<null>")
     return false;
   return true;
 }
 
 
 void RawPrint(const char *Str) {
-  write(2, Str, strlen(Str));
+  mozilla::Unused << write(2, Str, strlen(Str));
 }
 
 }  // namespace fuzzer
 
 #endif // LIBFUZZER_POSIX