util: make *_from_name() returns negative errno on error

This commit is contained in:
Yu Watanabe
2018-11-28 20:20:50 +09:00
parent 7b5e750d2a
commit acf4d15893
9 changed files with 24 additions and 25 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
@@ -29,7 +30,7 @@ int af_from_name(const char *name) {
sc = lookup_af(name, strlen(name));
if (!sc)
return AF_UNSPEC;
return -EINVAL;
return sc->id;
}
+2 -1
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
#include <net/if_arp.h>
#include <string.h>
@@ -29,7 +30,7 @@ int arphrd_from_name(const char *name) {
sc = lookup_arphrd(name, strlen(name));
if (!sc)
return 0;
return -EINVAL;
return sc->id;
}