From f76f21b24536c7d1bb2622fffc3b8c1eda59fb51 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 27 Aug 2020 01:10:51 +0700 Subject: [PATCH] macaddr: fix osmo_macaddr_parse(): return meaningful error codes Change-Id: I316deb83979198acc26721d29708d9942174b192 --- src/macaddr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/macaddr.c b/src/macaddr.c index a9138f840..56fdf86eb 100644 --- a/src/macaddr.c +++ b/src/macaddr.c @@ -34,6 +34,7 @@ #include #include #include +#include /*! 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_macaddr_parse(uint8_t *out, const char *in) */ 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;