util: make *_from_name() returns negative errno on error
This commit is contained in:
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user