提交 8041af59 编写于 作者: R Rich Felker

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.
上级 d85d261e
......@@ -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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册