Subject: Re: [PATCH 2] count-objects: add human-readable size option

From: Johannes Sixt <[email-masked]>
Date: Thu, 14 Aug 2008 09:39:46 +0200

Marcus Griep schrieb:
> +void human_readable_size(char *buf, int buf_size, double size /* in bytes */)
> +{
> +	char human_readable_prefixes[10] = "BKMGTPEZY";
> +	if (buf_size < 5)
> +		die("insufficient buffer size");
> +	int i = 0;
> +	for (; i < 8 && size >= 1000 ; ++i, size = size / 1024)
> +		;
> +	if (size >= 1000)
> +		die("size greater than 999Y");

No need to die here. Just make the buffer large enough, and you can have
something that is as large as 18446744073709551615Y.

-- Hannes