[PATCH] one more hdparm patch with command line parsing bug fix

Tito farmatito at tiscali.it
Sat May 13 19:24:48 UTC 2006


On Saturday 13 May 2006 18:43, Bernhard Fischer wrote:
> 
> Tito,
> 
> On Sat, May 13, 2006 at 04:20:46PM +0200, Tito wrote:
> >Hi,
> >this is a new hdparm patch to fix one bug, reduce size and clean up the code.
> >The main changes are:
> >
> >Fixed bug in command line arg parsing:  flags for options without args are reset on next getopt_long iteration.
> >Updated the timing algorithm  in do_time()  to that of hdparm 6.6  (gives better results on my drives and code is cleaner).
> >Changed switch() to if() else if() else  to reduce size.
> >Renamed if_printf_on_off() to print_flag_on() and optimised for size.
> >Removed if_printf() as it increases size and substituted with print_flag() where appropriate.
> >Removed check_if_min_and_set_val() as it increases size.
> >Removed check_if_maj_and_set_val() as it increases size.
> >Removed if_else_printf() as it increases size.
> >Removed sync_and_sleep() as now it was used only in one place.
> >Moved code used 2 times in do_time() to print_timing().
> >Optimised some text strings to reduce size.
> >
> >Commandline option parsing should now work in all cases.
> >Size reduction for hdparm.o (with all options enabled) is:
> >   text    data     bss     dec     hex filename
> >  23525     176     872   24573    5ffd hdparm.o.orig 
> >  22209     176     864   23249    5ad1hdparm.o
> >
> >Please apply before feature freeze.
> 
> allnoconfig, enable all hdparm stuff:
> $ size miscutils/hdparm.o*
>    text	   data	    bss	    dec	    hex	filename
>   31717	    148	    872	  32737	   7fe1	miscutils/hdparm.o.oorig
>   29870	    148	    864	  30882	   78a2	miscutils/hdparm.o.10
>   29743	    148	    864	  30755	   7823	miscutils/hdparm.o.11a



> For my compiler it helps if you explicitely cache the array-derefs like
> in identify() near /* reset result */, can you reproduce this with your
> compiler?

Sorry, but due to my limited knowledge,  English and programming,
i don't understand exactly  what you're talking about here?

How can I "explicitely cache the array-derefs"?  

> Also, we should use "strng" more often. I renamed 's' to strng for better
> grep'ability

Yes, you are right, didn't think  about this.

> The putchar and puts usage makes absolutely no difference for any
> version of gcc i have here. Do you see any adverse/positive effect if you
> change these?

Yes, i can confirm this, for gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5),
it seems that:

printf("\n");
putchar('\n');
puts("");

produce binaries of the same size.
Same thing for:

printf("Prova\n");
puts("Prova");

That's why I don't change them anymore.

Should we merge the 2 patches?

Ciao,
Tito
> >
> >PS.: Rob, I know the patch is rather big, but it does mostly trivial stuff, the only real changes
> >       are the bugfix in main and the timing algorithm update in do_time(). Sorry!
> >       If you really, really, really want this patch splitted in pieces....... i will do it.
> >
> 
> 
> >_______________________________________________
> >busybox mailing list
> >busybox at busybox.net
> >http://busybox.net/cgi-bin/mailman/listinfo/busybox
> 



More information about the busybox mailing list