]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logs-show: use sd_journal_step_one()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 23 Sep 2023 18:31:14 +0000 (03:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Sep 2023 04:26:22 +0000 (13:26 +0900)
src/shared/logs-show.c

index 6cd376b0a1191001cc72d09394f284823019e302..0130e747bf477a4761f74d9997dcc6f90c7d9746 100644 (file)
@@ -1852,13 +1852,10 @@ static int discover_next_boot(
         sd_journal_flush_matches(j);
 
         do {
-                if (advance_older)
-                        r = sd_journal_previous(j);
-                else
-                        r = sd_journal_next(j);
+                r = sd_journal_step_one(j, !advance_older);
                 if (r < 0)
                         return r;
-                else if (r == 0) {
+                if (r == 0) {
                         *ret = (BootId) {};
                         return 0; /* End of journal, yay. */
                 }
@@ -1893,13 +1890,10 @@ static int discover_next_boot(
         if (r < 0)
                 return r;
 
-        if (advance_older)
-                r = sd_journal_next(j);
-        else
-                r = sd_journal_previous(j);
+        r = sd_journal_step_one(j, advance_older);
         if (r < 0)
                 return r;
-        else if (r == 0)
+        if (r == 0)
                 return log_debug_errno(SYNTHETIC_ERRNO(ENODATA),
                                        "Whoopsie! We found a boot ID but can't read its last entry."); /* This shouldn't happen. We just came from this very boot ID. */