[libblockdev 3/3] Omit cast based distinction and print all as floats

Vratislav Podzimek vpodzime at redhat.com
Thu Sep 4 07:26:57 UTC 2014


On Wed, 2014-09-03 at 11:41 -0400, mulhern wrote:
> It just seems wrong to claim that 16EiB - 1 is exactly
> 16EiB, which is what we claim when we leave off the decimal point,
> when it is only very close, i.e., within 1/100 of an EiB, easily.
> 
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
>  src/utils/sizes.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/utils/sizes.c b/src/utils/sizes.c
> index 91e2713..9a5ec49 100644
> --- a/src/utils/sizes.c
> +++ b/src/utils/sizes.c
> @@ -59,10 +59,7 @@ gchar* bd_utils_size_human_readable (guint64 size) {
>       * below are guaranteed to remain within bounds.
>       */
>  
> -    if (INT_EQ_FLOAT (value, (guint64) value))
> -        return g_strdup_printf ("%"G_GUINT64_FORMAT" %sB", (guint64) value, size_prefixes[i]);
> -    else
> -        return g_strdup_printf ("%.2f %sB", value, size_prefixes[i]);
> +    return g_strdup_printf ("%.2f %sB", value, size_prefixes[i]);
>  }
>  
NACK. We should keep the blivet's Size.humanReadable conventions which,
among the other things, implies showing integer values as integers not
floats. I you're really worried about 16 EiB - 1 (a value that I'm sure
can only appear in artificial test cases) being wrongly shown as 16 EiB,
then please find a better solution to the issue.

-- 
Vratislav Podzimek

Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic




More information about the anaconda-patches mailing list