lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhV-H6zkq1KoLQSQgimEgHhdD=S--kHa9hmhfbxUS_6OOfSJQ@mail.gmail.com>
Date: Tue, 4 Mar 2025 20:00:25 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: WangYuli <wangyuli@...ontech.com>
Cc: kernel@...0n.name, yangtiezhu@...ngson.cn, maobibo@...ngson.cn, 
	guoweikang.kernel@...il.com, agordeev@...ux.ibm.com, ast@...nel.org, 
	usamaarif642@...il.com, jiaxun.yang@...goat.com, loongarch@...ts.linux.dev, 
	linux-kernel@...r.kernel.org, zhanjun@...ontech.com, niecheng1@...ontech.com, 
	chenlinxuan@...ontech.com, donmor3000@...mail.com, 
	Wentao Guan <guanwentao@...ontech.com>
Subject: Re: [PATCH] LoongArch: Fix use of logical '&&' with constant operand

On Tue, Mar 4, 2025 at 6:53 PM WangYuli <wangyuli@...ontech.com> 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.
Are you kidding me? CONFIG_CMDLINE[0] is a constant for a specific
config but the config is variable across buildings. So the "constant"
for compilers is not as "constant" for people. Compiler warnings
should be double-checked by people, right?

Huacai

>
> Fixes: 83da30d73b86 ("LoongArch: Fix CMDLINE_EXTEND and CMDLINE_BOOTLOADER handling")
> Co-developed-by: Wentao Guan <guanwentao@...ontech.com>
> Signed-off-by: Wentao Guan <guanwentao@...ontech.com>
> Signed-off-by: Yuli Wang <wangyuli@...ontech.com>
> ---
>  arch/loongarch/kernel/setup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
> index edcfdfcad7d2..834bea7f42da 100644
> --- a/arch/loongarch/kernel/setup.c
> +++ b/arch/loongarch/kernel/setup.c
> @@ -332,7 +332,7 @@ static void __init bootcmdline_init(char **cmdline_p)
>          * Append built-in command line to the bootloader command line if
>          * CONFIG_CMDLINE_EXTEND is enabled.
>          */
> -       if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && CONFIG_CMDLINE[0]) {
> +       if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && !!CONFIG_CMDLINE[0]) {
>                 strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
>                 strlcat(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
>         }
> --
> 2.47.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ