Bug 63250

Summary: Skipping backwards with matches is subtly broken
Product: systemd Reporter: Marius Vollmer <marius.vollmer>
Component: generalAssignee: systemd-bugs
Status: VERIFIED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: high    
Version: unspecified   
Hardware: Other   
OS: All   
i915 platform: i915 features:
Attachments: Fix typo.

Description Marius Vollmer 2013-04-08 08:21:17 UTC
Created attachment 77577 [details] [review]
Fix typo.

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.

For example:

  # journalctl PRIORITY=2
  <some output>
  # journalctl _PID=1
  <some other output>
  # journalctl PRIORITY=2 _PID=1


  # journalctl -n10 PRIORITY=2 _PID=1
  <one entry>

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.
Comment 1 Lennart Poettering 2013-04-08 09:08:25 UTC
Indeed! Applied! Thanks!
Comment 2 Marius Vollmer 2013-04-15 11:30:31 UTC

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.