summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-06-03 17:53:11 -0400
committerRich Felker <dalias@aerifal.cx>2014-06-06 17:57:36 -0400
commitf8b5cc8a7e7482560f1b781d43a271c496a6d55c (patch)
tree2be6036b60ed8f4c0236bf5ac4ad96d1a19203a1 /src
parent5fa12af8daeaa71add0ccd15e082c01154545def (diff)
downloadmusl-f8b5cc8a7e7482560f1b781d43a271c496a6d55c.tar.gz
fix if_nametoindex return value when interface does not exist
the return value is unsigned, so negative results for "errors" do not make sense; 0 is the value reserved for when the interface name does not exist. (cherry picked from commit 8041af59881219c32267c3491bee43591d3c3fe6)
Diffstat (limited to 'src')
-rw-r--r--src/network/if_nametoindex.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/network/if_nametoindex.c b/src/network/if_nametoindex.c
index fb4a1474..cb6ec054 100644
--- a/src/network/if_nametoindex.c
+++ b/src/network/if_nametoindex.c
@@ -14,5 +14,5 @@ unsigned if_nametoindex(const char *name)
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
r = ioctl(fd, SIOCGIFINDEX, &ifr);
__syscall(SYS_close, fd);
- return r < 0 ? r : ifr.ifr_ifindex;
+ return r < 0 ? 0 : ifr.ifr_ifindex;
}