From owner-svn-src-head@freebsd.org Fri Aug 4 06:47:36 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A968DC9B2F; Fri, 4 Aug 2017 06:47:36 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 13CD280C3D; Fri, 4 Aug 2017 06:47:36 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 72E3026015A; Fri, 4 Aug 2017 08:47:34 +0200 (CEST) Subject: Re: svn commit: r321985 - head/sys/ofed/drivers/infiniband/core To: Colin Percival , cem@freebsd.org Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201708030918.v739IPVY034866@repo.freebsd.org> <0100015dabf99670-4b6c3f74-5f86-49a2-a3d5-85dee9e16f91-000000@email.amazonses.com> From: Hans Petter Selasky Message-ID: Date: Fri, 4 Aug 2017 08:45:23 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <0100015dabf99670-4b6c3f74-5f86-49a2-a3d5-85dee9e16f91-000000@email.amazonses.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2017 06:47:36 -0000 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