From owner-freebsd-hackers Thu Jun 22 16:19:56 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id QAA04198 for hackers-outgoing; Thu, 22 Jun 1995 16:19:56 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.34]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id QAA04192 for ; Thu, 22 Jun 1995 16:19:50 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id JAA15556; Fri, 23 Jun 1995 09:18:23 +1000 Date: Fri, 23 Jun 1995 09:18:23 +1000 From: Bruce Evans Message-Id: <199506222318.JAA15556@godzilla.zeta.org.au> To: hackers@freebsd.org, mtaylor@gateway.cybernet.com Subject: Re: brokenness in kern_time.c: timevalfix() Sender: hackers-owner@freebsd.org Precedence: bulk >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