]> err.no Git - dpkg/commitdiff
s-s-d: Use system timersub and fix timeval normalization in multiplication
authorAndreas Påhlsson <andreas.pahlsson@xcerion.com>
Thu, 24 Jan 2008 22:15:15 +0000 (00:15 +0200)
committerGuillem Jover <guillem@debian.org>
Thu, 24 Jan 2008 22:15:15 +0000 (00:15 +0200)
Closes: #462225
ChangeLog
THANKS
debian/changelog
utils/start-stop-daemon.c

index 69c26cc7fd825d3463d455167641e3476d5f2ad4..c8742bbf50a3c412cf563ed0b45d0545272512a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-25  Andreas Påhlsson  <andreas.pahlsson@xcerion.com>
+
+       * utils/start-stop-daemon.c (tsub): Remove function.
+       (tmul): Fix normalization.
+       (run_stop_schedule): Use timersub instead of tsub.
+
 2008-01-24  Raphael Hertzog  <hertzog@debian.org>
 
        * scripts/dpkg-genchanges.pl: Warn if the current version is
diff --git a/THANKS b/THANKS
index 6109ce9aacd8659ddb64096c8f85a805f5d1a849..c61d1273da42f55c9cb1978b8691da26d852b042 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -6,6 +6,7 @@ Alberto Garcia <berto@gpul.org>
 Anand Kumria <wildfire@progsoc.org>
 Andreas Barth <aba@not.so.argh.org>
 Andreas Metzler <ametzler@debian.org>
+Andreas Påhlsson <andreas.pahlsson@xcerion.com>
 Andrew Ferrier <andrew@new-destiny.co.uk>
 Andrew Hobson <ahobson@eng.mindspring.net>
 Andrew Suffield <asuffield@debian.org>
index d554e2f58baf644eb4f65b5f92640056da07a275..1eb6246988c844d346310cdbb3dd75857499447b 100644 (file)
@@ -6,6 +6,8 @@ dpkg (1.14.17) UNRELEASED; urgency=low
   * Add new keybinding in dselect to restore all selections back to
     whatever's currently installed. Closes: #151540
     Thanks to Colin Watson.
+  * Use system timersub and fix timeval normalization in multiplication in
+    start-stop-daemon. Thanks to Andreas Påhlsson. Closes: #462225
 
   [ Raphael Hertzog ]
   * Add a warning displayed by dpkg-genchanges if the current version is
index 79d07c349595d94cf01622e174e159049a3823b8..1494e55e07579cb5c3934ae11b2a774809713fa1 100644 (file)
@@ -216,26 +216,13 @@ xgettimeofday(struct timeval *tv)
                fatal("gettimeofday failed: %s", strerror(errno));
 }
 
-static void
-tsub(struct timeval *r, struct timeval *a, struct timeval *b)
-{
-       r->tv_sec = (time_t)(a->tv_sec - b->tv_sec);
-       r->tv_usec = (suseconds_t)(a->tv_usec - b->tv_usec);
-       if (r->tv_usec < 0) {
-               --r->tv_sec;
-               r->tv_usec += 1000000;
-       }
-}
-
 static void
 tmul(struct timeval *a, int b)
 {
        a->tv_sec *= b;
        a->tv_usec *= b;
-       if (a->tv_usec >= 1000000) {
-               ++a->tv_sec;
-               a->tv_usec -= 1000000;
-       }
+       a->tv_sec = a->tv_sec + a->tv_usec / 1000000;
+       a->tv_usec %= 1000000;
 }
 
 static long
@@ -1200,8 +1187,8 @@ run_stop_schedule(void)
                                if (ratio < 10)
                                        ratio++;
 
-                               tsub(&maxinterval, &stopat, &after);
-                               tsub(&interval, &after, &before);
+                               timersub(&stopat, &after, &maxinterval);
+                               timersub(&after, &before, &interval);
                                tmul(&interval, ratio);
 
                                if (interval.tv_sec < 0 || interval.tv_usec < 0)