Skip to content

Commit

Permalink
machinectl: do not format size if freed disk space is "-1"
Browse files Browse the repository at this point in the history
Closes #11941.
  • Loading branch information
yuwata authored and poettering committed Mar 11, 2019
1 parent a289dfd commit 3a6797f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/machine/machinectl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2666,19 +2666,27 @@ 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++;
}

r = sd_bus_message_exit_container(reply);
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;
}
Expand Down

0 comments on commit 3a6797f

Please sign in to comment.