[PATCH v3 5/5] mtdinfo: consolidate help as display_help()

Brian Foster brian.foster at maxim-ic.com
Tue Aug 16 03:18:15 EDT 2011


On Tuesday 16 August 2011 06:00:57 Mike Frysinger wrote:
> On Mon, Aug 15, 2011 at 13:27, Brian Norris wrote:
> > On Sat, Aug 13, 2011 at 11:10 AM, Mike Frysinger wrote:
> >> On Fri, Aug 12, 2011 at 12:37, Brian Norris wrote:
> > ...
> >>> "mtdinfo"). I suppose we could either hardcode the spaces in or try to
> >>> do some sort of "ARRAY_SIZE" trickery (as found in the Linux kernel)
> >>
> >> you could probably use %*s and then pass in "" as well as <some max
> >> spacing number - strlen(PROGRAM_NAME)>.
> >>
> >> printf("%*s\n", 80 - strlen(PROGRAM_NAME), "");
> >
> > Yes, that's what I meant...of course "strlen" is better than writing
> > your own ARRAY_SIZE() when you already have the full C library :)
> 
> gcc optimizes strlen("constant") into a number

 And ‘ARRAY_SIZE(...)’, in this case, is simply ‘sizeof(...)’
 (or, actually, ‘sizeof(...)-1’ to be equivalent to ‘strlen’).

 Albeit I won't worry about the case of  strlen > 80  here,
 I am mildly curious what the output would be if that were
 indeed true...?

 The other thing I won't worry about is the assumption every
 output byte in PROGRAM_NAME is a printing glyph occupying
 exactly one cell.  That is true (in this case) ....

cheers!
	-blf-
-- 
Brian FOSTER
Principal MTS, Software
Maxim Integrated Products (Microcontroller BU), formerly Innova Card
Web    : http://www.maxim-ic.com/



More information about the linux-mtd mailing list