public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] clang sandbox warning
@ 2014-06-10 18:38 Jeroen Hofstee
  2014-07-30 15:57 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Jeroen Hofstee @ 2014-06-10 18:38 UTC (permalink / raw)
  To: u-boot

Hello Simon,

While trying to find a u-boot make command which likely works with a
pre-build clang linux package I got the following warnings:

`make CC="clang -no-integrated-as" HOSTCC="clang -no-integrated-as"
HOST_TOOLS_ALL=y sandbox_config tools`


/home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:59:17:
warning: variable 'flags' is uninitialized when used here
[-Wuninitialized]
        local_irq_save(flags);
                       ^~~~~
/home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:56:21:
note: initialize the variable 'flags' to silence this warning
        unsigned long flags;
                           ^
                            = 0
/home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:81:17:
warning: variable 'flags' is uninitialized when used here
[-Wuninitialized]
        local_irq_save(flags);
                       ^~~~~
/home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:78:21:
note: initialize the variable 'flags' to silence this warning
        unsigned long flags;
                           ^
                            = 0

I guess gcc accepts this since flags is not actually used. Anyway merely
mentioned for completeness. You might be interested in:

/home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:77:6: warning:
variable 'ret' is used uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
        if (!rsa) {
            ^~~~
/home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:94:9: note:
uninitialized use occurs here
        return ret;
               ^~~
/home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:77:2: note:
remove the 'if' if its condition is always false
        if (!rsa) {
        ^~~~~~~~~~~
/home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:48:9: note:
initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0

which actually looks like a bug. And:


/home/jeroen/software/u-boot/tools/../lib/rsa/rsa-verify.c:59:27:
warning: comparison of unsigned expression >= 0 is always true
[-Wtautological-compare]
        for (i = key->len - 1; i >= 0; i--) {
                               ~ ^  ~


which looks a bit odd, especially since there is no way to break out of
the loop and reach the final return statement, which has a comment to
that it might be useful (equal).

Regards,
Jeroen

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [U-Boot] clang sandbox warning
  2014-06-10 18:38 [U-Boot] clang sandbox warning Jeroen Hofstee
@ 2014-07-30 15:57 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2014-07-30 15:57 UTC (permalink / raw)
  To: u-boot

Hi Jeroen,

On 10 June 2014 19:38, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> Hello Simon,
>
> While trying to find a u-boot make command which likely works with a
> pre-build clang linux package I got the following warnings:
>
> `make CC="clang -no-integrated-as" HOSTCC="clang -no-integrated-as"
> HOST_TOOLS_ALL=y sandbox_config tools`
>
>
> /home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:59:17:
> warning: variable 'flags' is uninitialized when used here
> [-Wuninitialized]
>         local_irq_save(flags);
>                        ^~~~~
> /home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:56:21:
> note: initialize the variable 'flags' to silence this warning
>         unsigned long flags;
>                            ^
>                             = 0
> /home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:81:17:
> warning: variable 'flags' is uninitialized when used here
> [-Wuninitialized]
>         local_irq_save(flags);
>                        ^~~~~
> /home/jeroen/software/u-boot/arch/sandbox/include/asm/bitops.h:78:21:
> note: initialize the variable 'flags' to silence this warning
>         unsigned long flags;
>                            ^
>                             = 0
>
> I guess gcc accepts this since flags is not actually used. Anyway merely
> mentioned for completeness. You might be interested in:
>
> /home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:77:6: warning:
> variable 'ret' is used uninitialized whenever 'if' condition is true
> [-Wsometimes-uninitialized]
>         if (!rsa) {
>             ^~~~
> /home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:94:9: note:
> uninitialized use occurs here
>         return ret;
>                ^~~
> /home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:77:2: note:
> remove the 'if' if its condition is always false
>         if (!rsa) {
>         ^~~~~~~~~~~
> /home/jeroen/software/u-boot/tools/../lib/rsa/rsa-sign.c:48:9: note:
> initialize the variable 'ret' to silence this warning
>         int ret;
>                ^
>                 = 0
>
> which actually looks like a bug. And:
>
>
> /home/jeroen/software/u-boot/tools/../lib/rsa/rsa-verify.c:59:27:
> warning: comparison of unsigned expression >= 0 is always true
> [-Wtautological-compare]
>         for (i = key->len - 1; i >= 0; i--) {
>                                ~ ^  ~
>
>
> which looks a bit odd, especially since there is no way to break out of
> the loop and reach the final return statement, which has a comment to
> that it might be useful (equal).

Both of these looks like bugs - I will copy you on a patch (I don't
see a fix from you in patchwork). Thanks for reporting this.

Regards,
Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-30 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10 18:38 [U-Boot] clang sandbox warning Jeroen Hofstee
2014-07-30 15:57 ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox