Created attachment 77577 [details] [review]
I think it's just a typo, check the attached patch.
Sometimes, skipping backwards with a match that yields the empty set will not return 0, but will successfully skip the requested number of items. The next call to sd_journal_next will then correctly return 0.
To reproduce, find two matches that are independently non-empty, but whose intersection is empty, and then use them with "journalctl -n10" or similar.
# journalctl PRIORITY=2
# journalctl _PID=1
<some other output>
# journalctl PRIORITY=2 _PID=1
# journalctl -n10 PRIORITY=2 _PID=1
You might need to swap the match expressions:
# journalctl -n10 _PID=1 PRIORITY=2
As mentioned, I think this is just a typo in next_for_match for the DIRECTION_UP case. The attached patch seems to fix all incorrect behavior that I could find.
Indeed! Applied! Thanks!