summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index eabc36dc..7d5537fc 100644
--- a/utils.c
+++ b/utils.c
@@ -1672,6 +1672,13 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mod
size /= mult;
num_divs++;
}
+ /*
+ * If the value is smaller than base, we didn't do any
+ * division, in that case, base should be 1, not original
+ * base, or the unit will be wrong
+ */
+ if (num_divs == 0)
+ base = 1;
}
if (num_divs >= ARRAY_SIZE(unit_suffix_binary)) {