Bug 63250 - Skipping backwards with matches is subtly broken
Summary: Skipping backwards with matches is subtly broken
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: high normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
Depends on:
Reported: 2013-04-08 08:21 UTC by Marius Vollmer
Modified: 2013-04-15 11:30 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

Fix typo. (1.02 KB, patch)
2013-04-08 08:21 UTC, Marius Vollmer
Details | Splinter Review

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.