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/linux_code/configuration.cc b/aos/linux_code/configuration.cc
index 2fd5150..55fff84 100644
--- a/aos/linux_code/configuration.cc
+++ b/aos/linux_code/configuration.cc
@@ -1,7 +1,6 @@
#include "aos/linux_code/configuration.h"
#include <string.h>
-#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -21,24 +20,24 @@
// set the IP address when running tests from the test.
const char *const kLinuxNetInterface = "eth0";
const in_addr *DoGetOwnIPAddress() {
- static const char *kOverrideVariable = "FRC971_IP_OVERRIDE";
- const char *override_ip = getenv(kOverrideVariable);
- if (override_ip != NULL) {
- LOG(INFO, "Override IP is %s\n", override_ip);
- static in_addr r;
- if (inet_aton(override_ip, &r) != 0) {
- return &r;
- } else {
- LOG(WARNING, "error parsing %s value '%s'\n", kOverrideVariable, override_ip);
- }
+ static const char *kOverrideVariable = "FRC971_IP_OVERRIDE";
+ const char *override_ip = getenv(kOverrideVariable);
+ if (override_ip != NULL) {
+ LOG(INFO, "Override IP is %s\n", override_ip);
+ static in_addr r;
+ if (inet_aton(override_ip, &r) != 0) {
+ return &r;
} else {
- LOG(INFO, "Couldn't get environmental variable.\n");
+ LOG(WARNING, "error parsing %s value '%s'\n",
+ kOverrideVariable, override_ip);
}
+ } else {
+ LOG(INFO, "Couldn't get environmental variable.\n");
+ }
ifaddrs *addrs;
if (getifaddrs(&addrs) != 0) {
- LOG(FATAL, "getifaddrs(%p) failed with %d: %s\n", &addrs,
- errno, strerror(errno));
+ PLOG(FATAL, "getifaddrs(%p) failed", &addrs);
}
// Smart pointers don't work very well for iterating through a linked list,
// but it does do a very nice job of making sure that addrs gets freed.
@@ -71,8 +70,7 @@
if (ret != -1) {
LOG(WARNING, "it returned %zd, not -1\n", ret);
}
- LOG(FATAL, "readlink(\"/proc/self/exe\", %p, %zu) failed with %d: %s\n",
- r, size, errno, strerror(errno));
+ PLOG(FATAL, "readlink(\"/proc/self/exe\", %p, %zu) failed", r, size);
}
if (ret < size) {
void *last_slash = memrchr(r, '/', ret);