Sorry to be a pain in the arse at this late stage of the patch, but
I've only just noticed.
On Wed, Jul 10, 2013 at 04:30:15PM +0200, David Sterba wrote:
> static char *size_strs[] = { "", "KB", "MB", "GB", "TB",
> - "PB", "EB", "ZB", "YB"};
> -char *pretty_sizes(u64 size)
> + "PB", "EB"};
These are SI (power of 10) prefixes...
> +void pretty_size_snprintf(u64 size, char *str, size_t str_bytes)
> {
> int num_divs = 0;
> - int pretty_len = 16;
> float fraction;
> - char *pretty;
> +
> + if (str_bytes == 0)
> + return;
>
> if( size < 1024 ){
> fraction = size;
> @@ -1172,13 +1173,13 @@ char *pretty_sizes(u64 size)
> num_divs ++;
> }
>
> - if (num_divs >= ARRAY_SIZE(size_strs))
> - return NULL;
> + if (num_divs >= ARRAY_SIZE(size_strs)) {
> + str[0] = '\0';
> + return;
> + }
> fraction = (float)last_size / 1024;
... and this is working in IEC (power of 2) units.
Can we fix this discrepancy, please? Also note that SI uses k for
10^3, but IEC uses K for 2^10. Just insert an "i" in the middle of
each element of size_strs should deal with the problem.
Hugo.
--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- Charting the inexorable advance of Western syphilisation... ---
Attachment:
signature.asc
Description: Digital signature
