From owner-cvs-all Tue Oct 30 1: 3:53 2001 Delivered-To: cvs-all@freebsd.org Received: from straylight.ringlet.net (sentinel.office1.bg [217.75.129.210]) by hub.freebsd.org (Postfix) with SMTP id 92E8B37B40C for ; Tue, 30 Oct 2001 01:03:26 -0800 (PST) Received: (qmail 3976 invoked by uid 1000); 30 Oct 2001 09:03:00 -0000 Date: Tue, 30 Oct 2001 11:03:00 +0200 From: Peter Pentchev To: Matt Dillon Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sbin/dump optr.c Message-ID: <20011030110300.B622@straylight.oblivion.bg> Mail-Followup-To: Matt Dillon , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org References: <200110280613.f9S6Dlc96209@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200110280613.f9S6Dlc96209@freefall.freebsd.org>; from dillon@FreeBSD.org on Sat, Oct 27, 2001 at 11:13:47PM -0700 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, Oct 27, 2001 at 11:13:47PM -0700, Matt Dillon wrote: > dillon 2001/10/27 23:13:47 PDT > > Modified files: > sbin/dump optr.c > Log: > deltat declared time_t, msg("") call used %d (assumed time_t == int). > Changed deltat to be an int (result of delta time calculation). > > MFC after: 1 day How about the following change? I don't think it's really correct either, technically deltat should be declared 'double' and the division by 3600 should be rewritten; still, isn't difftime(3) the correct way to, well, to diff times? :) (And yes, I know that actual subtraction will work as well.) G'luck, Peter -- If I had finished this sentence, Index: src/sbin/dump/optr.c =================================================================== RCS file: /home/ncvs/src/sbin/dump/optr.c,v retrieving revision 1.15 diff -u -r1.15 optr.c --- src/sbin/dump/optr.c 28 Oct 2001 06:13:47 -0000 1.15 +++ src/sbin/dump/optr.c 30 Oct 2001 08:59:59 -0000 @@ -200,9 +200,9 @@ tschedule = tnow + 300; if (blockswritten < 500) return; - deltat = tstart_writing - tnow + - (1.0 * (tnow - tstart_writing)) - / blockswritten * tapesize; + deltat = (int)(difftime(tstart_writing, tnow) + + difftime(tnow, tstart_writing) + / blockswritten * tapesize); msg("%3.2f%% done, finished in %d:%02d\n", (blockswritten * 100.0) / tapesize, deltat / 3600, (deltat % 3600) / 60); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message