shared/format-table: print BPS with part after point

Fixes https://github.com/systemd/systemd/issues/33076.
"2Gbps" → "2.5Gbps".
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2024-05-29 18:09:48 +02:00
parent 11226bf19b
commit 12080b1f7d
2 changed files with 9 additions and 9 deletions

View file

@ -1712,7 +1712,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
if (!p)
return NULL;
if (!format_bytes_full(p, FORMAT_BYTES_MAX, d->size, 0))
if (!format_bytes_full(p, FORMAT_BYTES_MAX, d->size, FORMAT_BYTES_BELOW_POINT))
return table_ersatz_string(t);
n = strlen(p);

View file

@ -650,14 +650,14 @@ TEST(table_bps) {
printf("%s", formatted);
assert_se(streq(formatted,
"UINT64 SIZE BPS\n"
"2500 2.4K 2Kbps\n"
"10000000 9.5M 10Mbps\n"
"20000000 19M 20Mbps\n"
"25000000 23.8M 25Mbps\n"
"1000000000 953.6M 1Gbps\n"
"2000000000 1.8G 2Gbps\n"
"2500000000 2.3G 2Gbps\n"
"UINT64 SIZE BPS\n"
"2500 2.4K 2.5Kbps\n"
"10000000 9.5M 10Mbps\n"
"20000000 19M 20Mbps\n"
"25000000 23.8M 25Mbps\n"
"1000000000 953.6M 1Gbps\n"
"2000000000 1.8G 2Gbps\n"
"2500000000 2.3G 2.5Gbps\n"
));
}