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: <20181203091522.GC2516@gmail.com>
Date:   Mon, 3 Dec 2018 10:15:22 +0100
From:   Ingo Molnar <mingo@...nel.org>
To:     Wen Yang <wen.yang99@....com.cn>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        linux-kernel@...r.kernel.org, zhong.weidong@....com.cn,
        "Peter Zijlstra (Intel)" <peterz@...raded.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Mukesh Ojha <mojha@...eaurora.org>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH] cpu: Bool tests don't need comparisons


* Wen Yang <wen.yang99@....com.cn> wrote:

> This is the patch to the file cpu.c
> which fixes the following coccinelle warning:
> 
> WARNING: Comparison to bool
> 
> Signed-off-by: Wen Yang <wen.yang99@....com.cn>
> CC: Thomas Gleixner <tglx@...utronix.de>
> CC: Ingo Molnar <mingo@...nel.org>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
> CC: Josh Poimboeuf <jpoimboe@...hat.com>
> CC: "Peter Zijlstra (Intel)" <peterz@...raded.org>
> CC: Peter Zijlstra <peterz@...radead.org>
> CC: Mukesh Ojha <mojha@...eaurora.org>
> CC: linux-kernel@...r.kernel.org
> ---
>  kernel/cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 91d5c38eb7e5..5bdd7e150a11 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -1650,7 +1650,7 @@ int __cpuhp_state_add_instance_cpuslocked(enum cpuhp_state state,
>  	lockdep_assert_cpus_held();
>  
>  	sp = cpuhp_get_step(state);
> -	if (sp->multi_instance == false)
> +	if (!sp->multi_instance)
>  		return -EINVAL;
>  

This is a *totally* bogus explanation.

This is an equivalent pattern to '== 0' which is commonly used.

The patch is still doing the right thing, but only accidentally, for 
another reason, it's because we are using ->multi_instance in an 
inconsistent fashion:

 kernel/cpu.c:	if (!step->multi_instance) {
 kernel/cpu.c:	if (sp->multi_instance == false)
 kernel/cpu.c:	if (!sp->multi_instance)
 kernel/cpu.c:	if (sp->multi_instance) {

But that's really just by accident - if all usages were of the
'== true/false' pattern then this wouldn't be necessary.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ