From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9143 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] fix if_nametoindex return value when socket open fails Date: Sun, 17 Jan 2016 17:34:55 -0500 Message-ID: <20160117223455.GL238@brightrain.aerifal.cx> References: <5698be60.uat8s3q4Wfvl5TQE%rmy@frippery.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1453070112 18791 80.91.229.3 (17 Jan 2016 22:35:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jan 2016 22:35:12 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9156-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jan 17 23:35:11 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aKvug-0003nn-US for gllmg-musl@m.gmane.org; Sun, 17 Jan 2016 23:35:11 +0100 Original-Received: (qmail 23885 invoked by uid 550); 17 Jan 2016 22:35:09 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 23858 invoked from network); 17 Jan 2016 22:35:08 -0000 Content-Disposition: inline In-Reply-To: <5698be60.uat8s3q4Wfvl5TQE%rmy@frippery.org> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:9143 Archived-At: On Fri, Jan 15, 2016 at 09:39:44AM +0000, Ron Yorston wrote: > The return value of if_nametoindex is unsigned; it should return 0 > on error. > --- > src/network/if_nametoindex.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/network/if_nametoindex.c b/src/network/if_nametoindex.c > index cb6ec05..331413c 100644 > --- a/src/network/if_nametoindex.c > +++ b/src/network/if_nametoindex.c > @@ -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); Committed. Rich