Subject: Re: CVS commit: src/sys/compat/linux/common
To: Simon Burge <simonb@wasabisystems.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: source-changes
Date: 11/09/2005 09:46:10
On Wed, Nov 09, 2005 at 05:52:33PM +1100, Simon Burge wrote:
> Emmanuel Dreyfus wrote:
> 
> > Module Name:	src
> > Committed By:	manu
> > Date:		Tue Nov  8 21:28:49 UTC 2005
> > 
> > Modified Files:
> > 
> > 	src/sys/compat/linux/common: linux_futex.c
> > 
> > Log Message:
> > 
> > Correctly computes futex timeout.
> 
> +               timeout_hz = (timeout.tv_sec * hz)
> +                          + ((timeout.tv_nsec * hz) / 1000000000);
> 
> It looks like we might have the chance of an overflow here.
> hz * 999,999,999 will be > 32bits for pretty much any value of hz.
> Maybe look at hzto() in kern_clock.c to see how it avoids
> overflow?

Or mstohz() in sys/sys/param.h, which you could use here, I guess:
timeout_hz = mstohz(timeout.tv_sec * 1000 + timeout.tv_nsec / 1000);

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--