diff options
-rw-r--r-- | src/journal/journal-file.c | 8 | ||||
-rw-r--r-- | src/journal/journal-file.h | 2 | ||||
-rw-r--r-- | src/journal/sd-journal.c | 10 | ||||
-rw-r--r-- | src/journal/test-journal.c | 10 |
4 files changed, 12 insertions, 18 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 35f3ea92a4..fec54f31b9 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -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), diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h index 561982fe39..01bb4e038a 100644 --- a/src/journal/journal-file.h +++ b/src/journal/journal-file.h @@ -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); diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 0fefe2bc6e..bcd39be35e 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -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 */ diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c index 29d5877986..230d26596a 100644 --- a/src/journal/test-journal.c +++ b/src/journal/test-journal.c @@ -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); |