mirror of
https://github.com/systemd/systemd.git
synced 2026-08-11 01:25:28 +00:00
coredumpctl: use break instead of continue for time bound checks
When iterating journal entries with --until (forward scan) or --since (reverse scan), the code used continue instead of break after crossing the time boundary. Since sd_journal_seek_realtime_usec() is called before the loop to position at the start of the range, sd_journal_next()/previous() returns entries in monotonically increasing/decreasing time order. Once an entry's timestamp exceeds arg_until (or falls below arg_since in reverse), all subsequent entries will also be out of range. Using continue caused the entire remaining journal to be scanned unnecessarily. journalctl uses break for the identical pattern in src/journal/journalctl-show.c. Fixes: #42808 Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com> (cherry picked from commitbd1bb49ffa) (cherry picked from commit1f720ac2dd)
This commit is contained in:
committed by
Luca Boccassi
parent
613699b055
commit
007ef4ea89
@@ -949,7 +949,7 @@ static int dump_list(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to determine timestamp: %m");
|
||||
if (usec > arg_until)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (arg_since != USEC_INFINITY && arg_reverse) {
|
||||
@@ -959,7 +959,7 @@ static int dump_list(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to determine timestamp: %m");
|
||||
if (usec < arg_since)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
r = print_entry(j, n_found++, t);
|
||||
|
||||
Reference in New Issue
Block a user