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/die.h b/aos/common/die.h
index 3c5cca9..05500be 100644
--- a/aos/common/die.h
+++ b/aos/common/die.h
@@ -4,6 +4,7 @@
#include <stdarg.h>
#include "aos/common/macros.h"
+#include "aos/common/util/aos_strerror.h"
namespace aos {
@@ -17,6 +18,16 @@
__attribute__((noreturn))
__attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 1, 0)));
+
+// The same as Die except appends " because of %d (%s)" (formatted with errno
+// and aos_strerror(errno)) to the message.
+#define PDie(format, args...) \
+ do { \
+ const int error = errno; \
+ ::aos::Die(format " because of %d (%s)", ##args, error, \
+ aos_strerror(error)); \
+ } while (false);
+
// Turns on (or off) "test mode", where (V)Die doesn't write out files and
// doesn't print to stdout.
// Test mode defaults to false.