From: Boaz Harrosh <bharrosh@panasas.com>
To: Ivo van Doorn <ivdoorn@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>,
"David S. Miller" <davem@davemloft.net>,
"John W. Linville" <linville@tuxdriver.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Theodore Tso <tytso@mit.edu>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jan Beulich <jbeulich@novell.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/5 ver2] rt2x00: Compiler warning unmasked by fix of BUILD_BUG_ON
Date: Tue, 02 Sep 2008 17:20:35 +0300 [thread overview]
Message-ID: <48BD4BB3.7040808@panasas.com> (raw)
In-Reply-To: <200809011834.45856.IvDoorn@gmail.com>
Ivo van Doorn wrote:
> On Monday 01 September 2008, Boaz Harrosh wrote:
>> Ivo Van Doorn wrote:
>>
<snip>
>> Do you want that I send a fix for readability's sake?
>
> Yes, thanks.
>
<snip>
>> diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h
>> index 7e88ce5..e71b793 100644
>> --- a/drivers/net/wireless/rt2x00/rt2x00reg.h
>> +++ b/drivers/net/wireless/rt2x00/rt2x00reg.h
>> @@ -136,8 +136,8 @@ struct rt2x00_field32 {
>> */
>> #define is_power_of_two(x) ( !((x) & ((x)-1)) )
>> #define low_bit_mask(x) ( ((x)-1) & ~(x) )
>> -#define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x))
>> -
>> +#define is_valid_mask(x) is_power_of_two(1LU + (unsigned long)(x) + \
>> + low_bit_mask((unsigned long)x))
BTW
doing only:
-#define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x))
+#define is_valid_mask(x) is_power_of_two(1LU (x) + low_bit_mask(x))
Also fixes the problem. (By definition of C type promotion rules)
Should I do just That?
>> /*
>> * Macro's to find first set bit in a variable.
>> * These macro's behaves the same as the __ffs() function with
>> -- 1.5.6.rc1.5.gadf6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
>>
This is my suggested new patch:
---
From: Boaz Harrosh <bharrosh@panasas.com>
Date: Mon, 1 Sep 2008 14:47:19 +0300
Subject: [PATCH] rt2x00: Compiler warning unmasked by fix of BUILD_BUG_ON
A "Set" to a sign-bit in an "&" operation causes a compiler warning.
Make calculations unsigned.
[ The warning was masked by the old definition of BUILD_BUG_ON() ]
Also remove __builtin_constant_p from FIELD_CHECK since BUILD_BUG_ON
no longer permits non-const values.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
TO: Ivo van Doorn <IvDoorn@gmail.com>
TO: John W. Linville <linville@tuxdriver.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/net/wireless/rt2x00/rt2x00reg.h | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h
index 7e88ce5..2ea7866 100644
--- a/drivers/net/wireless/rt2x00/rt2x00reg.h
+++ b/drivers/net/wireless/rt2x00/rt2x00reg.h
@@ -136,7 +136,7 @@ struct rt2x00_field32 {
*/
#define is_power_of_two(x) ( !((x) & ((x)-1)) )
#define low_bit_mask(x) ( ((x)-1) & ~(x) )
-#define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x))
+#define is_valid_mask(x) is_power_of_two(1LU + (x) + low_bit_mask(x))
/*
* Macro's to find first set bit in a variable.
@@ -173,8 +173,7 @@ struct rt2x00_field32 {
* does not exceed the given typelimit.
*/
#define FIELD_CHECK(__mask, __type) \
- BUILD_BUG_ON(!__builtin_constant_p(__mask) || \
- !(__mask) || \
+ BUILD_BUG_ON(!(__mask) || \
!is_valid_mask(__mask) || \
(__mask) != (__type)(__mask)) \
--
1.5.6.rc1.5.gadf6
next prev parent reply other threads:[~2008-09-02 14:22 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 13:00 [PATCHSET 0/5] BUILD_BUG_ON: error on none-const expressions Boaz Harrosh
2008-09-01 13:07 ` [PATCH] debug, x86: move BUILD_BUG_ON() ARRAY_SIZE and __FUNCTION__ Boaz Harrosh
2008-09-01 13:11 ` [PATCH 2/5] net/niu: Fix none-const BUILD_BUG_ON usage Boaz Harrosh
2008-09-01 13:13 ` [PATCH 3/5] virtio: " Boaz Harrosh
2008-09-02 15:53 ` [PATCH 3/5 ver2] virtio: Fix non-const " Boaz Harrosh
2008-09-01 13:21 ` [PATCH 4/5] rt2x00: Compiler warning unmasked by fix of BUILD_BUG_ON Boaz Harrosh
2008-09-01 13:27 ` Ivo Van Doorn
2008-09-01 13:27 ` Benny Halevy
2008-09-01 13:44 ` [PATCH 4/5 ver2] " Boaz Harrosh
2008-09-01 14:01 ` Ivo Van Doorn
2008-09-01 15:17 ` Boaz Harrosh
2008-09-01 16:34 ` Ivo van Doorn
2008-09-02 14:20 ` Boaz Harrosh [this message]
2008-09-02 14:27 ` Ivo van Doorn
2008-09-02 15:55 ` Boaz Harrosh
2008-09-01 13:28 ` [PATCH 5/5] debug: BUILD_BUG_ON: error on non-const expressions Boaz Harrosh
2008-09-01 13:55 ` Jan Beulich
2008-09-01 14:21 ` Boaz Harrosh
2008-09-01 14:36 ` Jan Beulich
2008-09-01 15:00 ` Boaz Harrosh
2008-09-01 15:29 ` Jan Beulich
2008-09-01 16:41 ` Boaz Harrosh
2008-09-02 7:47 ` Jan Beulich
2008-09-02 15:19 ` Boaz Harrosh
2008-09-02 15:57 ` [PATCH 5/5 ver2] " Boaz Harrosh
2008-09-02 16:06 ` Boaz Harrosh
2008-09-02 16:11 ` Jan Beulich
2008-09-03 8:57 ` Boaz Harrosh
2008-09-03 10:19 ` Jan Beulich
2008-09-03 10:52 ` Boaz Harrosh
2008-10-02 5:35 ` Rusty Russell
2008-10-05 9:34 ` Boaz Harrosh
2008-09-02 16:07 ` [PATCH 5/5 ver3] " Boaz Harrosh
2008-09-06 16:01 ` [PATCHSET 0/5] BUILD_BUG_ON: error on none-const expressions Ingo Molnar
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=48BD4BB3.7040808@panasas.com \
--to=bharrosh@panasas.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=ivdoorn@gmail.com \
--cc=jbeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.