This does what
404803e6caad2de2d8e74caab0b79ec3f030f801 did for the
monotonic timestamp getter, but for the realtime timestamp.
It also also makes the return value optional, exactly as for the
monotonic timestamp logic.
}
_public_ int sd_journal_get_realtime_usec(sd_journal *j, uint64_t *ret) {
- Object *o;
JournalFile *f;
+ Object *o;
int r;
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
- assert_return(ret, -EINVAL);
f = j->current_file;
if (!f)
return -EADDRNOTAVAIL;
-
if (f->current_offset <= 0)
return -EADDRNOTAVAIL;
if (r < 0)
return r;
- *ret = le64toh(o->entry.realtime);
+ uint64_t t = le64toh(o->entry.realtime);
+ if (!VALID_REALTIME(t))
+ return -EBADMSG;
+
+ if (ret)
+ *ret = t;
+
return 0;
}