All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: NamJae Jeon <linkinjeon@gmail.com>
Cc: linux-arch@vger.kernel.org
Subject: Re: 'hweight_long' include/linux/bitops.h compile warning problem.
Date: Mon, 20 Jun 2011 15:00:58 +0200	[thread overview]
Message-ID: <201106201500.58617.arnd@arndb.de> (raw)
In-Reply-To: <BANLkTi=ETn+LXtd20qkfcgrUngjqwVrVPg@mail.gmail.com>

On Monday 20 June 2011, NamJae Jeon wrote:
> I found compile warning while compiling module when using -Wsign-compare option.
> 
> include/linux/bitops.h: In function 'hweight_long':
> include/linux/bitops.h:49: warning: signed and unsigned type in
> conditional expression
> 
> I found the reason of this problem that the default return value of
> the below macro is signed.
> 
> #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))) )
> 
> So, I try to add (unsigned long) in __const_hweight8 like this.
> 
> #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))) )
> 
> so, I can't see compile warning after fixing it, Would you plz check this ?

Yes, this looks correct to me. Could you send the change as a proper patch
with your Signed-off-by:?

	Arnd

  reply	other threads:[~2011-06-20 13:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20  7:59 'hweight_long' include/linux/bitops.h compile warning problem NamJae Jeon
2011-06-20 13:00 ` Arnd Bergmann [this message]
2011-06-21  6:11   ` NamJae Jeon
2011-06-21  6:11     ` NamJae Jeon

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=201106201500.58617.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linkinjeon@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    /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.