On Wed, 2007-04-11 at 11:24 -0700, Andrew Morton wrote:
> Also, as a start on the generic range-checking toolkit I'd suggest that
> range_within() should be implemented in linux/range.h, not in
> linux/kernel.h.
> 
> range_within() isn't terribly well documented.  Does it return true only if
> range1 is wholly within range2?  What if the two overlap?  What are the
> boundary cases?

Actually, I think it's brilliantly documented.  Defining base as the
first valid value and limit as the first invalid value makes it pretty
clear, IMHO.

Anyway, I just want range_under_limit(start, len, limit).  Beyond that
gets confusing.  See below.

> bool range_within(unsigned long outer_range_start,
>               unsigned long outer_range_len,
>               unsigned long inner_range_start,
>               unsigned long inner_range_len)

This *is* nicer, because noone will get confused about whether limit is
inclusive or exclusive.  I think the outer and inner arg order should be
swapped.

> bool range_overlaps(range1_start, range1_len, range2_start, range2_len)

I assume this means "range1 intersects range2"?

> bool range_wholly_less_than(lesser_range_start, lesser_range_len,
>                       greater_range_start, greater_range_len)

This means "lesser range does not intersect greater range, and is closer
to 0"?

In which case, the greater_range_len seems redundant, but isn't (because
greater_range_len could make the range wrap)?

Erk,
Rusty.

-
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

Reply via email to