journal: modernize sd_journal_get_realtime_usec() a bit
This does what 404803e6ca 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.
This commit is contained in:
committed by
Luca Boccassi
parent
bccad0584e
commit
834f759c49
@@ -2164,18 +2164,16 @@ _public_ void sd_journal_close(sd_journal *j) {
|
||||
}
|
||||
|
||||
_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;
|
||||
|
||||
@@ -2183,7 +2181,13 @@ _public_ int sd_journal_get_realtime_usec(sd_journal *j, uint64_t *ret) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user