lkml.org 
[lkml]   [2020]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] bitops: avoid clang shift-count-overflow warnings
On Tue, May 5, 2020 at 4:58 PM Arnd Bergmann <arnd@arndb.de> 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:

Shouldn't it be fixed in CLang?

> include/linux/bitops.h:75:41: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
> return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
> ^~~~~~~~~~~~

sizeof(w) is compile-time constant. It can easily drop the second part
without even looking at it.

> Adding an explicit cast to __u64 avoids that warning and makes it easier
> to read other output.

Looks like papering over the real issue.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2020-05-05 16:09    [W:0.067 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site