[PATCH] sched/fair: fix boolreturn.cocci warning

Jiapeng Chong posted 1 patch 3 years, 9 months ago
kernel/sched/fair.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] sched/fair: fix boolreturn.cocci warning
Posted by Jiapeng Chong 3 years, 9 months ago
Return statements in functions returning bool should use true/false
instead of 1/0.

This was found by coccicheck:

./kernel/sched/fair.c:9988:9-10: WARNING: return of 0/1 in function 'imbalanced_active_balance' with return type bool.

Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ac64b5bb7cc9..814235b5477a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9985,9 +9985,9 @@ imbalanced_active_balance(struct lb_env *env)
 	 */
 	if ((env->migration_type == migrate_task) &&
 	    (sd->nr_balance_failed > sd->cache_nice_tries+2))
-		return 1;
+		return true;
 
-	return 0;
+	return false;
 }
 
 static int need_active_balance(struct lb_env *env)
-- 
2.20.1.7.g153144c
Re: [PATCH] sched/fair: fix boolreturn.cocci warning
Posted by Steven Rostedt 3 years, 9 months ago
On Tue,  5 Jul 2022 15:38:22 +0800
Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:

> This was found by coccicheck:
> 
> ./kernel/sched/fair.c:9988:9-10: WARNING: return of 0/1 in function 'imbalanced_active_balance' with return type bool.
> 
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

As your subject says "fix boolreturn.cocci warning". Can you please?

That is, this change has been presented 10 times before, and every time
it is nacked or ignored. The true fix is to fix boolreturn.cocci to not
warn about this in existing code.

Just in case it wasn't clear. NACK to this change.

-- Steve