+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
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>
* 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
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
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)