diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-10-24 19:09:36 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-10-24 19:09:36 +0200 |
commit | 75a5f1d837739fc84a7c5af14797490774a10646 (patch) | |
tree | 06d161d80ad0b29e7ced9bf6e498d6294e1cc321 /src/shared/time-util.c | |
parent | 65de0395ffe1cfb0f9af86504e8588fb31bb0fbc (diff) |
time: minor simplification
Diffstat (limited to 'src/shared/time-util.c')
-rw-r--r-- | src/shared/time-util.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/shared/time-util.c b/src/shared/time-util.c index 43ad9db91e..33d0822f33 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; } |