Re: [PATCH] LoongArch: Fix use of logical '&&' with constant operand
From: David Laight
Date: Thu Mar 13 2025 - 17:58:31 EST
On Tue, 4 Mar 2025 18:52:46 +0800
WangYuli <wangyuli@xxxxxxxxxxxxx> wrote:
> Fix follow error with clang-19:
>
> arch/loongarch/kernel/setup.c:335:40: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand]
> 335 | if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && CONFIG_CMDLINE[0]) {
> | ^ ~~~~~~~~~~~~~~~~~
> arch/loongarch/kernel/setup.c:335:40: note: use '&' for a bitwise operation
> 335 | if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && CONFIG_CMDLINE[0]) {
> | ^~
> | &
> arch/loongarch/kernel/setup.c:335:40: note: remove constant to silence this warning
> 335 | if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && CONFIG_CMDLINE[0]) {
> | ^~~~~~~~~~~~~~~~~~~~
> 1 error generated.
Isn't that just 'an error too far' ?
There is nothing really wrong with compile-time constants in conditionals.
The kernel is full of them.
Why not just disable the warning?
David