mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
Fix display alignment of zero.
This commit is contained in:
parent
457a47f19f
commit
28879d4174
@ -101,11 +101,12 @@ char *display_size(uint64_t size, size_len_t sl)
|
|||||||
ulong byte = 1024 * 1024 * 1024;
|
ulong byte = 1024 * 1024 * 1024;
|
||||||
char *size_buf = NULL;
|
char *size_buf = NULL;
|
||||||
char *size_str[][2] = {
|
char *size_str[][2] = {
|
||||||
{"Terabyte", "TB"},
|
{" Terabyte", "TB"},
|
||||||
{"Gigabyte", "GB"},
|
{" Gigabyte", "GB"},
|
||||||
{"Megabyte", "MB"},
|
{" Megabyte", "MB"},
|
||||||
{"Kilobyte", "KB"},
|
{" Kilobyte", "KB"},
|
||||||
{"", ""}
|
{"", ""},
|
||||||
|
{" ", " "}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(size_buf = dbg_malloc(SIZE_BUF))) {
|
if (!(size_buf = dbg_malloc(SIZE_BUF))) {
|
||||||
@ -114,13 +115,13 @@ char *display_size(uint64_t size, size_len_t sl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size == 0LL)
|
if (size == 0LL)
|
||||||
sprintf(size_buf, "0");
|
sprintf(size_buf, "0%s", size_str[5][sl]);
|
||||||
else {
|
else {
|
||||||
s = 0;
|
s = 0;
|
||||||
while (size_str[s] && size < byte)
|
while (size_str[s] && size < byte)
|
||||||
s++, byte /= 1024;
|
s++, byte /= 1024;
|
||||||
snprintf(size_buf, SIZE_BUF - 1,
|
snprintf(size_buf, SIZE_BUF - 1,
|
||||||
"%.2f %s", (float) size / byte, size_str[s][sl]);
|
"%.2f%s", (float) size / byte, size_str[s][sl]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Caller to deallocate */
|
/* Caller to deallocate */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user