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

Tito farmatito at tiscali.it
Sat May 13 14:20:46 UTC 2006


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.

Thanks and 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hdparm10.patch.bz2
Type: application/x-bzip2
Size: 13091 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060513/e9ef96b0/attachment.bin 


More information about the busybox mailing list