Before, sizes below 1KB where displayed in KB,
but without a unit.
Signed-off-by: Pierre Carrier <pierre@xxxxxxxxxxx>
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;
}
--
1.7.11.1
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html