svn commit: r321985 - head/sys/ofed/drivers/infiniband/core

Hans Petter Selasky hps at selasky.org
Fri Aug 4 06:47:36 UTC 2017


On 08/04/17 08:40, Colin Percival wrote:
>> Casting to "int" or truncating is the right thing to do in this case.
> Signed integer overflow is undefined.  Using 'int' is liable to cause problems
> after 2^32  ticks.
> 

Hi,

If you check the code how this function is used, you'll see that the 
argument passed is computed from:

jiffies + n, where "n" is a relatively small value.

The <= 0 check is basically there to catch cases where the jiffies value 
has changed between the point where it was set and the point where the 
relative ticks timeout value "n" was extracted.

Basically the code is doing like this, reading the value of "jiffies" twice.

delay = (jiffies0 + n) - jiffies1;

if (delay <= 0)
delay = 1;

And then "delay" should be "int", because we are usually not dealing 
with timeouts greater than a few hundred seconds or so.

--HPS


More information about the svn-src-head mailing list