Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jun 1995 09:18:23 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        hackers@freebsd.org, mtaylor@gateway.cybernet.com
Subject:   Re: brokenness in kern_time.c: timevalfix()
Message-ID:  <199506222318.JAA15556@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I've noticed that timevalfix() does not calculate fixes 'correctly'
>(completely).  I assume that it is suposed to take a given timeval structure
>and 'fix' it so that tv_usec is less than one million and greater than zero,
>while adjusting tv_sec appropriately.

I think it is only supposed to handle naively added and subtracted valid
timevals.  For such pre-timevals, -999999 <= t1->tv_usec < 1999999 so
there is no need to loop.  itimerfix() rejects invalid timevals.

>Another way to fix it would be to do an integer division of tv_usec by 1000000
>to determine how many seconds need to be added / subtracted:

The extra division and multiplication would make this method 10-20 times
slower on i*86's.

>Also, timevalfix() is called by timevaladd() and timevalsub(), so why is it
>being called in settimeofday() right after a timevaladd()?  Isn't this
>redundant?

I think it fixes `delta' not being timevalfix()ed.  It doesn't fix `atv'
not being validated.  This is a bug.

>These 'problems' have been in kern_time.c at least since FreeBSD 1.1.5.1.

The previous bug wasn't in 1.1.5.1, (`runtime' didn't exist and only the
seconds part of `boottime' was adjusted, so `boottime' was sometimes
inaccurate but never invalid).

Bruce



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