linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] include: Fix compile warning in include/linux/bitops.h
@ 2011-08-24 15:23 Namjae Jeon
  2011-08-24 15:29 ` NamJae Jeon
  0 siblings, 1 reply; 5+ messages in thread
From: Namjae Jeon @ 2011-08-24 15:23 UTC (permalink / raw)
  To: linux-arch, arnd; +Cc: linux-kernel, Namjae Jeon

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@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] include: Fix compile warning in include/linux/bitops.h
  2011-08-24 15:23 Namjae Jeon
@ 2011-08-24 15:29 ` NamJae Jeon
  0 siblings, 0 replies; 5+ messages in thread
From: NamJae Jeon @ 2011-08-24 15:29 UTC (permalink / raw)
  To: arnd; +Cc: linux-kernel, linux-arch

Hi. Arnd.

I send a patch by the below your request.

Would you plz confirm it ?

Thanks.

2011/8/25 Namjae Jeon <linkinjeon@gmail.com>:
> 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@gmail.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] include: Fix compile warning in include/linux/bitops.h
@ 2012-06-09  3:15 Namjae Jeon
  2012-06-11 22:59 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Namjae Jeon @ 2012-06-09  3:15 UTC (permalink / raw)
  To: arnd, akpm; +Cc: linux-arch, linux-kernel, Namjae Jeon

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@gmail.com>
---
 include/asm-generic/bitops/const_hweight.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/bitops/const_hweight.h b/include/asm-generic/bitops/const_hweight.h
index fa2a50b..3ad0dae 100644
--- a/include/asm-generic/bitops/const_hweight.h
+++ b/include/asm-generic/bitops/const_hweight.h
@@ -4,7 +4,7 @@
 /*
  * Compile time versions of __arch_hweightN()
  */
-#define __const_hweight8(w)		\
+#define __const_hweight8(w)	(unsigned long)	\
       (	(!!((w) & (1ULL << 0))) +	\
 	(!!((w) & (1ULL << 1))) +	\
 	(!!((w) & (1ULL << 2))) +	\
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] include: Fix compile warning in include/linux/bitops.h
  2012-06-09  3:15 [PATCH] include: Fix compile warning in include/linux/bitops.h Namjae Jeon
@ 2012-06-11 22:59 ` Andrew Morton
  2012-06-12  0:05   ` Namjae Jeon
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2012-06-11 22:59 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: arnd, linux-arch, linux-kernel

On Fri,  8 Jun 2012 23:15:30 -0400
Namjae Jeon <linkinjeon@gmail.com> wrote:

> 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.

um, what warning?

Please always quote the compiler messages when fixing build warnings or
errors.

> index fa2a50b..3ad0dae 100644
> --- a/include/asm-generic/bitops/const_hweight.h
> +++ b/include/asm-generic/bitops/const_hweight.h
> @@ -4,7 +4,7 @@
>  /*
>   * Compile time versions of __arch_hweightN()
>   */
> -#define __const_hweight8(w)		\
> +#define __const_hweight8(w)	(unsigned long)	\
>        (	(!!((w) & (1ULL << 0))) +	\
>  	(!!((w) & (1ULL << 1))) +	\
>  	(!!((w) & (1ULL << 2))) +	\

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] include: Fix compile warning in include/linux/bitops.h
  2012-06-11 22:59 ` Andrew Morton
@ 2012-06-12  0:05   ` Namjae Jeon
  0 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2012-06-12  0:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: arnd, linux-arch, linux-kernel

2012/6/12, Andrew Morton <akpm@linux-foundation.org>:
> On Fri,  8 Jun 2012 23:15:30 -0400
> Namjae Jeon <linkinjeon@gmail.com> wrote:
>
>> 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.
>
> um, what warning?
Hi Andrew.
Sorry, I forgot it.
When we use hwight_long function, We can see the below warning message.

include/linux/bitops.h: In function 'hweight_long':
include/linux/bitops.h:49: warning: signed and unsigned type in
conditional expression

Thanks a lot.
>
> Please always quote the compiler messages when fixing build warnings or
> errors.
>
>> index fa2a50b..3ad0dae 100644
>> --- a/include/asm-generic/bitops/const_hweight.h
>> +++ b/include/asm-generic/bitops/const_hweight.h
>> @@ -4,7 +4,7 @@
>>  /*
>>   * Compile time versions of __arch_hweightN()
>>   */
>> -#define __const_hweight8(w)		\
>> +#define __const_hweight8(w)	(unsigned long)	\
>>        (	(!!((w) & (1ULL << 0))) +	\
>>  	(!!((w) & (1ULL << 1))) +	\
>>  	(!!((w) & (1ULL << 2))) +	\
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-12  0:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-09  3:15 [PATCH] include: Fix compile warning in include/linux/bitops.h Namjae Jeon
2012-06-11 22:59 ` Andrew Morton
2012-06-12  0:05   ` Namjae Jeon
  -- strict thread matches above, loose matches on Subject: below --
2011-08-24 15:23 Namjae Jeon
2011-08-24 15:29 ` NamJae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).