[PATCH] compiler warning cleanup in libcrypt/des.c

Bernhard Fischer rep.dot.nop at gmail.com
Thu Mar 15 08:39:19 UTC 2007


On Thu, Mar 15, 2007 at 03:19:17AM +0000, Al Stone wrote:

>   gcc -c short_des.c -Wall -Os -fno-tree-dominator-opts
>
>where short_des.c is the pared down version of libcrypt/des.c, and looks
>like this:
>
>unsigned int saltbits;
>
>static int
>do_des(unsigned int *l_out)
>{
>        unsigned int    l;
>        unsigned int    f, r48l, r48r;
>        int             round;
>
>        l = r48l = r48r = 0;
>        round = 16;
>        while (round--) {
>                while (round--) {
>                        f = (r48l ^ r48r) & saltbits;
>                }
>                l = f;
>        }
>        *l_out = l;
>        return(0);
>}
>
>void __des_crypt(void)
>{
>        unsigned int    l, r0;
>        unsigned char   *p;
>
>        p = 0;
>        if (do_des(&r0))
>                return;
>        l = r0;
>        *p++ = l;
>}
>
>
>If I remove almost anything else, the warning goes away.  It looks
>like GCC is confused about the loop variable, even though it is very
>clearly being set to a constant.  For no obvious reason, it believes
>the loop variable could somehow be set so that one never enters the
>inner loop.  The warning is bogus, especially since you get this out:
>
>short_des.c: In function '__des_crypt':
>short_des.c:7: warning: 'f' may be used uninitialized in this function
>
>Apparently, it's trying to inline do_des() and gets confused about
>who 'f' even belongs to.
>
>The good news is that this has been fixed in GCC 4.3.0.  I've filed
>bugzilla #31181 against GCC 4.1.2 for documentation purposes, if
>nothing else.

There are numerous dups of this one, really.
20968, #4
>
>So: wait until GCC 4.3.0, or apply the patch as a workaround?  Either
>way works for me...

4.2.0 does also warn about it, fwiw.
I wouldn't install a workaround, personally.



More information about the uClibc mailing list