include/log2.h: Fix rounddown_pow_of_two(1)
PATCH 1/1 include/log2.h: Fix rounddown_pow_of_two(1)
1 is a power of two, therefore rounddown_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, however net/drivers/vmxnet3 with latest GCC does and breaks on unicpu systems.
--- include/linux/log2.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/log2.h +1 -1
@@ -185,7 +185,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)#define rounddown_pow_of_two (n) \ ( \ __builtin_constant_p(n) ? ( \ - (n == 1) ? 0 : \ + (n == 1) ? 1 : \ (1UL << ilog2(n))) : \ __rounddown_pow_of_two(n) \ )
Signature · 1 line
1.7.4.1
Quoted 16 lines · Andrei Warkentin
1 is a power of two, therefore
rounddown_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, howevernet/drivers/vmxnet3with latest GCC does and breaks on unicpu systems.Signed-off-by Andrei Warkentin <[email protected]>--- include/linux/log2.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)include/linux/log2.h +0
-0
include/linux/log2.h unsigned long __rounddown_pow_of_two(unsigned long n) · line 191
Quoted 8 lines
include/linux/log2.h +1
-1@@ -185,7 +185,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)#define rounddown_pow_of_two (n) \ ( \ __builtin_constant_p(n) ? ( \ - (n == 1) ? 0 : \ + (n == 1) ? 1 : \ (1UL << ilog2(n))) : \ __rounddown_pow_of_two(n) \ )
For what it's worth; looks good to me.
Signature · 3 lines
Jesper Juhl <[email protected]> http://www.chaosbits.net/ Don't top-post http://www.catb.org/jargon/html/T/top-post.html Plain text mails only, please.
----- Original Message -----
Quoted 31 lines
From: "Jesper Juhl" <[email protected]>
To: "Andrei Warkentin" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 2:57:27 PM
Subject: Re: [PATCH]include/log2.h: Fixrounddown_pow_of_two(1)Quoted 23 lines · Andrei Warkentin
1 is a power of two, therefore
rounddown_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,
howevernet/drivers/vmxnet3with latest GCC does and breaks on unicpu systems.Signed-off-by Andrei Warkentin <[email protected]>--- include/linux/log2.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)include/linux/log2.h +0
-0@@ -185,7 +185,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)#define rounddown_pow_of_two (n) \ ( \ __builtin_constant_p(n) ? ( \
Quoted 8 lines
Quoted 6 lines
include/linux/log2.h +1
-1- (n == 1) ? 0 : \ + (n == 1) ? 1 : \ (1UL << ilog2(n))) : \__rounddown_pow_of_two (n) \)
For what it's worth; looks good to me.
Is that an Acked-by or a Reviewed-by?
Thanks,
A
Quoted 41 lines · Andrei Warkentin
----- Original Message -----
Quoted 31 lines
From: "Jesper Juhl" <[email protected]>
To: "Andrei Warkentin" <[email protected]>
Cc: [email protected]
Sent: Tuesday, November 8, 2011 2:57:27 PM
Subject: Re: [PATCH]include/log2.h: Fixrounddown_pow_of_two(1)Quoted 23 lines · Andrei Warkentin
1 is a power of two, therefore
rounddown_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,
howevernet/drivers/vmxnet3with latest GCC does and breaks on unicpu systems.Signed-off-by Andrei Warkentin <[email protected]>--- include/linux/log2.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)include/linux/log2.h +0
-0@@ -185,7 +185,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)#define rounddown_pow_of_two (n) \ ( \ __builtin_constant_p(n) ? ( \Quoted 8 lines
Quoted 6 lines
include/linux/log2.h +1
-1- (n == 1) ? 0 : \ + (n == 1) ? 1 : \ (1UL << ilog2(n))) : \__rounddown_pow_of_two (n) \)
For what it's worth; looks good to me.
Quoted 2 lines
Is that an Acked-by or a Reviewed-by?
I don't really know (to be honest). I guess it is whichever is weakest, since I did review the patch and convinced myself that the change was sane, but didn't spent a whole lot of time checking that *all* users were OK with it...
Signature · 3 lines
Jesper Juhl <[email protected]> http://www.chaosbits.net/ Don't top-post http://www.catb.org/jargon/html/T/top-post.html Plain text mails only, please.