From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Harvey Harrison <harvey.harrison@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] consolidate all within() implementations
Date: Wed, 21 May 2008 12:04:26 +0200 [thread overview]
Message-ID: <1211364266.6463.76.camel@lappy.programming.kicks-ass.net> (raw)
In-Reply-To: <4832F14B.2060305@de.ibm.com>
>
> /**
> + * addr_within - check whether address is in start-and-end address range
> + * @addr: address
> + * @start: start address (included in range)
> + * @end: end address (excluded from range)
> + */
> +static inline int addr_within(const void *addr, const void *start,
> + const void *end)
> +{
> + return ((unsigned long) addr >= (unsigned long) start) &&
> + ((unsigned long) addr < (unsigned long) end);
> +}
> +
> +/**
> + * addr_within_len - check whether address is in start-and-length address range
> + * @addr: address
> + * @start: start of range
> + * @len: number of bytes in range
> + */
> +static inline int addr_within_len(const void *addr, const void *start,
> + size_t len)
> +{
> + return ((unsigned long) addr >= (unsigned long) start) &&
> + ((unsigned long) addr < ((unsigned long) start + len));
> +}
might be my braindamage, but I'd have written it like:
static inline int
addr_within_len(const void *addr, const void *start, size_t len)
{
return (unsigned long)addr - (unsigned long)start < len;
}
static inline int
addr_within(const void *add, const void *start, const void *end)
{
return addr_within_len(addr, start,
(unsigned long)end - (unsigned long)start);
}
next prev parent reply other threads:[~2008-05-21 10:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-19 8:45 [PATCH] consolidate all within() implementations Peter Oberparleiter
2008-05-19 20:50 ` Harvey Harrison
2008-05-20 8:08 ` Peter Oberparleiter
2008-05-20 9:45 ` Andrew Morton
2008-05-20 15:42 ` Peter Oberparleiter
2008-05-21 10:04 ` Peter Zijlstra [this message]
2008-05-21 10:33 ` Peter 1 Oberparleiter
2008-05-21 10:48 ` Peter Zijlstra
2008-05-21 13:50 ` Peter 1 Oberparleiter
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=1211364266.6463.76.camel@lappy.programming.kicks-ass.net \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=harvey.harrison@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.oberparleiter@de.ibm.com \
/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