human-readable swap partition sizes with pstat -sh

Giorgos Keramidas keramida at freebsd.org
Thu Jan 6 12:46:35 PST 2005


On 2005-01-06 12:07, Brooks Davis <brooks at one-eyed-alien.net> wrote:
> On Thu, Jan 06, 2005 at 09:59:50PM +0200, Giorgos Keramidas wrote:
> > > On minor, mostly style nit is that while intmax_t is 64-bits, nothing
> > > requires that so you should probably have conver return an int64_t.
> >
> > I lost you a bit here.
>
> The CONVERT macro used to case to (int).  You removed that cast which
> works because humanize_number takes an int64_t and intmax_t is the same
> as int64_t on all architectures.  I was suggesting that you should case
> to int64_t.  Alternativly, humanize_number could be fixed.  I can't
> think of any useful reason to add the complexity of 128-bit ints to
> general purpose CPUs so this is probalby mostly paranoia.

Ah, I see now.  I didn't like the explicit cast to (int) because
significant bits may be lost if sizeof(int) < sizeof(intmax_t)
(which is true on all the architectures FreeBSD runs on now, IIRC).

Adding an (int64_t) cast won't avoid the possibility of having problems
later on when intmax_t is larger than int64_t, but you are 100% right :-)

- Giorgos



More information about the freebsd-current mailing list