got rid of all uses of strerror

This required some minor refactoring of other things and there were some
other small cleanups I noticed along the way.
diff --git a/aos/common/util/aos_strerror.cc b/aos/common/util/aos_strerror.cc
new file mode 100644
index 0000000..d2b2ca6
--- /dev/null
+++ b/aos/common/util/aos_strerror.cc
@@ -0,0 +1,42 @@
+#include "aos/common/util/aos_strerror.h"
+
+#include <assert.h>
+#include <sys/types.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "aos/linux_code/thread_local.h"
+
+// This code uses an overloaded function to handle the result from either
+// version of strerror_r correctly without needing a way to get the choice out
+// of the compiler/glibc/whatever explicitly.
+
+namespace {
+
+const size_t kBufferSize = 128;
+
+// Handle the result from the GNU version of strerror_r. It never fails, so
+// that's pretty easy...
+__attribute__((unused))
+char *aos_strerror_handle_result(int /*error*/, char *ret, char * /*buffer*/) {
+  return ret;
+}
+
+// Handle the result from the POSIX version of strerror_r.
+__attribute__((unused))
+char *aos_strerror_handle_result(int error, int ret, char *buffer) {
+  if (ret != 0) {
+    assert(snprintf(buffer, kBufferSize, "Unknown error %d", error) > 0);
+  }
+  return buffer;
+}
+
+}  // namespace
+
+char *aos_strerror(int error) {
+  static AOS_THREAD_LOCAL char buffer[kBufferSize];
+
+  // Call the overload for whichever version we're using.
+  return aos_strerror_handle_result(
+      error, strerror_r(error, buffer, sizeof(buffer)), buffer);
+}
diff --git a/aos/common/util/aos_strerror.h b/aos/common/util/aos_strerror.h
new file mode 100644
index 0000000..2fd6818
--- /dev/null
+++ b/aos/common/util/aos_strerror.h
@@ -0,0 +1,21 @@
+#ifndef AOS_COMMON_UTIL_AOS_STRERROR_H_
+#define AOS_COMMON_UTIL_AOS_STRERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Thread-safe version of strerror(3) (except it may change errno).
+//
+// Necessary because strerror_r(3) is such a mess (which version you get is
+// determined at compile time by black magic related to feature macro
+// definitions, compiler flags, glibc version, and even whether you're using g++
+// or clang++) and strerror_l(3) might not work if you end up with the magic
+// LC_GLOBAL_LOCALE locale.
+char *aos_strerror(int error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  // AOS_COMMON_UTIL_AOS_STRERROR_H_
diff --git a/aos/common/util/death_test_log_implementation.h b/aos/common/util/death_test_log_implementation.h
new file mode 100644
index 0000000..c1b12c0
--- /dev/null
+++ b/aos/common/util/death_test_log_implementation.h
@@ -0,0 +1,27 @@
+#ifndef AOS_COMMON_UTIL_DEATH_TEST_LOG_IMPLEMENTATION_H_
+#define AOS_COMMON_UTIL_DEATH_TEST_LOG_IMPLEMENTATION_H_
+
+#include <stdlib.h>
+
+#include "aos/common/logging/logging_impl.h"
+
+namespace aos {
+namespace util {
+
+// Prints all FATAL messages to stderr and then abort(3)s before the regular
+// stuff can print out anything else. Ignores all other messages.
+// This is useful in death tests that expect a LOG(FATAL) to cause the death.
+class DeathTestLogImplementation : public logging::HandleMessageLogImplementation {
+ public:
+  virtual void HandleMessage(const logging::LogMessage &message) override {
+    if (message.level == FATAL) {
+      logging::internal::PrintMessage(stderr, message);
+      abort();
+    }
+  }
+};
+
+}  // namespace util
+}  // namespace aos
+
+#endif  // AOS_COMMON_UTIL_DEATH_TEST_LOG_IMPLEMENTATION_H_
diff --git a/aos/common/util/util.gyp b/aos/common/util/util.gyp
index b20a7d9..9f3e1c6 100644
--- a/aos/common/util/util.gyp
+++ b/aos/common/util/util.gyp
@@ -1,6 +1,26 @@
 {
   'targets': [
     {
+      'target_name': 'death_test_log_implementation',
+      'type': 'static_library',
+      'sources': [
+        #'death_test_log_implementation',
+      ],
+      'dependencies': [
+        '<(AOS)/build/aos.gyp:logging',
+      ],
+      'export_dependent_settings': [
+        '<(AOS)/build/aos.gyp:logging',
+      ],
+    },
+    {
+      'target_name': 'aos_strerror',
+      'type': 'static_library',
+      'sources': [
+        'aos_strerror.cc',
+      ],
+    },
+    {
       'target_name': 'inet_addr',
       'type': 'static_library',
       'sources': [