Debian Codegraph @

tools/fuzzing/libfuzzer/patches/13-unused-write.patch

raw
1 # HG changeset patch
2 # User Christian Holler <[email protected]>
3 # Date 1596126946 -7200
4 # Thu Jul 30 18:35:46 2020 +0200
5 # Node ID 6c779ec81530b6784a714063af66085681ab7318
6 # Parent 64e7d096fa77a62b71a306b2c5383b8f75ac4945
7 [libFuzzer] Suppress warnings about unused return values
8
9 diff --git a/FuzzerIO.cpp b/FuzzerIO.cpp
10 --- a/FuzzerIO.cpp
11 +++ b/FuzzerIO.cpp
12 @@ -3,16 +3,17 @@
13 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
14 // See https://llvm.org/LICENSE.txt for license information.
15 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16 //
17 //===----------------------------------------------------------------------===//
18 // IO functions.
19 //===----------------------------------------------------------------------===//
20
21 +#include "mozilla/Unused.h"
22 #include "FuzzerDefs.h"
23 #include "FuzzerExtFunctions.h"
24 #include "FuzzerIO.h"
25 #include "FuzzerUtil.h"
26 #include <algorithm>
27 #include <cstdarg>
28 #include <fstream>
29 #include <iterator>
30 @@ -68,17 +69,17 @@ void WriteToFile(const std::string &Data
31 WriteToFile(reinterpret_cast<const uint8_t *>(Data.c_str()), Data.size(),
32 Path);
33 }
34
35 void WriteToFile(const uint8_t *Data, size_t Size, const std::string &Path) {
36 // Use raw C interface because this function may be called from a sig handler.
37 FILE *Out = fopen(Path.c_str(), "wb");
38 if (!Out) return;
39 - fwrite(Data, sizeof(Data[0]), Size, Out);
40 + mozilla::Unused << fwrite(Data, sizeof(Data[0]), Size, Out);
41 fclose(Out);
42 }
43
44 void ReadDirToVectorOfUnits(const char *Path, Vector<Unit> *V,
45 long *Epoch, size_t MaxSize, bool ExitOnError) {
46 long E = Epoch ? *Epoch : 0;
47 Vector<std::string> Files;
48 ListFilesInDirRecursive(Path, Epoch, &Files, /*TopDir*/true);
49 diff --git a/FuzzerIOPosix.cpp b/FuzzerIOPosix.cpp
50 --- a/FuzzerIOPosix.cpp
51 +++ b/FuzzerIOPosix.cpp
52 @@ -2,16 +2,17 @@
53 //
54 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
55 // See https://llvm.org/LICENSE.txt for license information.
56 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
57 //
58 //===----------------------------------------------------------------------===//
59 // IO functions implementation using Posix API.
60 //===----------------------------------------------------------------------===//
61 +#include "mozilla/Unused.h"
62 #include "FuzzerPlatform.h"
63 #if LIBFUZZER_POSIX || LIBFUZZER_FUCHSIA
64
65 #include "FuzzerExtFunctions.h"
66 #include "FuzzerIO.h"
67 #include <cstdarg>
68 #include <cstdio>
69 #include <dirent.h>
70 @@ -150,17 +151,17 @@ bool IsInterestingCoverageFile(const std
71 if (FileName.find("/usr/include/") != std::string::npos)
72 return false;
73 if (FileName == "<null>")
74 return false;
75 return true;
76 }
77
78 void RawPrint(const char *Str) {
79 - write(2, Str, strlen(Str));
80 + mozilla::Unused << write(2, Str, strlen(Str));
81 }
82
83 void MkDir(const std::string &Path) {
84 mkdir(Path.c_str(), 0700);
85 }
86
87 void RmDir(const std::string &Path) {
88 rmdir(Path.c_str());