public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpu: Bool tests don't need comparisons
@ 2018-12-01  8:04 Wen Yang
  2018-12-03  9:15 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Wen Yang @ 2018-12-01  8:04 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Konrad Rzeszutek Wilk,
	Josh Poimboeuf
  Cc: linux-kernel, zhong.weidong, Wen Yang, Peter Zijlstra (Intel),
	Peter Zijlstra, Mukesh Ojha

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@zte.com.cn>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@kernel.org>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Josh Poimboeuf <jpoimboe@redhat.com>
CC: "Peter Zijlstra (Intel)" <peterz@infraded.org>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Mukesh Ojha <mojha@codeaurora.org>
CC: linux-kernel@vger.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;
 
 	mutex_lock(&cpuhp_state_mutex);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpu: Bool tests don't need comparisons
  2018-12-01  8:04 [PATCH] cpu: Bool tests don't need comparisons Wen Yang
@ 2018-12-03  9:15 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2018-12-03  9:15 UTC (permalink / raw)
  To: Wen Yang
  Cc: Thomas Gleixner, Konrad Rzeszutek Wilk, Josh Poimboeuf,
	linux-kernel, zhong.weidong, Peter Zijlstra (Intel),
	Peter Zijlstra, Mukesh Ojha, Peter Zijlstra


* Wen Yang <wen.yang99@zte.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@zte.com.cn>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Ingo Molnar <mingo@kernel.org>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: Josh Poimboeuf <jpoimboe@redhat.com>
> CC: "Peter Zijlstra (Intel)" <peterz@infraded.org>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: Mukesh Ojha <mojha@codeaurora.org>
> CC: linux-kernel@vger.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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-03  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-01  8:04 [PATCH] cpu: Bool tests don't need comparisons Wen Yang
2018-12-03  9:15 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox