Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Dec 1997 06:24:40 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        current@FreeBSD.ORG, lars@fredriks-1.pr.mcs.net
Subject:   Re: EDOM and hz
Message-ID:  <199712181924.GAA07415@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>                        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



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