Subject: Re: 64-bit daddr_t problems with libsa
To: David Laight <david@l8s.co.uk>
From: Jaromir Dolecek <jdolecek@netbsd.org>
List: tech-kern
Date: 01/30/2003 16:39:18
David Laight wrote:
> +static struct mi {
> + int errno;
> + char *msg;
const pls.
> +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);
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.
Jaromir
--
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.NetBSD.org/
-=- We should be mindful of the potential goal, but as the tantric -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow. Do not let this distract you.'' -=-