Otherwise, if several matches already set, then the first seek to head
or tail may move the cursor to an invalid place, hence they provide
wrong ID(s). Also, reading journal after calling these function may
provide unexpected data.
Currently, the caller does not install any matches before calling the
functions, and does not read any journal entry after journal_get_boots()
succeeds or journal_find_boot_by_offset() succeeds with 0. Hence, this
should not change any behavior. Just for safety.
if (r < 0)
return r;
if (r == 0) {
+ sd_journal_flush_matches(j);
*ret = (BootId) {};
return 0; /* End of journal, yay. */
}
* (chronological) first boot in the journal. */
advance_older = offset <= 0;
+ sd_journal_flush_matches(j);
+
if (advance_older)
r = sd_journal_seek_tail(j); /* seek to newest */
else
assert(ret_boots);
assert(ret_n_boots);
+ sd_journal_flush_matches(j);
+
r = sd_journal_seek_head(j); /* seek to oldest */
if (r < 0)
return r;