]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredumpctl: use break instead of continue for time bound checks
authordongshengyuan <545258830@qq.com>
Tue, 30 Jun 2026 10:10:49 +0000 (18:10 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 2 Jul 2026 16:46:39 +0000 (18:46 +0200)
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>
src/coredump/coredumpctl.c

index 9b26e23d629303877d3383feb5a9e0590a5d6a87..c13cfa1cce13635192714b5505df3c33e74ea88a 100644 (file)
@@ -1076,7 +1076,7 @@ static int verb_dump_list(int argc, char *argv[], uintptr_t _data, void *userdat
                                 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) {
@@ -1086,7 +1086,7 @@ static int verb_dump_list(int argc, char *argv[], uintptr_t _data, void *userdat
                                 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);