On Mon, Mar 12, 2018 at 6:38 PM, Rob Landley <r...@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
From 6f4639cd21afd043b1a3c4822aa381fc880ffd1f Mon Sep 17 00:00:00 2001 From: Elliott Hughes <e...@google.com> Date: Wed, 14 Mar 2018 16:38:34 -0700 Subject: [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(-) diff --git a/lib/args.c b/lib/args.c index 7b9350f..5267ebe 100644 --- a/lib/args.c +++ b/lib/args.c @@ -304,7 +304,7 @@ void parse_optflaglist(struct getoptflagstate *gof) } else if (CFG_TOYBOX_FLOAT && new->type == '.') { FLOAT f = strtod(++options, &temp); if (temp != options) new->val[idx].f = f; - } else if (CFG_TOYBOX_DEBUG) error_exit("<>= only after .#"); + } else error_exit("<>= only after .#"); options = --temp; // At this point, we've hit the end of the previous option. The -- 2.16.2.804.g6dcf76e118-goog
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net