summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-11 03:03:17 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-11 15:54:42 +0100
commit966204e010ed432a1d7a0481d41a326d8ec7b0c8 (patch)
tree8948c584db95024236f799de2daa23930816ad86 /src/shared
parent1fcf71f562a83a59f853f982306fca7d009bb30d (diff)
timer: consider (usec_t) -1 an invalid timestamp
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/time-util.c4
-rw-r--r--src/shared/time-util.h5
2 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index b29d8c6e4e..55428c4ced 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -158,7 +158,7 @@ char *format_timestamp(char *buf, size_t l, usec_t t) {
assert(buf);
assert(l > 0);
- if (t <= 0)
+ if (t <= 0 || t == (usec_t) -1)
return NULL;
sec = (time_t) (t / USEC_PER_SEC);
@@ -176,7 +176,7 @@ char *format_timestamp_us(char *buf, size_t l, usec_t t) {
assert(buf);
assert(l > 0);
- if (t <= 0)
+ if (t <= 0 || t == (usec_t) -1)
return NULL;
sec = (time_t) (t / USEC_PER_SEC);
diff --git a/src/shared/time-util.h b/src/shared/time-util.h
index a51317dbd6..0a3a98b187 100644
--- a/src/shared/time-util.h
+++ b/src/shared/time-util.h
@@ -64,7 +64,10 @@ dual_timestamp* dual_timestamp_get(dual_timestamp *ts);
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);
dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u);
-#define dual_timestamp_is_set(ts) ((ts)->realtime > 0)
+static inline bool dual_timestamp_is_set(dual_timestamp *ts) {
+ return ((ts->realtime > 0 && ts->realtime != (usec_t) -1) ||
+ (ts->monotonic > 0 && ts->monotonic != (usec_t) -1));
+}
usec_t timespec_load(const struct timespec *ts) _pure_;
struct timespec *timespec_store(struct timespec *ts, usec_t u);