tree-wide: make parse_ifindex simply return the index
We don't need a seperate output parameter that is of type int. glibc() says that the type is "unsigned", but the kernel thinks it's "int". And the "alternative names" interface also uses ints. So let's standarize on ints, since it's clearly not realisitic to have interface numbers in the upper half of unsigned int range.
This commit is contained in:
+7
-10
@@ -79,11 +79,10 @@ int parse_mode(const char *s, mode_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_ifindex(const char *s, int *ret) {
|
||||
int parse_ifindex(const char *s) {
|
||||
int ifi, r;
|
||||
|
||||
assert(s);
|
||||
assert(ret);
|
||||
|
||||
r = safe_atoi(s, &ifi);
|
||||
if (r < 0)
|
||||
@@ -91,26 +90,24 @@ int parse_ifindex(const char *s, int *ret) {
|
||||
if (ifi <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
*ret = ifi;
|
||||
return 0;
|
||||
return ifi;
|
||||
}
|
||||
|
||||
int parse_ifindex_or_ifname(const char *s, int *ret) {
|
||||
int parse_ifindex_or_ifname(const char *s) {
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
assert(ret);
|
||||
|
||||
r = parse_ifindex(s, ret);
|
||||
if (r >= 0)
|
||||
r = parse_ifindex(s);
|
||||
if (r > 0)
|
||||
return r;
|
||||
assert(r < 0);
|
||||
|
||||
r = (int) if_nametoindex(s);
|
||||
if (r <= 0)
|
||||
return -errno;
|
||||
|
||||
*ret = r;
|
||||
return 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int parse_mtu(int family, const char *s, uint32_t *ret) {
|
||||
|
||||
Reference in New Issue
Block a user