On Tue, Apr 01, 2003 at 12:11:46PM +0100, Hugh Dickins wrote:
> On 1 Apr 2003, Xavier Bestel wrote:
> > size = memparse(value,&rest);
> > + if (*rest == '%') {
> > + struct sysinfo si;
> > + si_meminfo(&si);
> > + size = (si.totalram << PAGE_CACHE_SHIFT) / 100 * size;
> >
> > (si.totalram << PAGE_CACHE_SHIFT) * size / 100;
> > would have been better precision-wise.
>
> Hardly, it'll overflow in even more cases
> than CaT's (si.totalram << PAGE_CACHE_SHIFT).
Yes. I had it initially as Xavier suggested but after thinking about it
a bit I felt that making the value smaller and -then- bigger was safer.
> I'll take a look at this later, not right now.
It is still an unsigned long long int so (AFAIK) it wont overflow till
it hits 18,446,744,073,709,551,615. Now... if you have that much ram...
wow! :)
Basically it'll only overflow for astoundingly stupid values of size and
when it comes down to it, I think you could still make it overflow by
setting a REALLY large static value for size anyways (liek greater then
the above). Same issue as far as I can see.
-- "Other countries of course, bear the same risk. But there's no doubt his hatred is mainly directed at us. After all this is the guy who tried to kill my dad." - George W. Bush Jr, Leader of the United States Regime September 26, 2002 (from a political fundraiser in Houston, Texas) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Mon Apr 07 2003 - 22:00:13 EST