[Toybox] ls.c compile error
Rob Landley
rob at landley.net
Wed Nov 6 17:46:16 PST 2019
On 11/6/19 3:41 PM, enh via Toybox wrote:
> external/toybox/toys/posix/ls.c:408:53: error: variable 'curcol' is
> uninitialized when used here
> unsigned curcol, lastlen = *len, lastcol = ul ? curcol : 0, color = 0;
> ^~~~~~
>
> should this line have come *after* the next line?
No, there was a declaration that wasn't at the start of the block and I collated
it, but that changed the lifetime rules. (Well, it didn't _really_ and all the
tests still pass, but it gave the optimizer the opportunity to screw stuff up,
so a future version will. Oddly gcc doesn't complain about it being uninitialized.)
The thing is, the logic wants the version from _last_ time through the loop, or
zero the first time through. So putting it after curcol gets overwritten is
still wrong.
Lemme take a proper look at the logic and see what I can unravel here. (After
breakfast, I'm late...)
Rob
More information about the Toybox
mailing list