cpu: Bool tests don't need comparisons
PATCH 1/1 cpu: Bool tests don't need comparisons
This is the patch to the file cpu.c
which fixes the following coccinelle warning:
WARNING: Comparison to bool
--- kernel/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cpu.c +1 -1
@@ -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);
Signature · 1 line
2.19.1
Quoted 23 lines · Wen Yang
This is the patch to the file
cpu.c
which fixes the following coccinelle warning:WARNING: Comparison to bool
Signed-off-by Wen Yang <[email protected]>CC Thomas Gleixner <[email protected]>CC Ingo Molnar <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>CC Josh Poimboeuf <[email protected]>CC "Peter Zijlstra (Intel)" <[email protected]>CC Peter Zijlstra <[email protected]>CC Mukesh Ojha <[email protected]>--- kernel/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/cpu.c +0
-0
kernel/cpu.c int __cpuhp_state_add_instance_cpuslocked(enum cpuhp_state state, · line 1655
Quoted 7 lines
kernel/cpu.c +1
-1@@ -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