[compiler-rt] 1ef0e94 - [compiler-rt] Suppress -Wunused-result due to ::write when _FORTIFY_SOURCE>0 in glibc

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 09:57:57 PDT 2020


Author: Fangrui Song
Date: 2020-10-12T09:57:12-07:00
New Revision: 1ef0e94d5b0206f69e4e822c6828d0b5121c11fb

URL: https://github.com/llvm/llvm-project/commit/1ef0e94d5b0206f69e4e822c6828d0b5121c11fb
DIFF: https://github.com/llvm/llvm-project/commit/1ef0e94d5b0206f69e4e822c6828d0b5121c11fb.diff

LOG: [compiler-rt] Suppress -Wunused-result due to ::write when _FORTIFY_SOURCE>0 in glibc

Noticed by Peter Foley.
In glibc, ::write is declared as __attribute__((__warn_unused_result__)) when __USE_FORTIFY_LEVEL is larger than 0.

Added: 
    

Modified: 
    compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
    compiler-rt/lib/scudo/standalone/linux.cpp
    compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
index 0da063a18ff7..4706a40959be 100644
--- a/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
@@ -159,7 +159,7 @@ bool IsInterestingCoverageFile(const std::string &FileName) {
 }
 
 void RawPrint(const char *Str) {
-  write(2, Str, strlen(Str));
+  (void)write(2, Str, strlen(Str));
 }
 
 void MkDir(const std::string &Path) {

diff  --git a/compiler-rt/lib/scudo/standalone/linux.cpp b/compiler-rt/lib/scudo/standalone/linux.cpp
index 69ffdd9a165b..12f3da620e12 100644
--- a/compiler-rt/lib/scudo/standalone/linux.cpp
+++ b/compiler-rt/lib/scudo/standalone/linux.cpp
@@ -198,7 +198,7 @@ void outputRaw(const char *Buffer) {
     }
     async_safe_write_log(AndroidLogInfo, "scudo", Buffer);
   } else {
-    write(2, Buffer, strlen(Buffer));
+    (void)write(2, Buffer, strlen(Buffer));
   }
 }
 

diff  --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index 8654c705cfbb..6a1903da62ce 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -10,7 +10,7 @@ extern "C" void ubsan_message(const char *msg);
 static void message(const char *msg) { ubsan_message(msg); }
 #else
 static void message(const char *msg) {
-  write(2, msg, strlen(msg));
+  (void)write(2, msg, strlen(msg));
 }
 #endif
 


        


More information about the llvm-commits mailing list