2007-06-08 07:48:46

by Chris Wright

[permalink] [raw]
Subject: [patch 34/54] Fix roundup_pow_of_two(1)

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

From: Rolf Eike Beer <[email protected]>

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 <[email protected]>
Signed-off-by: Chris Wright <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---

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) \

--


2007-06-08 08:20:32

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [patch 34/54] Fix roundup_pow_of_two(1)

On Fri, Jun 08, 2007 at 12:22:01AM -0700, Chris Wright wrote:
> -stable review patch. If anyone has any objections, please let us know.
> ---------------------
>
> From: Rolf Eike Beer <[email protected]>
>
> 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.

If this doesn't fix a user-visiable bug, should we be including it in
the stable patch series? (Assuming that it doesn't, I wouldn't, but I
tend to be more conservative about what I would include in a stable
production release.)

Regards,

- Ted

2007-06-08 18:25:08

by Chris Wright

[permalink] [raw]
Subject: Re: [patch 34/54] Fix roundup_pow_of_two(1)

* Theodore Tso ([email protected]) wrote:
> If this doesn't fix a user-visiable bug, should we be including it in
> the stable patch series? (Assuming that it doesn't, I wouldn't, but I
> tend to be more conservative about what I would include in a stable
> production release.)

Rolf, despite simplicity of patch, I'm inclined to agree with Ted.
Were you effected by this in the wild, or just noticed by code
inspection?

thanks,
-chris

2007-06-11 07:38:21

by Rolf Eike Beer

[permalink] [raw]
Subject: Re: [patch 34/54] Fix roundup_pow_of_two(1)

Chris Wright wrote:
> * Theodore Tso ([email protected]) wrote:
> > If this doesn't fix a user-visiable bug, should we be including it in
> > the stable patch series? (Assuming that it doesn't, I wouldn't, but I
> > tend to be more conservative about what I would include in a stable
> > production release.)
>
> Rolf, despite simplicity of patch, I'm inclined to agree with Ted.
> Were you effected by this in the wild, or just noticed by code
> inspection?

Code inspection. Drop it if you like, it's in mainline already.


Attachments:
(No filename) (521.00 B)
signature.asc (189.00 B)
This is a digitally signed message part.
Download all attachments