From db3d5211c6552d2863a4936ac79b0495543f0f92 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 19 Jul 2017 15:03:38 +0000 Subject: [PATCH] Defeat a GCC -Wunused-result warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It was warning like: ../llvm-project/llvm/lib/Support/ErrorHandling.cpp:172:51: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result] (void)::write(2, OOMMessage, strlen(OOMMessage)); Work around the warning by storing the return value in a variable and casting that to void instead. We already did this for the other write() call in this file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308483 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/ErrorHandling.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Support/ErrorHandling.cpp b/lib/Support/ErrorHandling.cpp index 2fd4f3ea0d4..fb8ae4c1cd5 100644 --- a/lib/Support/ErrorHandling.cpp +++ b/lib/Support/ErrorHandling.cpp @@ -169,7 +169,8 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) { // Don't call the normal error handler. It may allocate memory. Directly write // an OOM to stderr and abort. char OOMMessage[] = "LLVM ERROR: out of memory\n"; - (void)::write(2, OOMMessage, strlen(OOMMessage)); + ssize_t written = ::write(2, OOMMessage, strlen(OOMMessage)); + (void)written; abort(); #endif } -- 2.50.1