linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: David Howells <dhowells@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	linux-arch@vger.kernel.org, randy.dunlap@oracle.com
Subject: Re: + expose-range-checking-functions-from-arch-specific.patch added to -mm tree
Date: Wed, 11 Apr 2007 11:24:52 -0700	[thread overview]
Message-ID: <20070411112452.6979414c.akpm@linux-foundation.org> (raw)
In-Reply-To: <14926.1176288559@redhat.com>

On Wed, 11 Apr 2007 11:49:19 +0100
David Howells <dhowells@redhat.com> wrote:

> Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > To me, "val_outside" means "true if the value is outside":
> > 
> > bool val_outside(val, start, len)
> > {
> > 	return val < start || val > (start+len-1);
> > }
> > 
> > that's what my function does.
> 
> Seconded.  Again, I would suggest calling it something like limit_check() or
> range_check().
> 

I suspect we would benefit from a proper suite of tools for comparing a
single number against a range, and for comparing ranges.  As you say, it's
something which we do an awful lot of, and we regularly get it wrong <looks
at a great pile of coverity-derived bugfixes.  It's like using time_after()
instead of open-coding it and then screwing it up.

But considerable thought, review and documentation would need to go into
that.  I'd then spend the next two years buried in cleanup patches <looks
at a great pile of ARRAY_SIZE and ROUND_UP patches>.

However Rusty's patch is merely a modest code consolidation.  And it's a
per-arch thing, which I suspect is inappropriate for a general
compare-a-number-with-a-range toolkit.  So I guess the above is out of
scope.

But I do thing we should continue to pile on about the val_outside() naming
and documentation ;)

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?

And the naming start, len, base, limit is hard to follow.  Wouldn't it be
better to have

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

or similar?

then we go on to 

bool range_overlaps(range1_start, range1_len, range2_start, range2_len)
bool range_wholly_less_than(lesser_range_start, lesser_range_len,
			greater_range_start, greater_range_len)

and on and on...


  reply	other threads:[~2007-04-11 18:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-06 21:27 + expose-range-checking-functions-from-arch-specific.patch added to -mm tree akpm
2007-04-10 10:17 ` David Howells
2007-04-11  2:19   ` Rusty Russell
2007-04-11  2:48     ` Andrew Morton
2007-04-11 10:49       ` David Howells
2007-04-11 18:24         ` Andrew Morton [this message]
2007-04-11 23:28           ` Rusty Russell
2007-04-12 16:05             ` + expose-range-checking-functions-from-arch-specific.patchadded " Luck, Tony
2007-04-13  0:08               ` Rusty Russell
2007-04-11 23:41           ` + expose-range-checking-functions-from-arch-specific.patch added " Rusty Russell
2007-04-12 10:47             ` David Howells
2007-04-12 14:51               ` Randy Dunlap
2007-04-12  7:42           ` Geert Uytterhoeven
2007-04-11 13:17       ` Rusty Russell
2007-04-11 17:03         ` David Howells
2007-04-11 18:31           ` Andrew Morton
2007-04-11 19:17             ` David Howells
2007-04-11 22:52           ` Rusty Russell
2007-04-12 10:49             ` David Howells
2007-04-11 10:47     ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070411112452.6979414c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=randy.dunlap@oracle.com \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).