mirror of
https://github.com/systemd/systemd.git
synced 2025-03-08 08:58:27 +03:00
journal: journal_file_next_entry() does not need pointer to current Object
The current offset is sufficient information.
This commit is contained in:
parent
7943f42275
commit
f534928ad7
@ -2003,7 +2003,7 @@ int journal_file_compare_locations(JournalFile *af, JournalFile *bf) {
|
||||
|
||||
int journal_file_next_entry(
|
||||
JournalFile *f,
|
||||
Object *o, uint64_t p,
|
||||
uint64_t p,
|
||||
direction_t direction,
|
||||
Object **ret, uint64_t *offset) {
|
||||
|
||||
@ -2011,18 +2011,14 @@ int journal_file_next_entry(
|
||||
int r;
|
||||
|
||||
assert(f);
|
||||
assert(p > 0 || !o);
|
||||
|
||||
n = le64toh(f->header->n_entries);
|
||||
if (n <= 0)
|
||||
return 0;
|
||||
|
||||
if (!o)
|
||||
if (p == 0)
|
||||
i = direction == DIRECTION_DOWN ? 0 : n - 1;
|
||||
else {
|
||||
if (o->object.type != OBJECT_ENTRY)
|
||||
return -EINVAL;
|
||||
|
||||
r = generic_array_bisect(f,
|
||||
le64toh(f->header->entry_array_offset),
|
||||
le64toh(f->header->n_entries),
|
||||
|
@ -199,7 +199,7 @@ int journal_file_find_field_object_with_hash(JournalFile *f, const void *field,
|
||||
void journal_file_reset_location(JournalFile *f);
|
||||
void journal_file_save_location(JournalFile *f, direction_t direction, Object *o, uint64_t offset);
|
||||
int journal_file_compare_locations(JournalFile *af, JournalFile *bf);
|
||||
int journal_file_next_entry(JournalFile *f, Object *o, uint64_t p, direction_t direction, Object **ret, uint64_t *offset);
|
||||
int journal_file_next_entry(JournalFile *f, uint64_t p, direction_t direction, Object **ret, uint64_t *offset);
|
||||
|
||||
int journal_file_next_entry_for_data(JournalFile *f, Object *o, uint64_t p, uint64_t data_offset, direction_t direction, Object **ret, uint64_t *offset);
|
||||
|
||||
|
@ -681,9 +681,9 @@ static int find_location_with_matches(
|
||||
/* No matches is simple */
|
||||
|
||||
if (j->current_location.type == LOCATION_HEAD)
|
||||
return journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, ret, offset);
|
||||
return journal_file_next_entry(f, 0, DIRECTION_DOWN, ret, offset);
|
||||
if (j->current_location.type == LOCATION_TAIL)
|
||||
return journal_file_next_entry(f, NULL, 0, DIRECTION_UP, ret, offset);
|
||||
return journal_file_next_entry(f, 0, DIRECTION_UP, ret, offset);
|
||||
if (j->current_location.seqnum_set && sd_id128_equal(j->current_location.seqnum_id, f->header->seqnum_id))
|
||||
return journal_file_move_to_entry_by_seqnum(f, j->current_location.seqnum, direction, ret, offset);
|
||||
if (j->current_location.monotonic_set) {
|
||||
@ -694,7 +694,7 @@ static int find_location_with_matches(
|
||||
if (j->current_location.realtime_set)
|
||||
return journal_file_move_to_entry_by_realtime(f, j->current_location.realtime, direction, ret, offset);
|
||||
|
||||
return journal_file_next_entry(f, NULL, 0, direction, ret, offset);
|
||||
return journal_file_next_entry(f, 0, direction, ret, offset);
|
||||
} else
|
||||
return find_location_for_match(j, j->level0, f, direction, ret, offset);
|
||||
}
|
||||
@ -706,7 +706,6 @@ static int next_with_matches(
|
||||
Object **ret,
|
||||
uint64_t *offset) {
|
||||
|
||||
Object *c;
|
||||
uint64_t cp;
|
||||
|
||||
assert(j);
|
||||
@ -714,13 +713,12 @@ static int next_with_matches(
|
||||
assert(ret);
|
||||
assert(offset);
|
||||
|
||||
c = *ret;
|
||||
cp = *offset;
|
||||
|
||||
/* No matches is easy. We simple advance the file
|
||||
* pointer by one. */
|
||||
if (!j->level0)
|
||||
return journal_file_next_entry(f, c, cp, direction, ret, offset);
|
||||
return journal_file_next_entry(f, cp, direction, ret, offset);
|
||||
|
||||
/* If we have a match then we look for the next matching entry
|
||||
* with an offset at least one step larger */
|
||||
|
@ -66,18 +66,18 @@ static void test_non_empty(void) {
|
||||
#endif
|
||||
journal_file_dump(f);
|
||||
|
||||
assert_se(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(journal_file_next_entry(f, 0, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(le64toh(o->entry.seqnum) == 1);
|
||||
|
||||
assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(journal_file_next_entry(f, p, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(le64toh(o->entry.seqnum) == 2);
|
||||
|
||||
assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(journal_file_next_entry(f, p, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(le64toh(o->entry.seqnum) == 3);
|
||||
|
||||
assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 0);
|
||||
assert_se(journal_file_next_entry(f, p, DIRECTION_DOWN, &o, &p) == 0);
|
||||
|
||||
assert_se(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(journal_file_next_entry(f, 0, DIRECTION_DOWN, &o, &p) == 1);
|
||||
assert_se(le64toh(o->entry.seqnum) == 1);
|
||||
|
||||
assert_se(journal_file_find_data_object(f, test, strlen(test), NULL, &p) == 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user