From 75a5f1d837739fc84a7c5af14797490774a10646 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 24 Oct 2014 19:09:36 +0200 Subject: [PATCH] time: minor simplification --- src/shared/time-util.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/shared/time-util.c b/src/shared/time-util.c index 43ad9db91..33d0822f3 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -49,25 +49,20 @@ dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) { int64_t delta; assert(ts); - if (u == USEC_INFINITY) { - ts->realtime = ts->monotonic = USEC_INFINITY; + if (u == USEC_INFINITY || u <= 0) { + ts->realtime = ts->monotonic = u; return ts; } ts->realtime = u; - if (u == 0) - ts->monotonic = 0; - else { - delta = (int64_t) now(CLOCK_REALTIME) - (int64_t) u; - - ts->monotonic = now(CLOCK_MONOTONIC); + delta = (int64_t) now(CLOCK_REALTIME) - (int64_t) u; + ts->monotonic = now(CLOCK_MONOTONIC); - if ((int64_t) ts->monotonic > delta) - ts->monotonic -= delta; - else - ts->monotonic = 0; - } + if ((int64_t) ts->monotonic > delta) + ts->monotonic -= delta; + else + ts->monotonic = 0; return ts; } -- 2.30.2