From: David Howells <dhowells@redhat.com>
To: torvalds@linux-foundation.org, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>,
"Robert P. J. Day" <rpjday@crashcourse.ca>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] Fix order_base_2(0)
Date: Wed, 14 Dec 2011 11:40:17 +0000 [thread overview]
Message-ID: <20111214114016.9441.12006.stgit@warthog.procyon.org.uk> (raw)
The order_base_2() function is either wrongly documented or wrongly
implemented. In the preceding comment, it says that:
ob2(0) = 0
but this is not valid as roundup_pow_of_two()'s documentation asserts that:
* - the result is undefined when n == 0
Fix order_base_2(n) to actually return 0 when n == 0.
However, should we just instead define that the result of order_base_2(0) is
undefined?
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Robert P. J. Day <rpjday@crashcourse.ca>
cc: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/log2.h | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/include/linux/log2.h b/include/linux/log2.h
index fd7ff3d..d6463d8 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -202,7 +202,6 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
* ob2(5) = 3
* ... and so on.
*/
-
-#define order_base_2(n) ilog2(roundup_pow_of_two(n))
+#define order_base_2(n) ((n) == 0 ? 0 : ilog2(roundup_pow_of_two(n)))
#endif /* _LINUX_LOG2_H */
next reply other threads:[~2011-12-14 11:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 11:40 David Howells [this message]
2011-12-14 23:55 ` Linus Torvalds
2011-12-15 0:33 ` David Howells
2011-12-18 7:15 ` Milton Miller
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=20111214114016.9441.12006.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpjday@crashcourse.ca \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®