Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 May 2011 12:26:52 -0500 (CDT)
From:      Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
To:        Rick Macklem <rmacklem@uoguelph.ca>
Cc:        rmacklem@freebsd.org, fs@freebsd.org
Subject:   Re: newnfs client and statfs
Message-ID:  <alpine.GSO.2.01.1105011215510.20825@freddy.simplesystems.org>
In-Reply-To: <1211771823.830180.1304268292625.JavaMail.root@erie.cs.uoguelph.ca>
References:  <1211771823.830180.1304268292625.JavaMail.root@erie.cs.uoguelph.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 1 May 2011, Rick Macklem wrote:
>
> Or should I try and do the division to see if the large
> value in sf_abytes will fit in INT64_MAX after the division? Something
> like:
>  int64_t tmp;
>
>  tmp = sfp->sf_abytes;
>  tmp /= NFS_FABLKSIZE;
>  if (tmp < 0)
>     sbp->f_bavail = INT64_MAX;
>  else
>     sbp->f_bavail = tmp;

That one seems better because it preserves more of the value, but 
perhaps this is better because it does not depend on 
undocumented/undefined behavior (also untested):

   uint64_t tmp;
   tmp = sfp->sf_abytes / NFS_FABLKSIZE;
   if (tmp > (uint64_t) INT64_MAX)
     sbp->f_bavail = INT64_MAX;
   else
     sbp->f_bavail = tmp;

Bob
-- 
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.GSO.2.01.1105011215510.20825>