Re: [PATCH 4/5] rt2x00: Compiler warning unmasked by fix of BUILD_BUG_ON

From: Ivo Van Doorn
Date: Mon Sep 01 2008 - 09:27:20 EST


On Mon, Sep 1, 2008 at 3:21 PM, Boaz Harrosh <bharrosh@xxxxxxxxxxx> wrote:
>
> A "Set" of the sign-bit in an "&" operation causes a compiler warning.
> Make calculations unsigned.
>
> [ The warning was masked by the use of (void)() cast in the old
> BUILD_BUG_ON() ]
>
> Signed-off-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx>
> TO: Ivo van Doorn <IvDoorn@xxxxxxxxx>
> TO: John W. Linville <linville@xxxxxxxxxxxxx>
> CC: Ingo Molnar <mingo@xxxxxxx>
> CC: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> ---
> drivers/net/wireless/rt2x00/rt2x00reg.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h
> index 7e88ce5..c0e8706 100644
> --- a/drivers/net/wireless/rt2x00/rt2x00reg.h
> +++ b/drivers/net/wireless/rt2x00/rt2x00reg.h
> @@ -134,8 +134,8 @@ struct rt2x00_field32 {
> * Note that we cannot use the is_power_of_2() function since this
> * check must be done at compile-time.
> */
> -#define is_power_of_two(x) ( !((x) & ((x)-1)) )
> -#define low_bit_mask(x) ( ((x)-1) & ~(x) )
> +#define is_power_of_two(x) ( !((unsigned)(x) & ((x)-1)) )
> +#define low_bit_mask(x) ( ((unsigned)(x)-1) & ~(x) )
> #define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x))

Could the patch not become a lot easier (and perhaps cleaner) when the
only change is:
#define is_valid_mask(x) is_power_of_two(1 + (x) +
low_bit_mask((unsigned)x))
that way all instances of x will be cast to unsigned...

Ivo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/