Merge "Consistently use `#if defined(__BIONIC__)`." into main
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 29aba60..12ea21b 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -412,9 +412,6 @@
   ASSERT_FORTIFY(sprintf(buf, "%s", source_buf));
 }
 
-#if !__has_attribute(alloc_size)
-// TODO: remove this after Clang prebuilt rebase.
-#else
 TEST_F(DEATHTEST, sprintf_malloc_fortified) {
   char* buf = (char *) malloc(10);
   char source_buf[11];
@@ -422,7 +419,6 @@
   ASSERT_FORTIFY(sprintf(buf, "%s", source_buf));
   free(buf);
 }
-#endif
 
 TEST_F(DEATHTEST, sprintf2_fortified) {
   char buf[5];
diff --git a/tests/utils.cpp b/tests/utils.cpp
index e470724..0c7c552 100644
--- a/tests/utils.cpp
+++ b/tests/utils.cpp
@@ -28,7 +28,9 @@
 
 #include "utils.h"
 
+#include <string.h>
 #include <syscall.h>
+
 #include <string>
 
 #include <android-base/properties.h>
@@ -72,8 +74,19 @@
 #endif
 
 void PrintTo(const Errno& e, std::ostream* os) {
-  // TODO: strerrorname_np() might be more useful here, but we'd need to implement it first!
-  *os << strerror(e.errno_);
+  // Prefer EINVAL or whatever, but fall back to strerror() to print
+  // "Unknown error 666" for bogus values. Not that I've ever seen one,
+  // but we shouldn't be looking at an assertion failure unless something
+  // weird has happened!
+#if defined(__BIONIC__)
+  const char* errno_name = strerrorname_np(e.errno_);
+  if (errno_name != nullptr) {
+    *os << errno_name;
+  } else
+#endif
+  {
+    *os << strerror(e.errno_);
+  }
 }
 
 bool operator==(const Errno& lhs, const Errno& rhs) {