]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machinectl: do not format size if freed disk space is "-1"
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Mar 2019 03:51:51 +0000 (12:51 +0900)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 Mar 2019 13:04:16 +0000 (14:04 +0100)
Closes #11941.

src/machine/machinectl.c

index 30f2e26a1e8cf89f897628d4ca6cad6c0b1fd502..8b97b4d8cef02248f382963a80c67a77fe0b8964 100644 (file)
@@ -2666,10 +2666,15 @@ static int clean_images(int argc, char *argv[], void *userdata) {
                 return bus_log_parse_error(r);
 
         while ((r = sd_bus_message_read(reply, "(st)", &name, &usage)) > 0) {
-                log_info("Removed image '%s'. Freed exclusive disk space: %s",
-                         name, format_bytes(fb, sizeof(fb), usage));
-
-                total += usage;
+                if (usage == UINT64_MAX) {
+                        log_info("Removed image '%s'", name);
+                        total = UINT64_MAX;
+                } else {
+                        log_info("Removed image '%s'. Freed exclusive disk space: %s",
+                                 name, format_bytes(fb, sizeof(fb), usage));
+                        if (total != UINT64_MAX)
+                                total += usage;
+                }
                 c++;
         }
 
@@ -2677,8 +2682,11 @@ static int clean_images(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return bus_log_parse_error(r);
 
-        log_info("Removed %u images in total. Total freed exclusive disk space %s.",
-                 c, format_bytes(fb, sizeof(fb), total));
+        if (total == UINT64_MAX)
+                log_info("Removed %u images in total.", c);
+        else
+                log_info("Removed %u images in total. Total freed exclusive disk space: %s.",
+                         c, format_bytes(fb, sizeof(fb), total));
 
         return 0;
 }