[patch 34/54] Fix roundup_pow_of_two(1)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Chris Wright
Date: Friday, June 8, 2007 - 12:22 am

-stable review patch.  If anyone has any objections, please let us know.
---------------------

From: Rolf Eike Beer <eike-kernel@sf-tec.de>

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>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---

 include/linux/log2.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.21.4.orig/include/linux/log2.h
+++ linux-2.6.21.4/include/linux/log2.h
@@ -159,7 +159,7 @@ unsigned long __roundup_pow_of_two(unsig
 #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)			\

-- 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 34/54] Fix roundup_pow_of_two(1), Chris Wright, (Fri Jun 8, 12:22 am)
Re: [patch 34/54] Fix roundup_pow_of_two(1), Theodore Tso, (Fri Jun 8, 1:19 am)
Re: [patch 34/54] Fix roundup_pow_of_two(1), Chris Wright, (Fri Jun 8, 11:23 am)
Re: [patch 34/54] Fix roundup_pow_of_two(1), Rolf Eike Beer, (Mon Jun 11, 12:38 am)