Skip to content

Commit

Permalink
Fix roundup_pow_of_two(1)
Browse files Browse the repository at this point in the history
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: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rolf Eike Beer authored and Linus Torvalds committed May 19, 2007
1 parent 18963c0 commit 1a06a52
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/log2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 1a06a52

Please sign in to comment.