Hi Collin,
> ./vasnprintf.c:6203:49: warning: variable 'thousep_len' is used
> uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> 6203 | if ((flags &
> FLAG_GROUP) && (intpart_digits > 1))
> |
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./vasnprintf.c:6232:76: note: uninitialized use occurs here
> 6232 | p += intpart_digits +
> insert * thousep_len;
> |
> ^~~~~~~~~~~
> ./vasnprintf.c:6203:45: note: remove the 'if' if its condition is always
> true
> 6203 | if ((flags &
> FLAG_GROUP) && (intpart_digits > 1))
> |
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 6204 | {
> [...]
>
> These warnings look correct to me since we always do
> "p += intpart_digits + insert * thousep_len" unconditionally without an
> early return.
It was introduced in commit 7d8705539af0c8555badacbdbe9c92ae0abca6f5.
Probably I thought that the uninitialized value doesn't matter, since in this
line it gets multiplied by 0, and 0 * anything is 0. But valgrind reports
an "uninitialised value" in such a case. Therefore you are right: better fix it.
> Can you confirm the attached patch is correct? Since this was introduced
> by your grouping fixes ~2 months ago.
The patch is correct. Any value would be a correct initializer; 0 is perfect
since it is available with the minimum of CPU instructions.
Thanks!
Bruno