[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1211364266.6463.76.camel@lappy.programming.kicks-ass.net>
Date: Wed, 21 May 2008 12:04:26 +0200
From: Peter Zijlstra <a.p.zijlstra@...llo.nl>
To: Peter Oberparleiter <peter.oberparleiter@...ibm.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Harvey Harrison <harvey.harrison@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] consolidate all within() implementations
>
> /**
> + * 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);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists