Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Oct 2001 11:03:00 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        Matt Dillon <dillon@FreeBSD.org>
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>
In-Reply-To: <200110280613.f9S6Dlc96209@freefall.freebsd.org>; from dillon@FreeBSD.org on Sat, Oct 27, 2001 at 11:13:47PM -0700
References:  <200110280613.f9S6Dlc96209@freefall.freebsd.org>

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




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