Coverity check please...

Gary E. Miller gem at rellim.com
Mon Jan 20 04:28:22 UTC 2025


Yo Hal!

On Sun, 19 Jan 2025 20:18:52 -0800
Hal Murray <halmurray at sonic.net> wrote:

> Gary said:
> > Since j is 2, andi is 3, subtracting i from j caused integer wrap,
> > which is undefined.   
> 
> That assumes it goes around the loop a couple of times.  But it
> doesn't go around the loop even once -- or I'm confused.
> 
> We get here with n=2
> It looks to me like m gets initialized to 2.  Do you gt a different
> answer?
> > 471        i = 0; j = n;
> > 472        m = n - (n * 4) / 10;
> > 473        while ((j - i) > m) {  

While is executed before forst loop iteration.

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