macaddr: fix osmo_macaddr_parse(): return meaningful error codes
Change-Id: I316deb83979198acc26721d29708d9942174b192
diff --git a/src/macaddr.c b/src/macaddr.c
index a9138f8..56fdf86 100644
--- a/src/macaddr.c
+++ b/src/macaddr.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <errno.h>
/*! Parse a MAC address from human-readable notation
* This function parses an ethernet MAC address in the commonly-used
@@ -77,11 +78,11 @@
*/
int osmo_get_macaddr(uint8_t *mac_out, const char *dev_name)
{
- int rc = -1;
struct ifaddrs *ifa, *ifaddr;
+ int rc = -ENODEV;
if (getifaddrs(&ifaddr) != 0)
- return -1;
+ return -errno;
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
struct sockaddr_dl *sdl;