Subject: Re: 64-bit daddr_t problems with libsa
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 01/30/2003 16:10:14
> 
> > +strerror(int err)
> >  {
> > -static	char ebuf[64];
> > +	static	char ebuf[] = "Unknown error: code 999";
> > +	struct mi *mi;
> > ...
> > +	snprintf(ebuf + sizeof ebuf - 4, 3, "%d", err);
> > +	return ebuf;
> >  }
> 
> For readability reasons, I'd prefer something similar to what
> was there before (with the buffer size smaller of course), like:
> 
> 	static char ebuf[24];	/* must be enough to hold 'Unknown error' */
> 	...
> 	snprintf(ebuf, sizeof(ebuf), "Unknown error: code %d", err);

My code was like that until I just looked at it :-)
My version saves another 20 bytes, and we were worrying about 40 bytes.
 
> Otherwise looks good :) This should give back at least those 40B.
> 
> How much space is saved by this? When I did similar stuff
> in past, I found that replacing switch() or couple if's with 
> array+for(;;) actually increased code size in some cases.

That one definitely saved some space on the x86 build.  I was
desparately trying to find enough space to support filename
globbing in boot's ls.

	David

-- 
David Laight: david@l8s.co.uk