[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aBTs6yvKlCYYgU2O@yury>
Date: Fri, 2 May 2025 12:03:55 -0400
From: Yury Norov <yury.norov@...il.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>,
Arnd Bergmann <arnd@...db.de>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Thomas Gleixner <tglx@...utronix.de>,
Jakub Kicinski <kuba@...nel.org>,
Jacob Keller <jacob.e.keller@...el.com>, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
Leo Yan <leo.yan@....com>
Subject: Re: [PATCH v2 2/5] bitmap: Silence a clang -Wshorten-64-to-32 warning
Hi Ian,
On Wed, Apr 30, 2025 at 10:15:31AM -0700, Ian Rogers wrote:
> The clang warning -Wshorten-64-to-32 can be useful to catch
> inadvertent truncation. In some instances this truncation can lead to
> changing the sign of a result, for example, truncation to return an
> int to fit a sort routine. Silence the warning by making the implicit
> truncation explicit. This isn't to say the code is currently incorrect
> but without silencing the warning it is hard to spot the erroneous
> cases.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
> include/linux/bitmap.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index 595217b7a6e7..4395e0a618f4 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -442,7 +442,7 @@ static __always_inline
> unsigned int bitmap_weight(const unsigned long *src, unsigned int nbits)
> {
> if (small_const_nbits(nbits))
> - return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
> + return (int)hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
This should return unsigned int, I guess?
Also, most of the functions you touch here have their copies in tools.
Can you please keep them synchronized?
Thanks,
Yury
> return __bitmap_weight(src, nbits);
> }
>
> --
> 2.49.0.906.g1f30a19c02-goog
Powered by blists - more mailing lists