projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5fa12af
)
fix if_nametoindex return value when interface does not exist
author
Rich Felker
<dalias@aerifal.cx>
Tue, 3 Jun 2014 21:53:11 +0000
(17:53 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Fri, 6 Jun 2014 21:57:36 +0000
(17:57 -0400)
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
)
src/network/if_nametoindex.c
patch
|
blob
|
history
diff --git
a/src/network/if_nametoindex.c
b/src/network/if_nametoindex.c
index fb4a14747edeb4836f59a290391128a504c4019f..cb6ec054efbd971fc362bc7dd24c738fc12eb997 100644
(file)
--- 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;
}