Message ID | 1341853347-11788-2-git-send-email-pierre@spotify.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
diff --git a/utils.c b/utils.c index aade9e2..dde0513 100644 --- a/utils.c +++ b/utils.c @@ -1108,13 +1108,20 @@ char *pretty_sizes(u64 size) size /= 1024; num_divs++; } - if (num_divs == 0) + if (num_divs == 0) { num_divs = 1; + fraction = (float)fract_size; + } else + fraction = (float)fract_size / 1024; + if (num_divs > ARRAY_SIZE(size_strs)) return NULL; - fraction = (float)fract_size / 1024; + pretty = malloc(pretty_len); + if (!pretty) + return NULL; + snprintf(pretty, pretty_len, "%.2f%s", fraction, size_strs[num_divs-1]); return pretty; }
Before, sizes below 1KB where displayed in KB, but without a unit. Signed-off-by: Pierre Carrier <pierre@spotify.com>