From owner-freebsd-current Thu Dec 18 11:29:14 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id LAA15550 for current-outgoing; Thu, 18 Dec 1997 11:29:14 -0800 (PST) (envelope-from owner-freebsd-current) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id LAA15525 for ; Thu, 18 Dec 1997 11:28:56 -0800 (PST) (envelope-from bde@zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.6.9) id GAA07415; Fri, 19 Dec 1997 06:24:40 +1100 Date: Fri, 19 Dec 1997 06:24:40 +1100 From: Bruce Evans Message-Id: <199712181924.GAA07415@godzilla.zeta.org.au> To: current@FreeBSD.ORG, lars@fredriks-1.pr.mcs.net Subject: Re: EDOM and hz Sender: owner-freebsd-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > if (tv->tv_sec > SHRT_MAX / hz - hz) { > error = EDOM; > goto bad; > } > val = tv->tv_sec * hz + tv->tv_usec / tick; > > >If we are running with hz anything but 100 this code sort of breaks. > >That is: > >32767/100-100 = 227 > >but >32767/250-250 = -119 Actually, it prevents breakage when `val' is stored in sb_timeo which is short. It seems to allow breakage when tv->tv_sec < 0. >Can we modify this check in such a fashion that works more universally? Perhaps sb_timeo should be long. >Perhaps by changing val to an int?? > >and make it: > if (tv->tv_sec > INT_MAX/hz -hz) Not universally. INT_MAX is not guaranteed to be > 32767. If hz is LONG_MAX :-), then the variable needs to be much longer than long. Bruce