libcrypt/md5.c: a few statics can be auto variables; strlen("const") is silly

Denys Vlasenko vda.linux at googlemail.com
Tue Jun 10 20:49:21 UTC 2008


Hi Bernd, Carmelo,

Can you look through this patch?

It makes sp, ep and p variables automatic.
There is no point in having them static,
they never use their values retained from previous call.
These are code lines where they are assigned to:

char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
{
...
        /* Refine the Salt first */
        sp = salt;
...
        /* It stops at the first '$', max 8 chars */
        for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
                continue;
...
...
        p = passwd + strlen(passwd);

and prior to these lines, their values were never used.


The second, much simpler change replaces
	__md5__magic_len = strlen(__md5__magic);
and related code by compile-time constant.

Effect on size:

--- uClibc.t4/libcrypt/md5.o.disasm     Tue Jun 10 22:41:17 2008
+++ uClibc.t5/libcrypt/md5.o.disasm     Tue Jun 10 22:41:17 2008
@@ -1,5 +1,5 @@
    text           data     bss     dec     hex filename
-   1957              0     132    2089     829 libcrypt/md5.o
+   1905              0     120    2025     7e9 libcrypt/md5.o


--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5.patch
Type: text/x-diff
Size: 2066 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20080610/9921a56c/attachment.bin 


More information about the uClibc mailing list