Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Feb 2011 23:12:03 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Bruce Cran <bruce@cran.org.uk>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Bruce Evans <brde@optusnet.com.au>
Subject:   Re: svn commit: r218966 - head/sys/vm
Message-ID:  <20110227230553.N10085@besplex.bde.org>
In-Reply-To: <1298800011.24317.7.camel@core.nessbank>
References:  <201102231028.p1NASbET045275@svn.freebsd.org>  <20110224063233.Y1100@besplex.bde.org> <1298499116.9366.3.camel@core.nessbank> <20110224102112.P1871@besplex.bde.org> <1298800011.24317.7.camel@core.nessbank>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 27 Feb 2011, Bruce Cran wrote:

> On Thu, 2011-02-24 at 10:36 +1100, Bruce Evans wrote:
>>
>> I would cast operand(s) in the expression as necessary to prevent overflow
>> of subexpressions.  vm_pindex_t would work, but I prefer to use a type
>> related to the subexpressions.  Not sure what that is.  Maybe just
>> uintmax_t for safety (even that is not safe if the subexpressions have
>> large values).  So:
>>
>>      (uintmax_t)swap_bcount * SWAP_META_PAGES * n / mumble.
>
> Following Alan's suggestion, I've attached an updated patch which uses a
> cast to u_long and returns long.

I thought he only meant to return long.  The units being returned are
PAGE_SIZE smaller than the units in the expression.  But I don't know
exacty how large swp_bcount can be.  If everything fits in a single
object, then vm_size_t = u_int on 32-bit machines is enough.

Bruce



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