mirror of
git://git.musl-libc.org/musl
synced 2025-02-28 00:30:24 +00:00
fix if_nametoindex return value when socket open fails
The return value of if_nametoindex is unsigned; it should return 0 on error.
This commit is contained in:
parent
2f853dd6b9
commit
3cdbfb99c3
@ -10,7 +10,7 @@ unsigned if_nametoindex(const char *name)
|
||||
struct ifreq ifr;
|
||||
int fd, r;
|
||||
|
||||
if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return -1;
|
||||
if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
|
||||
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
|
||||
r = ioctl(fd, SIOCGIFINDEX, &ifr);
|
||||
__syscall(SYS_close, fd);
|
||||
|
Loading…
Reference in New Issue
Block a user