summaryrefslogtreecommitdiff
path: root/usr.sbin/cron
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2014-04-28 07:50:45 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2014-04-28 07:50:45 +0000
commit3b8f08459569bf0faa21473e5cec2491e95c9349 (patch)
tree80f45dd81ca716bcd7ca9674581e1fc40b93cd34 /usr.sbin/cron
parent9d2ab4a62d6733c45958627ac113bdbd818d1e2a (diff)
parentb2ba55951383498f252746f618d513139da06e8e (diff)
downloadsrc-test2-3b8f08459569bf0faa21473e5cec2491e95c9349.tar.gz
src-test2-3b8f08459569bf0faa21473e5cec2491e95c9349.zip
Notes
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r--usr.sbin/cron/cron/cron.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
index d374319f7483..0cdb9e3af51d 100644
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -376,30 +376,17 @@ cron_sync(int secres) {
}
}
-static int
+static void
timespec_subtract(struct timespec *result, struct timespec *x,
struct timespec *y)
{
- time_t nsec;
-
- /* Perform the carry for the later subtraction by updating y. */
- if (x->tv_nsec < y->tv_nsec) {
- nsec = (y->tv_nsec - x->tv_nsec) / 10000000 + 1;
- y->tv_nsec -= 1000000000 * nsec;
- y->tv_sec += nsec;
- }
- if (x->tv_nsec - y->tv_nsec > 1000000000) {
- nsec = (x->tv_nsec - y->tv_nsec) / 1000000000;
- y->tv_nsec += 1000000000 * nsec;
- y->tv_sec -= nsec;
+ *result = *x;
+ result->tv_sec -= y->tv_sec;
+ result->tv_nsec -= y->tv_nsec;
+ if (result->tv_nsec < 0) {
+ result->tv_sec--;
+ result->tv_nsec += 1000000000;
}
-
- /* tv_nsec is certainly positive. */
- result->tv_sec = x->tv_sec - y->tv_sec;
- result->tv_nsec = x->tv_nsec - y->tv_nsec;
-
- /* Return True if result is negative. */
- return (x->tv_sec < y->tv_sec);
}
static void