Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Aug 2017 06:47:49 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        Colin Percival <cperciva@tarsnap.com>
Cc:        Hans Petter Selasky <hps@selasky.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r321985 - head/sys/ofed/drivers/infiniband/core
Message-ID:  <CAG6CVpWbkYkktaduJrhQCo00C9-ZzxAR6iLmc2VWxDJXtUvbuw@mail.gmail.com>
In-Reply-To: <0100015dabf99099-b39e4e26-cd45-4099-aa91-49820f55aacd-000000@email.amazonses.com>
References:  <201708030918.v739IPVY034866@repo.freebsd.org> <CAG6CVpVL49nVqRs5atub=d2P39EGOqcNtx_Raa8fWtV=BFZXbw@mail.gmail.com> <bd19c6f8-fa97-c9c5-6318-1778e38dd0a9@selasky.org> <0100015dabf99099-b39e4e26-cd45-4099-aa91-49820f55aacd-000000@email.amazonses.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 3, 2017 at 11:40 PM, Colin Percival <cperciva@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpWbkYkktaduJrhQCo00C9-ZzxAR6iLmc2VWxDJXtUvbuw>