diff options
author | Rich Felker <dalias@aerifal.cx> | 2014-06-03 17:53:11 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014-06-03 17:53:11 -0400 |
commit | 8041af59881219c32267c3491bee43591d3c3fe6 (patch) | |
tree | c7dbb1381b84ef53612225441506dba5350de221 /src/network/if_nametoindex.c | |
parent | d85d261ee601f7ccf0bb19c38c69e406a664fe8e (diff) | |
download | musl-8041af59881219c32267c3491bee43591d3c3fe6.tar.gz musl-8041af59881219c32267c3491bee43591d3c3fe6.tar.bz2 musl-8041af59881219c32267c3491bee43591d3c3fe6.tar.xz musl-8041af59881219c32267c3491bee43591d3c3fe6.zip |
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.
Diffstat (limited to 'src/network/if_nametoindex.c')
-rw-r--r-- | src/network/if_nametoindex.c | 2 |
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; } |