[Toybox] [PATCH] Fix bug in names_to_pid.

enh enh at google.com
Wed Mar 14 16:45:23 PDT 2018


On Mon, Mar 12, 2018 at 6:38 PM, Rob Landley <rob at landley.net> wrote:
> On 03/12/2018 11:13 AM, enh wrote:
>> Found by the compiler, not me:
>>
>>   lib/lib.c:1053:30: warning: 'st2.st_dev' may be used uninitialized
>> in this function [-Wmaybe-uninitialized]
>>          if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) continue;
>>                            ~~~^~~~~~~
>
> I despise the "may be used uninitialized" warning. It either is or it isn't.
>
> In this case, yes it looks like it is. So it should say "is used uninitialized".
> (They were 2 separate warnings in gcc for years and it was a fountain of false
> positives to the point I learned the "int a=a;" initializers from the kernel to
> SHUT IT UP.
>
> Anyway, appled.

since this went unnoticed i really want to remove -Wno-uninitialized
from our build. it turns out that there's currently only one other
line that clang's unhappy with, and it's our old friend
CFG_TOYBOX_DEBUG...

[PATCH] Fix last uninitialized warning.

clang is fine with the noreturn nature of error_exit, but only if we don't
`if (false)` it out for non-debug builds.

lib/args.c:304:18: error: variable 'temp' is used uninitialized
whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
      } else if (CFG_TOYBOX_FLOAT && new->type == '.') {
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/toybox/generated/config.h:11:26: note: expanded from macro
'CFG_TOYBOX_FLOAT'
                         ^
external/toybox/lib/args.c:308:19: note: uninitialized use occurs here
      options = --temp;
                  ^~~~
external/toybox/lib/args.c:304:14: note: remove the 'if' if its
condition is always true
      } else if (CFG_TOYBOX_FLOAT && new->type == '.') {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/toybox/lib/args.c:255:15: note: initialize the variable
'temp' to silence this warning
    char *temp;
              ^
               = NULL
---
 lib/args.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


> Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-last-uninitialized-warning.patch
Type: text/x-patch
Size: 1787 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20180314/a57adb31/attachment-0003.bin>


More information about the Toybox mailing list