chiark / gitweb /
timer: consider (usec_t) -1 an invalid timestamp
authorLennart Poettering <lennart@poettering.net>
Mon, 11 Nov 2013 02:03:17 +0000 (03:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 Nov 2013 14:54:42 +0000 (15:54 +0100)
TODO
src/shared/time-util.c
src/shared/time-util.h

diff --git a/TODO b/TODO
index fe5d2f5882e1528451634b4b9d4e43bfaf398038..efc7e2a1eb7d1859cdb9c31302f6962f26ccbf16 100644 (file)
--- a/TODO
+++ b/TODO
@@ -43,6 +43,8 @@ CGroup Rework Completion:
 
 Features:
 
+* be more careful what we export on the bus as (usec_t) 0 and (usec_t) -1
+
 * check :no-sender logic after PID 1 conversion
 
 * increase journal files by a few MB each time, instead of piecemeal
index b29d8c6e4ee710cbba2e3e4512786001ea7c2eb6..55428c4ced93cd9a6a5ae37f37d56137c5053c71 100644 (file)
@@ -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);
index a51317dbd6a037f79e86767e669f4cbb19b215be..0a3a98b1879f2b4b4427034f7916e1275167faaa 100644 (file)
@@ -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);