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

Conrad Meyer cem at freebsd.org
Fri Aug 4 13:47:52 UTC 2017


On Thu, Aug 3, 2017 at 11:40 PM, Colin Percival <cperciva at tarsnap.com> wrote:
> On 08/03/17 23:28, Hans Petter Selasky wrote:
>> On 08/03/17 16:37, Conrad Meyer wrote:
>>> Is it not important that the subtraction and result are evaluated
>>> without truncation?
>>
>> ticks is a circular counter. Assuming time = 0 and jiffies = -1U, then "delay"
>> becomes a very large negative value, because long is used, and the delay <= 0
>> check, is no longer working like expected.
>>
>> 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.

It is undefined in C, but defined in practice with -fwrapv, which the
kernel relies upon already.

Best,
Conrad


More information about the svn-src-head mailing list