Re: [PATCH v1 1/1] x86/percpu: Cast -1 to argument type when comparing in percpu_add_op()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 05, 2024 at 08:03:56PM +0300, Andy Shevchenko wrote:
> When percpu_add_op() is used with unsigned argument, it prevents kernel builds
> with clang, `make W=1` and CONFIG_WERROR=y:
> 
> net/ipv4/tcp_output.c:187:3: error: result of comparison of constant -1 with expression of type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
>   187 |                 NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPACKCOMPRESSED,
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   188 |                               tp->compressed_ack);
>       |                               ~~~~~~~~~~~~~~~~~~~
> ...
> arch/x86/include/asm/percpu.h:238:31: note: expanded from macro 'percpu_add_op'
>   238 |                               ((val) == 1 || (val) == -1)) ?            \
>       |                                              ~~~~~ ^  ~~
> 
> Fix this by casting -1 to the type of the parameter and then compare.

Any comments? Or can it be taken in?

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux