[llvm] r308483 - Defeat a GCC -Wunused-result warning
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 08:03:38 PDT 2017
Author: hans
Date: Wed Jul 19 08:03:38 2017
New Revision: 308483
URL: http://llvm.org/viewvc/llvm-project?rev=308483&view=rev
Log:
Defeat a GCC -Wunused-result warning
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.
Modified:
llvm/trunk/lib/Support/ErrorHandling.cpp
Modified: llvm/trunk/lib/Support/ErrorHandling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=308483&r1=308482&r2=308483&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ErrorHandling.cpp (original)
+++ llvm/trunk/lib/Support/ErrorHandling.cpp Wed Jul 19 08:03:38 2017
@@ -169,7 +169,8 @@ void llvm::report_bad_alloc_error(const
// 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
}
More information about the llvm-commits
mailing list