diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2022-07-05 15:22:01 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-05 22:13:40 +0200 |
commit | 977ad21b5b8f6323515297bd8995dcaaca0905df (patch) | |
tree | 746777b77219ae5a9a71c75fe5223f1a9b158f73 /src/libsystemd/sd-journal | |
parent | docs: normalize uppercasing of titles of network doc (diff) | |
download | systemd-977ad21b5b8f6323515297bd8995dcaaca0905df.tar.xz systemd-977ad21b5b8f6323515297bd8995dcaaca0905df.zip |
journal: Make sd_journal_previous/next() return 0 at HEAD/TAIL
Currently, both these functions don't return 0 if we're at HEAD/TAIL
and move in the corresponding direction. Let's fix that.
Replaces #23480
Diffstat (limited to 'src/libsystemd/sd-journal')
-rw-r--r-- | src/libsystemd/sd-journal/sd-journal.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c index 60e352022f..3318f9217d 100644 --- a/src/libsystemd/sd-journal/sd-journal.c +++ b/src/libsystemd/sd-journal/sd-journal.c @@ -607,9 +607,9 @@ static int find_location_for_match( /* FIXME: missing: find by monotonic */ if (j->current_location.type == LOCATION_HEAD) - return journal_file_next_entry_for_data(f, d, DIRECTION_DOWN, ret, offset); + return direction == DIRECTION_DOWN ? journal_file_next_entry_for_data(f, d, DIRECTION_DOWN, ret, offset) : 0; if (j->current_location.type == LOCATION_TAIL) - return journal_file_next_entry_for_data(f, d, DIRECTION_UP, ret, offset); + return direction == DIRECTION_UP ? journal_file_next_entry_for_data(f, d, DIRECTION_UP, ret, offset) : 0; 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_for_data(f, d, j->current_location.seqnum, direction, ret, offset); if (j->current_location.monotonic_set) { @@ -702,9 +702,9 @@ static int find_location_with_matches( /* No matches is simple */ if (j->current_location.type == LOCATION_HEAD) - return journal_file_next_entry(f, 0, DIRECTION_DOWN, ret, offset); + return direction == DIRECTION_DOWN ? journal_file_next_entry(f, 0, DIRECTION_DOWN, ret, offset) : 0; if (j->current_location.type == LOCATION_TAIL) - return journal_file_next_entry(f, 0, DIRECTION_UP, ret, offset); + return direction == DIRECTION_UP ? journal_file_next_entry(f, 0, DIRECTION_UP, ret, offset) : 0; 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) { |