From: Christian Brauner <christian.brauner@ubuntu.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Josh Poimboeuf <jpoimboe@redhat.com>,
linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com
Subject: Re: [PATCH] bitops: avoid clang shift-count-overflow warnings
Date: Tue, 5 May 2020 16:01:49 +0200 [thread overview]
Message-ID: <20200505140149.lyru5h2zxmkozn75@wittgenstein> (raw)
In-Reply-To: <20200505135513.65265-1-arnd@arndb.de>
On Tue, May 05, 2020 at 03:54:57PM +0200, Arnd Bergmann wrote:
> Clang normally does not warn about certain issues in inline functions when
> it only happens in an eliminated code path. However if something else
> goes wrong, it does tend to complain about the definition of hweight_long()
> on 32-bit targets:
>
> include/linux/bitops.h:75:41: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
> return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
> ^~~~~~~~~~~~
> include/asm-generic/bitops/const_hweight.h:29:49: note: expanded from macro 'hweight64'
> define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w))
> ^~~~~~~~~~~~~~~~~~~~
> include/asm-generic/bitops/const_hweight.h:21:76: note: expanded from macro '__const_hweight64'
> define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32))
> ^ ~~
> include/asm-generic/bitops/const_hweight.h:20:49: note: expanded from macro '__const_hweight32'
> define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16))
> ^
> include/asm-generic/bitops/const_hweight.h:19:72: note: expanded from macro '__const_hweight16'
> define __const_hweight16(w) (__const_hweight8(w) + __const_hweight8((w) >> 8 ))
> ^
> include/asm-generic/bitops/const_hweight.h:12:9: note: expanded from macro '__const_hweight8'
> (!!((w) & (1ULL << 2))) + \
>
> Adding an explicit cast to __u64 avoids that warning and makes it easier
> to read other output.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
next prev parent reply other threads:[~2020-05-05 14:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 13:54 [PATCH] bitops: avoid clang shift-count-overflow warnings Arnd Bergmann
2020-05-05 14:01 ` Christian Brauner [this message]
2020-05-05 14:08 ` Andy Shevchenko
2020-05-05 15:32 ` Arnd Bergmann
2020-05-05 15:36 ` Nick Desaulniers
2020-05-05 15:44 ` Arnd Bergmann
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=20200505140149.lyru5h2zxmkozn75@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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 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).