[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix printing of large device sizes

From: John Gilmore
Subject: Re: [PATCH] Fix printing of large device sizes
Date: Wed, 13 Oct 2004 02:08:12 -0700

> If you have a partition of over a terabyte, parted doesn't print the
> size correctly.  The attached patch from address@hidden fixes that
>               printf ("%10.3f %10.3f  ",
> -                     (int) part->geom.start * 1.0 / MEGABYTE_SECTORS,
> -                     (int) part->geom.end * 1.0 / MEGABYTE_SECTORS);
> +                     (unsigned int) part->geom.start * 1.0 / 
> +                     (unsigned int) part->geom.end * 1.0 / MEGABYTE_SECTORS);

Is this a joke?  A test to see if the maintainer is awake?

part->geom.start is of type PedSector, which is typedef'd to "long
long".  No wonder you get strange results if it holds a large number
and you cast it to an int.  That's a bug.

But casting it instead into an "unsigned int" is NOT a fix; that would
just break when your partition was TWO or THREE terabytes.  What kind of
programmers is Red Hat hiring these days?

The fix is not to cast it at all.  If you merely multiply a PedSector
times a double, the long long will get converted to double -- without
dropping any bits.

Or, you could just cast it to (double) and then merely divide by
MEGABYTE_SECTORS (skipping the useless multiply by 1.0).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]