chiark / gitweb /
journalctl: fix verbose output when no logs are found
[elogind.git] / src / journal / journalctl.c
index 2e672fa09655fb93dd26774c5acb6b73ebfc5e49..de972a17dbe0b385f44bee421f44d86a5623bbc2 100644 (file)
@@ -591,33 +591,10 @@ static int add_matches(sd_journal *j, char **args) {
 }
 
 static int add_this_boot(sd_journal *j) {
-        char match[9+32+1] = "_BOOT_ID=";
-        sd_id128_t boot_id;
-        int r;
-
-        assert(j);
-
         if (!arg_this_boot)
                 return 0;
 
-        r = sd_id128_get_boot(&boot_id);
-        if (r < 0) {
-                log_error("Failed to get boot id: %s", strerror(-r));
-                return r;
-        }
-
-        sd_id128_to_string(boot_id, match + 9);
-        r = sd_journal_add_match(j, match, strlen(match));
-        if (r < 0) {
-                log_error("Failed to add match: %s", strerror(-r));
-                return r;
-        }
-
-        r = sd_journal_add_conjunction(j);
-        if (r < 0)
-                return r;
-
-        return 0;
+        return add_match_this_boot(j);
 }
 
 static int add_dmesg(sd_journal *j) {
@@ -1311,11 +1288,10 @@ int main(int argc, char *argv[]) {
                                         log_error("Failed to iterate through journal: %s", strerror(-r));
                                         goto finish;
                                 }
+                                if (r == 0)
+                                        break;
                         }
 
-                        if (r == 0)
-                                break;
-
                         if (arg_until_set && !arg_reverse) {
                                 usec_t usec;
 
@@ -1361,10 +1337,12 @@ int main(int argc, char *argv[]) {
                                 arg_catalog * OUTPUT_CATALOG;
 
                         r = output_journal(stdout, j, arg_output, 0, flags);
-                        if (r < 0 || ferror(stdout))
+                        need_seek = true;
+                        if (r == -EADDRNOTAVAIL)
+                                break;
+                        else if (r < 0 || ferror(stdout))
                                 goto finish;
 
-                        need_seek = true;
                         n_shown++;
                 }