From: Nick Piggin <nickpiggin@yahoo.com.au>
To: "Robert P. J. Day" <rpjday@mindspring.com>
Cc: Linux kernel mailing list <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>, Paul Mackerras <paulus@samba.org>,
dhowells@redhat.com, galak@kernel.crashing.org
Subject: Re: [PATCH] Add "is_power_of_2" checking to log2.h.
Date: Wed, 31 Jan 2007 12:21:46 +1100 [thread overview]
Message-ID: <45BFEF2A.5070907@yahoo.com.au> (raw)
In-Reply-To: <Pine.LNX.4.64.0701300753170.23302@CPE00045a9c397f-CM001225dbafb6>
Robert P. J. Day wrote:
> On Tue, 30 Jan 2007, Nick Piggin wrote:
>
>
>>Robert P. J. Day wrote:
>>
>>> Add the inline function "is_power_of_2()" to log2.h, where the value
>>>zero is *not* considered to be a power of two.
>>
>>>Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
>>>
>>> /*
>>>+ * Determine whether some value is a power of two, where zero is
>>>+ * *not* considered a power of two.
>>>+ */
>>
>>Why the qualifier? Zero *is* not a power of 2, is it?
>
>
> no, but it bears repeating since some developers might think it *is*.
> if you peruse the current kernel code, you'll find some tests of the
> simpler form:
>
> ((n & (n - 1)) == 0))
>
> which is clearly testing for "power of twoness" but which will return
> true for a value of zero. that's wrong, and it's why it's emphasized
> in the comment.
I would have thought you'd comment the broken ones, but that's just me.
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
next prev parent reply other threads:[~2007-01-31 1:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-30 11:06 [PATCH] Add "is_power_of_2" checking to log2.h Robert P. J. Day
2007-01-30 12:25 ` Nick Piggin
2007-01-30 12:56 ` Robert P. J. Day
2007-01-30 14:12 ` Jan Engelhardt
2007-01-30 14:45 ` Robert P. J. Day
2007-01-30 15:50 ` Jan Engelhardt
2007-01-30 16:00 ` Robert P. J. Day
2007-06-11 23:11 ` H. Peter Anvin
2007-01-31 10:13 ` Vegard Nossum
2007-01-31 10:47 ` Robert P. J. Day
2007-01-31 1:21 ` Nick Piggin [this message]
2007-01-31 7:20 ` Robert P. J. Day
2007-02-01 10:41 ` David Howells
2007-02-01 10:43 ` David Howells
2007-02-01 10:49 ` Robert P. J. Day
2007-02-01 12:39 ` Tim Schmielau
2007-02-01 20:17 ` Valdis.Kletnieks
2007-02-01 21:55 ` Tim Schmielau
2007-02-20 15:29 ` Mariusz Kozlowski
2007-02-20 15:56 ` Kumar Gala
2007-02-20 16:14 ` Mariusz Kozlowski
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=45BFEF2A.5070907@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=akpm@osdl.org \
--cc=dhowells@redhat.com \
--cc=galak@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=rpjday@mindspring.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.