From 971f233fb7bc13f097cbc792fb70b96367a4840e Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 5 Nov 2007 17:13:54 +0000 Subject: [PATCH] attempt to fix human-readable unit output when number of sectors is odd --- lib/display/display.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/display/display.c b/lib/display/display.c index 9f9804f4f..9124187ca 100644 --- a/lib/display/display.c +++ b/lib/display/display.c @@ -186,17 +186,17 @@ static const char *_display_size(const struct cmd_context *cmd, return size_buf; } - if (s < 10) { + size *= UINT64_C(512); + + if (s < 10) byte = cmd->current_settings.unit_factor; - size *= UINT64_C(512); - } else { - size /= 2; + else { suffix = 1; if (cmd->current_settings.unit_type == 'H') units = UINT64_C(1000); else units = UINT64_C(1024); - byte = units * units * units * units * units; + byte = units * units * units * units * units * units; s = 0; while (size_str[s] && size < byte) s++, byte /= units;