|
|
Message-ID: <5083450C.4070701@barfooze.de>
Date: Sun, 21 Oct 2012 02:42:52 +0200
From: John Spencer <maillist-musl@...fooze.de>
To: musl@...ts.openwall.com
Subject: Re: [PATCH 3/4] Import BSD functions defined in <netinet/ether.h>
from NetBSD
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.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.