From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2170 Path: news.gmane.org!not-for-mail From: John Spencer Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 3/4] Import BSD functions defined in from NetBSD Date: Sun, 21 Oct 2012 02:42:52 +0200 Message-ID: <5083450C.4070701@barfooze.de> References: <1350764145-10305-1-git-send-email-awg@embtoolkit.org> <1350764145-10305-4-git-send-email-awg@embtoolkit.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1350780203 6187 80.91.229.3 (21 Oct 2012 00:43:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Oct 2012 00:43:23 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2171-gllmg-musl=m.gmane.org@lists.openwall.com Sun Oct 21 02:43:31 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TPjdb-0006sJ-6G for gllmg-musl@plane.gmane.org; Sun, 21 Oct 2012 02:43:31 +0200 Original-Received: (qmail 29751 invoked by uid 550); 21 Oct 2012 00:43:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 29743 invoked from network); 21 Oct 2012 00:43:23 -0000 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Mail/1.0 In-Reply-To: <1350764145-10305-4-git-send-email-awg@embtoolkit.org> Xref: news.gmane.org gmane.linux.lib.musl.general:2170 Archived-At: On 10/20/2012 10:15 PM, Abdoulaye Walsimou Gaye wrote: > +/* > + * ether_aton(): > + * This function converts an ASCII string of the same form and to a structure > + * containing the 6 octets of the address. It returns a pointer to a > + * static structure that is reused for each call. > + */ > +struct ether_addr *ether_aton(const char *s) > +{ > + static struct ether_addr n; > + unsigned int i[6]; > + > + assert(s != NULL); > + > + if (sscanf(s, " %x:%x:%x:%x:%x:%x ",&i[0],&i[1], > + &i[2],&i[3],&i[4],&i[5]) == 6) { > + n.ether_addr_octet[0] = (unsigned char)i[0]; > + n.ether_addr_octet[1] = (unsigned char)i[1]; > + n.ether_addr_octet[2] = (unsigned char)i[2]; > + n.ether_addr_octet[3] = (unsigned char)i[3]; > + n.ether_addr_octet[4] = (unsigned char)i[4]; > + n.ether_addr_octet[5] = (unsigned char)i[5]; > + return&n; > + } > + return NULL; > +} why do you duplicate the code and not use simply the _r functions from [4/4] with the static buffer ? btw the usage of sscanf is both bloated and slow. anyway, i doubt it makes sense to add this crap; i never needed it for sabotage which is almost feature complete and compiles 250 packages.