Silence warn_unused_result warning on write() call
Frustratingly, simply writing the standard (void)write(...) does not
work because GCC is broken and intentionally leaves the warning enabled
there. This does not comply with the now standard semantics for
nodiscard.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
Instead, what seems to work is to assign it to a variable and then
(void) the variable.
Fixed: 644
Change-Id: Ic418b4185aeae1a9ca424c45a05af063e8d50255
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/62666
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/test/abi_test.cc b/crypto/test/abi_test.cc
index 3e5043d..536be3c 100644
--- a/crypto/test/abi_test.cc
+++ b/crypto/test/abi_test.cc
@@ -208,7 +208,10 @@
WriteFile(stderr_handle, buf, strlen(buf), &unused, nullptr);
}
#else
- write(STDERR_FILENO, buf, strlen(buf));
+ ssize_t ret = write(STDERR_FILENO, buf, strlen(buf));
+ // We'll abort soon anyway, so if we fail to write the message, there's
+ // nothing to do.
+ (void)ret;
#endif
abort();
}