dovecot-1.2: timeval_diff_*() fixes.

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 13 00:27:30 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/00a1d109ecf6
changeset: 9312:00a1d109ecf6
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 12 17:27:25 2009 -0400
description:
timeval_diff_*() fixes.

diffstat:

1 file changed, 2 insertions(+), 11 deletions(-)
src/lib/time-util.c |   13 ++-----------

diffs (30 lines):

diff -r d48640a2ab4a -r 00a1d109ecf6 src/lib/time-util.c
--- a/src/lib/time-util.c	Wed Aug 12 17:06:07 2009 -0400
+++ b/src/lib/time-util.c	Wed Aug 12 17:27:25 2009 -0400
@@ -20,16 +20,7 @@ int timeval_cmp(const struct timeval *tv
 
 int timeval_diff_msecs(const struct timeval *tv1, const struct timeval *tv2)
 {
-	time_t secs;
-	int usecs;
-
-	secs = tv1->tv_sec - tv2->tv_sec;
-	usecs = tv1->tv_usec - tv2->tv_usec;
-	if (usecs < 0) {
-		secs++;
-		usecs += 1000000;
-	}
-	return (secs * 1000) + (usecs/1000);
+	return timeval_diff_usecs(tv1, tv2) / 1000;
 }
 
 long long timeval_diff_usecs(const struct timeval *tv1,
@@ -41,7 +32,7 @@ long long timeval_diff_usecs(const struc
 	secs = tv1->tv_sec - tv2->tv_sec;
 	usecs = tv1->tv_usec - tv2->tv_usec;
 	if (usecs < 0) {
-		secs++;
+		secs--;
 		usecs += 1000000;
 	}
 	return ((long long)secs * 1000000ULL) + usecs;


More information about the dovecot-cvs mailing list