On Tue, 2007-04-10 at 19:48 -0700, Andrew Morton wrote:
> On Wed, 11 Apr 2007 12:19:10 +1000 Rusty Russell <[EMAIL PROTECTED]> wrote:
> > > > + * Like val + len > limit, except with overflow checking.
> > > > + */
> > > > +static inline bool val_outside(unsigned long val, unsigned long len,
> > > > + unsigned long limit)
> > > > +
> > > > +{
> > > > + return val + len > limit || val + len < val;
> I probably shouldn't look at this after a glass of red, but otoh, perhaps
> that's a good way of ensuring that we have a built-in margin.
> I find this function incomprehensible. I'd just avoid using the sorry
> thing, personally.
No, you're absolutely right. Naming is vital, and something I criticise
others for regularly. We don't say "that is incomprehensible" anywhere
near often enough 8(
Is this clearer?
static inline bool range_over_limit(unsigned long start,
unsigned long len,
unsigned long limit)
{
return start + len > limit || start + len < start;
}
Cheers,
Rusty.
PS. Previously this identical function was called __range_ok() (and
returned 0 if it was not ok...)
-
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html