From 1ef0e94d5b0206f69e4e822c6828d0b5121c11fb Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 12 Oct 2020 09:57:12 -0700 Subject: [PATCH] [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. --- compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp | 2 +- compiler-rt/lib/scudo/standalone/linux.cpp | 2 +- compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp index 0da063a18ff7d..4706a40959be8 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 69ffdd9a165ba..12f3da620e123 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 8654c705cfbb0..6a1903da62ce7 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