summaryrefslogtreecommitdiffstats
path: root/tools/fuzzing/libfuzzer/patches/13-unused-write.patch
blob: f8ef7a5ac96e65edd05716c7874a1cc71a517cd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# HG changeset patch
# User Christian Holler <choller@mozilla.com>
# Date 1596126946 -7200
#      Thu Jul 30 18:35:46 2020 +0200
# Node ID 6c779ec81530b6784a714063af66085681ab7318
# Parent  64e7d096fa77a62b71a306b2c5383b8f75ac4945
[libFuzzer] Suppress warnings about unused return values

diff --git a/tools/fuzzing/libfuzzer/FuzzerIO.cpp b/tools/fuzzing/libfuzzer/FuzzerIO.cpp
--- a/tools/fuzzing/libfuzzer/FuzzerIO.cpp
+++ b/tools/fuzzing/libfuzzer/FuzzerIO.cpp
@@ -3,16 +3,17 @@
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 // IO functions.
 //===----------------------------------------------------------------------===//
 
+#include "mozilla/Unused.h"
 #include "FuzzerDefs.h"
 #include "FuzzerExtFunctions.h"
 #include "FuzzerIO.h"
 #include "FuzzerUtil.h"
 #include <algorithm>
 #include <cstdarg>
 #include <fstream>
 #include <iterator>
@@ -68,17 +69,17 @@ void WriteToFile(const std::string &Data
   WriteToFile(reinterpret_cast<const uint8_t *>(Data.c_str()), Data.size(),
               Path);
 }
 
 void WriteToFile(const uint8_t *Data, size_t Size, const std::string &Path) {
   // Use raw C interface because this function may be called from a sig handler.
   FILE *Out = fopen(Path.c_str(), "wb");
   if (!Out) return;
-  fwrite(Data, sizeof(Data[0]), Size, Out);
+  mozilla::Unused << fwrite(Data, sizeof(Data[0]), Size, Out);
   fclose(Out);
 }
 
 void ReadDirToVectorOfUnits(const char *Path, Vector<Unit> *V,
                             long *Epoch, size_t MaxSize, bool ExitOnError) {
   long E = Epoch ? *Epoch : 0;
   Vector<std::string> Files;
   ListFilesInDirRecursive(Path, Epoch, &Files, /*TopDir*/true);
diff --git a/tools/fuzzing/libfuzzer/FuzzerIOPosix.cpp b/tools/fuzzing/libfuzzer/FuzzerIOPosix.cpp
--- a/tools/fuzzing/libfuzzer/FuzzerIOPosix.cpp
+++ b/tools/fuzzing/libfuzzer/FuzzerIOPosix.cpp
@@ -2,16 +2,17 @@
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 // IO functions implementation using Posix API.
 //===----------------------------------------------------------------------===//
+#include "mozilla/Unused.h"
 #include "FuzzerPlatform.h"
 #if LIBFUZZER_POSIX || LIBFUZZER_FUCHSIA
 
 #include "FuzzerExtFunctions.h"
 #include "FuzzerIO.h"
 #include <cstdarg>
 #include <cstdio>
 #include <dirent.h>
@@ -150,17 +151,17 @@ bool IsInterestingCoverageFile(const std
   if (FileName.find("/usr/include/") != std::string::npos)
     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));
 }
 
 void MkDir(const std::string &Path) {
   mkdir(Path.c_str(), 0700);
 }
 
 void RmDir(const std::string &Path) {
   rmdir(Path.c_str());