[PATCH]passwd: size reduction and clean up

Bernhard Fischer rep.nop at aon.at
Thu Dec 29 14:02:00 UTC 2005


On Thu, Dec 29, 2005 at 02:14:37PM +0100, Tito wrote:
>On Thursday 29 December 2005 13:48, Bernhard Fischer wrote:
>> On Thu, Dec 29, 2005 at 01:49:52AM +0100, Tito wrote:
>> >Hi,
>> >I know that we are in feature freeze, but this patch is trivial...
>> >The patch changes:
>> >
>> >a) getopt -> bb_getopt_ulflags
>> >b) fprintf(stderr ... -> bb_error_msg/bb_perror_msg
>> >c) some minor hacks to save space.
>> >d) adds a GPL license text
>> >e) adds some CLEANUP stuff

f) use memset instead of bzero.
g) fold some helper functions into _main as they were only used once
anyway.
>> >
>> >Size reduction is:
>> >  text    data     bss     dec     hex filename
>> >   3243       0     160    3403     d4b passwd.o.orig
>> >   3025       0     160    3185     c71 passwd.o
>> >
>> >I tested the patch a few times on my box and it worked fine.
>> >
>> >Please take a look at it and apply or save for 1.2.
>> 
>> What do you think about the attached further size reduction?
>> 
>>    text    data     bss     dec     hex filename
>>    3159       0     160    3319     cf7 loginutils/passwd.o.oorig
>>    2947       0     160    3107     c23 loginutils/passwd.o.tito
>>    2871       0     160    3031     bd7 loginutils/passwd.o
>Hi, 
>the patch compiles fine with gcc-4.0 (GCC) 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9).
>Size reduction for me is:
> text    data     bss     dec     hex filename
>   3243       0     160    3403     d4b passwd.o.orig
>root at localhost:/dev/pts/0:/root/Desktop/busybox# size loginutils/passwd.o
>   text    data     bss     dec     hex filename
>   2949       0     160    3109     c25 loginutils/passwd.o    with shadow passports
>root at localhost:/dev/pts/0:/root/Desktop/busybox# size loginutils/passwd.o
>   text    data     bss     dec     hex filename                         without shadow passports
>   2897       0     160    3057     bf1 loginutils/passwd.o
>
>So for me it's ok, let's see what Rob thinks about it....

Could you also try to get rid of "algo" and use algo_arg instead?
Something like: if (new_password(pw, amroot, *algo_arg=='\0'?0:1)) {
As said, it's untested as of now, so one should make sure that it still
does what it's supposed to do :)

update_password() may also benefit from something like:
close_out_fp:
fclose(out_fp);
close_fp:
fclose(fp);
return 1;
out_fcntl_fp:
etc

Maybe we can shrink it to slightly below 2800 Bytes.
just a thought.



More information about the busybox mailing list