[tz] tzcode: uninitialized sp->charcnt gives clang analyzer warning

Paul Eggert eggert at cs.ucla.edu
Mon Aug 9 21:32:41 UTC 2021

On 8/9/21 4:47 AM, Jan Engelhardt via tz wrote:

> When building tzcode commit 7f74206b39673b1a110285c6992f70507e211060
> with -DALL_STATE, clang reports a loop with a undefined
> termination condition because sp->charcnt is not set before its
> use. There should probably be a sp->charcnt=0 in zoneinit.

Thanks for reporting that. Unfortunately, though, this appears to be a 
false alarm from Clang, as I don't see how sp->charcnt can be used 
without being set, because If tzload returns zero then sp->charcnt must 
be set. If you see a reason it is not a false alarm, please let us know. 
Otherwise, it might be good to file a bug report with the Clang folks.

I did try running clang with -fanalyzer and _DALL_STATE, as well as gcc 
with similar flags (something I don't normally do, as -fanalyzer is 
kinda slow), and fixed some minor glitches with the attached patch. This 
doesn't affect the problem you mention, though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Remove-some-lint-found-by-GCC-Clang.patch
Type: text/x-patch
Size: 11867 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20210809/38594cba/attachment.bin>

More information about the tz mailing list