On 5/1/21 7:40 PM, Jose E. Marchesi
wrote:
Hi Egeyar.
GCC -fanalyzer reported the following warnings:
7326:../../libpoke/ios.c:700:35: warning: shift by count ('64') >= precision of type ('64')
7382:../../libpoke/ios.c:1478:19: warning: shift by count ('64') >= precision of type ('64')
These reference code in ios.c like this:
/* We should shift to fill the least significant byte
which is the last 8 bits. */
*value = ((uint64_t) c[0] << (56 + lastbyte_bits))
| ((uint64_t) c[1] << (48 + lastbyte_bits))
| ((uint64_t) c[2] << (40 + lastbyte_bits))
| ((uint64_t) c[3] << (32 + lastbyte_bits))
| ((uint64_t) c[4] << (24 + lastbyte_bits))
| ((uint64_t) c[5] << (16 + lastbyte_bits))
| (c[6] << (8 + lastbyte_bits)) | (c[7] << lastbyte_bits)
| (c[8] >> (8 - lastbyte_bits));
Note how the code above incurs in UB when lastbyte_bits >= 8. I suppose
that this is a false positive and that in these two particular locations
lastbyte_bits can't be 8, but it would be good to double-check it.
Could you please take a look?
Thanks!