Date: Sun, 1 May 2011 16:47:02 -0400 (EDT) From: Rick Macklem <rmacklem@uoguelph.ca> To: Bob Friesenhahn <bfriesen@simple.dallas.tx.us> Cc: rmacklem@freebsd.org, fs@freebsd.org Subject: Re: newnfs client and statfs Message-ID: <956418604.835643.1304282822974.JavaMail.root@erie.cs.uoguelph.ca> In-Reply-To: <alpine.GSO.2.01.1105011215510.20825@freddy.simplesystems.org>
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; > That's basically what I went with for the updated patch, except I didn't put in the "if (tmp > (uint64_t) INT64_MAX)" since once you divide sf_abytes by 2 or more it is guaranteed to be less than or equal INT64_MAX. rick
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?956418604.835643.1304282822974.JavaMail.root>