X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnetwork%2Fif_nametoindex.c;h=331413c68912daf5157988df60f3605c8d818750;hb=ae388becb529428ac926da102f1d025b3c3968da;hp=fb4a14747edeb4836f59a290391128a504c4019f;hpb=0716b10ac8dc167f96969c964974d4094035fed0;p=musl diff --git a/src/network/if_nametoindex.c b/src/network/if_nametoindex.c index fb4a1474..331413c6 100644 --- a/src/network/if_nametoindex.c +++ b/src/network/if_nametoindex.c @@ -10,9 +10,9 @@ 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); - return r < 0 ? r : ifr.ifr_ifindex; + return r < 0 ? 0 : ifr.ifr_ifindex; }