[Toybox] Assigned value is garbage or undefined

Rob Landley rob at landley.net
Tue Nov 18 17:18:43 PST 2014


On 11/18/14 17:52, Isaac Dunham wrote:
> On Tue, Nov 18, 2014 at 03:13:17PM -0800, Cynt Rynt wrote:
>> Bug reported by the clang static analyzer.

Sorry for the radio silence, I spent several all-nighters debugging sed,
made it through the end of the busybox test suite (minus the tests I
commented out as testing a _bug_ in other implementations rather than a
behavior we actually want to emulate), and at the end of that it _still_
won't build the distcc ./configure stage.

So I'm leaving sed in "pending" this release and cutting the
long-delayed release. I'm working on release notes for 0.5.1 right now,
but closing various windows I keep hitting "sha1sum big endian, right,
need to fix that or revert the patch that broke it"...

Your (Cynt's) previous message is in one of those tabs, working my way
to it...

>>  void chvt_main(void)
>>  {
>> -  int vtnum, fd = fd;
>> +  int vtnum, fd = -2;
> ...
>>  static void loopback_setup(char *device, char *file)
>>  {
>>    struct loop_info64 *loop = (void *)(toybuf+32);
>> -  int lfd = -1, ffd = ffd;
>> +  int lfd = -1, ffd = -1;
> 
> "a = a" does nothing useful, but that's the point:
> whereever it's used, "a" is something that is assigned to in a way that
> GCC is not aware of. It's a "shut up gcc" trick that has no effect on 
> code size.

Indeed. GCC has two different warnings, "$BLAH is used uninitialized"
and "$BLAH may be used uninitialized". The "may be" one is often
spuriously generated, the code provably does not ever use it
uninitialized, but gcc's code analyzer can't tell.

Unfortunately, you can't shut up the second category of suprious
messages without shutting up the first properly generated (and very
useful) ones, they're controlled by the same warning switch. (I traced
through the code to try to fix this once. I could patch it out of my
local copy of gcc, but that didn't help.)

I blogged about this back in 2006:

http://landley.net/notes-2006.html#31-12-2006

Back to working on release notes...

Rob

 1416359923.0


More information about the Toybox mailing list