Re: [PATCH] include: Fix compile warning in include/linux/bitops.h

From: NamJae Jeon
Date: Wed Aug 24 2011 - 11:29:59 EST


Hi. Arnd.

I send a patch by the below your request.

Would you plz confirm it ?

Thanks.

2011/8/25 Namjae Jeon <linkinjeon@xxxxxxxxx>:
> The compile warning is caused by __const_hweight8 when using hweight_long with -Wsign-compare option.
> The reason is that the default return value of this macro is signed. So need type casting to remove warning.
>
> Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxx>
> ---
> Âinclude/asm-generic/bitops/const_hweight.h | Â 18 +++++++++---------
> Â1 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/include/asm-generic/bitops/const_hweight.h b/include/asm-generic/bitops/const_hweight.h
> index fa2a50b..31b7fce 100644
> --- a/include/asm-generic/bitops/const_hweight.h
> +++ b/include/asm-generic/bitops/const_hweight.h
> @@ -4,15 +4,15 @@
> Â/*
> Â* Compile time versions of __arch_hweightN()
> Â*/
> -#define __const_hweight8(w) Â Â Â Â Â Â\
> - Â Â Â( Â Â Â Â(!!((w) & (1ULL << 0))) + Â Â Â \
> - Â Â Â (!!((w) & (1ULL << 1))) + Â Â Â \
> - Â Â Â (!!((w) & (1ULL << 2))) + Â Â Â \
> - Â Â Â (!!((w) & (1ULL << 3))) + Â Â Â \
> - Â Â Â (!!((w) & (1ULL << 4))) + Â Â Â \
> - Â Â Â (!!((w) & (1ULL << 5))) + Â Â Â \
> - Â Â Â (!!((w) & (1ULL << 6))) + Â Â Â \
> - Â Â Â (!!((w) & (1ULL << 7))) )
> +#define __const_hweight8(w) Â Â(unsigned long) \
> + Â Â Â ( Â Â Â (!!((w) & (1ULL << 0))) + Â Â Â \
> + Â Â Â Â Â Â Â (!!((w) & (1ULL << 1))) + Â Â Â \
> + Â Â Â Â Â Â Â (!!((w) & (1ULL << 2))) + Â Â Â \
> + Â Â Â Â Â Â Â (!!((w) & (1ULL << 3))) + Â Â Â \
> + Â Â Â Â Â Â Â (!!((w) & (1ULL << 4))) + Â Â Â \
> + Â Â Â Â Â Â Â (!!((w) & (1ULL << 5))) + Â Â Â \
> + Â Â Â Â Â Â Â (!!((w) & (1ULL << 6))) + Â Â Â \
> + Â Â Â Â Â Â Â (!!((w) & (1ULL << 7))) )
>
> Â#define __const_hweight16(w) (__const_hweight8(w) Â+ __const_hweight8((w) Â>> 8 ))
> Â#define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16))
> --
> 1.7.4.4
>
>
Yes, this looks correct to me. Could you send the change as a proper patch
with your Signed-off-by:?

Arnd
--
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/