From owner-cvs-all Tue Nov 28 17:43:15 2000 Delivered-To: cvs-all@freebsd.org Received: from cypherpunks.ai (cypherpunks.ai [209.88.68.47]) by hub.freebsd.org (Postfix) with ESMTP id 437D437B400; Tue, 28 Nov 2000 17:43:10 -0800 (PST) Received: from vangelderen.org (grolsch.ai [209.88.68.214]) by cypherpunks.ai (Postfix) with ESMTP id 2A5C651; Tue, 28 Nov 2000 21:43:08 -0400 (AST) Message-ID: <3A245F2C.9842890E@vangelderen.org> Date: Tue, 28 Nov 2000 21:43:08 -0400 From: "Jeroen C. van Gelderen" X-Mailer: Mozilla 4.73 [en] (X11; I; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: Alfred Perlstein Cc: Warner Losh , "Brian F. Feldman" , obrien@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/usr.sbin/inetd builtins.c References: <20001126182240.A8051@fw.wintelcom.net> <200011262140.eAQLe2576200@green.dyndns.org> <20001126182240.A8051@fw.wintelcom.net> <200011280524.WAA07413@harmony.village.org> <20001127221535.Y8051@fw.wintelcom.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Alfred Perlstein wrote: > > * Warner Losh [001127 21:24] wrote: > > In message <20001126182240.A8051@fw.wintelcom.net> Alfred Perlstein writes: > > : - if ((to.tv_usec += tv.tv_usec) >= 1000000) { > > : + to.tv_usec += tv.tv_usec; > > : + if (to.tv_usec >= 1000000) { > > : to.tv_usec -= 1000000; > > : to.tv_sec++; > > : } > > > > Shouldn't this be > > if (to.tv_usec >= 1000000) { > > to.tv_sec += to.tv_usec / 1000000; > > to.tv_usec %= 1000000; > > } > > Yes, but it's overkill as afaik = 2000000 > shouldn't happen. So, shouldn't it be: ASSERT(to.tv_usec < 2000000); to.tv_usec += tv.tv_usec; if (to.tv_usec >= 1000000) { to.tv_usec -= 1000000; to.tv_sec++; } This will catch unwarranted assumptions and/or broken code *and* would have prevented Warner's question *and* will prevent future confusion while maintaining efficiency. Cheers, Jeroen -- Jeroen C. van Gelderen - jeroen@vangelderen.org "It is not utopian to work for a society without taxation; it is utopian to think that the power to tax won't be abused once it is granted." -- Murray N. Rothbard (1926-1995) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message