]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal/journalctl.c
hostname-util: get rid of unused parameter of hostname_cleanup()
[thirdparty/systemd.git] / src / journal / journalctl.c
index bbc42583c954c3382ddacb75d9bfc6ed7f9ecffe..d2c0a03ccb52dabc11b965ac0dea45074d031cfe 100644 (file)
@@ -852,6 +852,15 @@ static int add_matches(sd_journal *j, char **args) {
         return 0;
 }
 
+static void boot_id_free_all(BootId *l) {
+
+        while (l) {
+                BootId *i = l;
+                LIST_REMOVE(boot_list, l, i);
+                free(i);
+        }
+}
+
 static int discover_next_boot(
                 sd_journal *j,
                 BootId **boot,
@@ -929,6 +938,7 @@ static int discover_next_boot(
 
         *boot = next_boot;
         next_boot = NULL;
+
         return 0;
 }
 
@@ -1000,9 +1010,7 @@ static int get_boots(
 
                 r = discover_next_boot(j, &current, advance_older, !query_ref_boot);
                 if (r < 0) {
-                        BootId *id, *id_next;
-                        LIST_FOREACH_SAFE(boot_list, id, id_next, head)
-                                free(id);
+                        boot_id_free_all(head);
                         return r;
                 }
 
@@ -1038,7 +1046,7 @@ finish:
 
 static int list_boots(sd_journal *j) {
         int w, i, count;
-        BootId *id, *id_next, *all_ids;
+        BootId *id, *all_ids;
 
         assert(j);
 
@@ -1054,7 +1062,7 @@ static int list_boots(sd_journal *j) {
         w = DECIMAL_STR_WIDTH(count - 1) + 1;
 
         i = 0;
-        LIST_FOREACH_SAFE(boot_list, id, id_next, all_ids) {
+        LIST_FOREACH(boot_list, id, all_ids) {
                 char a[FORMAT_TIMESTAMP_MAX], b[FORMAT_TIMESTAMP_MAX];
 
                 printf("% *i " SD_ID128_FORMAT_STR " %s—%s\n",
@@ -1063,9 +1071,10 @@ static int list_boots(sd_journal *j) {
                        format_timestamp_maybe_utc(a, sizeof(a), id->first),
                        format_timestamp_maybe_utc(b, sizeof(b), id->last));
                 i++;
-                free(id);
         }
 
+        boot_id_free_all(all_ids);
+
         return 0;
 }
 
@@ -1518,7 +1527,7 @@ static int setup_keys(void) {
                 hn = gethostname_malloc();
 
                 if (hn) {
-                        hostname_cleanup(hn, false);
+                        hostname_cleanup(hn);
                         fprintf(stderr, "\nThe keys have been generated for host %s/" SD_ID128_FORMAT_STR ".\n", hn, SD_ID128_FORMAT_VAL(machine));
                 } else
                         fprintf(stderr, "\nThe keys have been generated for host " SD_ID128_FORMAT_STR ".\n", SD_ID128_FORMAT_VAL(machine));
@@ -1710,7 +1719,7 @@ static int access_check(sd_journal *j) {
 
 static int flush_to_var(void) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_close_ int watch_fd = -1;
         int r;
 
@@ -2057,6 +2066,10 @@ int main(int argc, char *argv[]) {
                 log_error_errno(r, "Failed to iterate through journal: %m");
                 goto finish;
         }
+        if (r == 0) {
+                printf("-- No entries --\n");
+                goto finish;
+        }
 
         if (!arg_follow)
                 pager_open_if_enabled();