Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 28 Apr 2013 22:07:57 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: [patch] add ether_(aton, ntoa)

On Sun, Apr 14, 2013 at 11:10:55PM -0500, Strake wrote:
> > Could you compare and see if it generates smaller code if we use a
> > single snprintf/sscanf to implement these functions rather than a
> > loop? I'm not sure which is better, but since they're not widely used,
> > my main interest is keeping them small.
> 
> ntoa: same size
> aton: mine is smaller

This doesn't seem to match my results. I compared against the
following version of aton and it was half the size of yours:

struct ether_addr *ether_aton_r (const char *x, struct ether_addr *p_a)
{
	unsigned char *y = p_a->ether_addr_octet;
	char c;
	if (sscanf(x, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx%c", y,y+1,y+2,y+3,y+4,y+5,y+6,&c)!=6)
		return 0;
	return p_a;
}

Rich

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.