From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
stable@kernel.org
Subject: [PATCH] Fix roundup_pow_of_two(1)
Date: Thu, 17 May 2007 23:56:56 +0200 [thread overview]
Message-ID: <200705172356.57620.eike-kernel@sf-tec.de> (raw)
Fix roundup_pow_of_two(1)
1 is a power of two, therefore roundup_pow_of_two(1) should return 1. It does
in case the argument is a variable but in case it's a constant it behaves
wrong and returns 0. Probably nobody ever did it so this was never noticed.
Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
---
commit 01ceeffac83011f0b5021013cc4abd1c4f291df5
tree 7da59df51617d7cebd55e4361019181645a17e10
parent ab35916f807eb4f2019a208e96cb0bddbb91dfc3
author Rolf Eike Beer <eike-kernel@sf-tec.de> Thu, 17 May 2007 23:43:54 +0200
committer Rolf Eike Beer <eike-kernel@sf-tec.de> Thu, 17 May 2007 23:43:54 +0200
include/linux/log2.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/log2.h b/include/linux/log2.h
index 57e641e..1b8a2c1 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -159,7 +159,7 @@ unsigned long __roundup_pow_of_two(unsigned long n)
#define roundup_pow_of_two(n) \
( \
__builtin_constant_p(n) ? ( \
- (n == 1) ? 0 : \
+ (n == 1) ? 1 : \
(1UL << (ilog2((n) - 1) + 1)) \
) : \
__roundup_pow_of_two(n) \
next reply other threads:[~2007-05-18 8:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-17 21:56 Rolf Eike Beer [this message]
2007-06-04 11:49 ` [PATCH] Fix roundup_pow_of_two(1) Adrian Bunk
2007-06-04 12:13 ` Rolf Eike Beer
2007-06-04 13:17 ` Adrian Bunk
2007-06-04 12:33 ` Jiri Kosina
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=200705172356.57620.eike-kernel@sf-tec.de \
--to=eike-kernel@sf-tec.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@kernel.org \
--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