Coverity check please...
Gary E. Miller
gem at rellim.com
Mon Jan 20 00:49:24 UTC 2025
Yo Hal!
On Sun, 19 Jan 2025 00:32:01 -0800
Hal Murray via devel <devel at ntpsec.org> wrote:
> I think it's a bug in Coverity. Would somebody please check.
I agree with coverity.
> Is there a way to report bugs to Coverity? Or tell it not to check
> something?
Not that I know of, and we would need a bug first.
> It's getting here with n =2
> 11. known_value_assign: j = n, its value is now 2.
> 471 i = 0; j = n;
> 472 m = n - (n * 4) / 10;
> (n*4)/10 is 0, so m is 2
> 12. Condition j - i > m, taking true branch.
> 16. Condition j - i > m, taking true branch.
> 20. Condition j - i > m, taking true branch.
>
> CID 497295: (#1 of 1): Overflowed constant (INTEGER_OVERFLOW)
> 24. overflow_const: Expression j - i, where j is known to be equal to
> 2, and i is known to be equal to 3, underflows the type of j - i,
> which is type unsigned long.
Since j is 2, andi is 3, subtracting i from j caused integer wrap, which
is undefined.
> 473 while ((j - i) > m) {
Work with 2s complement, but C does not specify 2s complement.
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
gem at rellim.com Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can't measure it, you can't improve it." - Lord Kelvin
More information about the devel
mailing list