[PATCH] hdparm new option parsing

Tito farmatito at tiscali.it
Sun May 7 19:28:25 UTC 2006


On Sunday 7 May 2006 01:07, Rob Landley wrote:
> On Friday 05 May 2006 8:22 pm, Tito wrote:
> > On Friday 5 May 2006 23:16, Rob Landley wrote:
> > > What does the "#define PARSE_OPTS_CMD_V2 parse_opts_v2" accomplish,
> > > exactly?
> >
> > It does the same as
> >
> > #if ENABLE_FEATURE_HDPARM_SOMETHING
> > 	parse_opts_v2(x,y,z);
> > #endif
> 
> A normal if:
> 
>   if (ENABLE_FEATURE_HDPARM_SOMETHING) parse_opts_v2(x,y,z);
> 
> Should optimize out when the enable macro is a constant 0.  So we can use 
> normal C syntax and have everything checked for validity by the compiler (and 
> thus not get surprised by build breaks when we toggle a configuration 
> symbol).
> 
> Alas, sometimes you can't do that because, variables are only conditionally 
> defined (generally structure members), or a function takes a variable number 
> of arguments depending on how the config symbols go, and then you can use:
> 
>   USE_FEATURE_HDPARM_SOMETHING(parse_opts_v2(x,y,z);)
> 
> Which has the advantage that the knowledge is localized (the use site is where 
> the decision whether or not to include the functionality is expressed), but 
> without the line-based preprocessor syntax.  It works well with automatic 
> string concatenation as well.  I.E. "thing" "also" becomes "thingalso", thus 
> you can do "thing" USE_ALSO("also")
> 

New version of the previous patch with the ENABLE_ and USE_ stuff.
Enjoy.

Ciao,
Tito
> Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hdparm_getopt01.patch
Type: text/x-diff
Size: 17517 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060507/d79396dd/attachment.bin 


More information about the busybox mailing list