[PATCH] hdparm new option parsing

Tito farmatito at tiscali.it
Sat May 6 00:22:41 UTC 2006


On Friday 5 May 2006 23:16, Rob Landley wrote:
> On Friday 05 May 2006 3:21 pm, Tito wrote:
> > Hi,
> > this is the first attempt to clean up and shrink hdparm's option parsing.
> > It is tested, but may contain more bugs so review is wellcome.....
> >
> > Size reduction is:
> >    text    data     bss     dec     hex filename
> >   25236     176     872   26284    66ac hdparm.o.orig
> >   23637     176     872   24685    606d hdparm.o
> >
> > Please apply if you are brave or test it if you are not....
> 
> Ummm...
> 
> +#define HDPARM_STR_IDENTITY "\256iI"
> +#define PARSE_OPTS_IDENT(x,y)          y=(x)
> +#else
> +#define HDPARM_STR_IDENTITY ""
> +#define PARSE_OPTS_IDENT(x,y)
> +#endif
> +/*-------------------------------------*/
> +#if ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA
> +#define HDPARM_STR_DMA "d::"
> +#define PARSE_OPTS_DMA         parse_opts
> +#else
> +#define HDPARM_STR_DMA ""
> +#define PARSE_OPTS_DMA(...)
>  #endif
> +/*-------------------------------------*/
> +#ifdef HDIO_DRIVE_CMD
> +#define HDPARM_STR_DRIVE_CMD "S::D::P::X::K::A::L::W::CyYzZ"
> +#define PARSE_OPTS_CMD         parse_opts
> +#define PARSE_OPTS_CMD_V2      parse_opts_v2
> +#define PARSE_OPTS_CMD_V3      parse_opts_v3
> +#define PARSE_OPTS_REREAD_PARTN(x,y)           y=(x)
> +#else
> 
> Just confirming: this is the cleaned up version?  It's supposed to look like 
> that?

Yes, it is.

> 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

without sticking all that #if #endif in the source.
Just a case preprocessor abuse.... ;-)
in this case it is:

#if ENABLE_FEATURE_HDPARM_SOMETHING
#define PARSE_OPTS_CMD_V2      parse_opts_v2      /* Use the function */
#else
#define PARSE_OPTS_CMD_V2(x,y,z)                           /* Remove it as the option is not enabled */  
#endif

Maybe there is a better way to do it but due to my limited skills I haven't found it yet.....

Ciao,
Tito
> Rob



More information about the busybox mailing list