Skip to contentSkip to conversation

sched/fair: Fix assignment of boolean variables

PATCH Superseded Wen Yang 4 participants 4 messages Dec 1, 2018 – Dec 3, 2018 Scheduler

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wen Yang

author
#0 lore raw

PATCH 1/1 sched/fair: Fix assignment of boolean variables

Fix the following warnings reported by coccinelle:
kernel//sched/fair.c:7958:3-12: WARNING: Assignment of bool to 0/1

This also makes the code more readable.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index a2e8160968cb..f19aa66f9b15 100644
@@ -7955,7 +7955,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
 		if (env->sd->flags & SD_ASYM_CPUCAPACITY &&
 		    sgs->group_misfit_task_load < rq->misfit_task_load) {
 			sgs->group_misfit_task_load = rq->misfit_task_load;
-			*overload = 1;
+			*overload = true;
 		}
 	}
 
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Wen Yang

Fix the following warnings reported by coccinelle:
kernel//sched/fair.c:7958:3-12: WARNING: Assignment of bool to 0/1

This also makes the code more readable.

Ack, earlier assignments in the function like:

	if (nr_running > 1)
		*overload = true;

use = true, so this change keeps things consistent.

Quoted 20 lines
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index a2e8160968cb..f19aa66f9b15 100644
@@ -7955,7 +7955,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
 		if (env->sd->flags & SD_ASYM_CPUCAPACITY &&
 		    sgs->group_misfit_task_load < rq->misfit_task_load) {
 			sgs->group_misfit_task_load = rq->misfit_task_load;
-			*overload = 1;
+			*overload = true;
 		}
 	}
 
Signature · 1 line
2.19.1
Signature · 2 lines
Cheers,
Joey Pabalinas
maintainer
#2 lore raw
In reply to Wen Yang
Quoted 4 lines · Wen Yang

Fix the following warnings reported by coccinelle:
kernel//sched/fair.c:7958:3-12: WARNING: Assignment of bool to 0/1

This also makes the code more readable.

I disagree; anybody that has trouble with 0/1 vs false/true needs to stay away from C.

Quoted 13 lines
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +0 -0
index a2e8160968cb..f19aa66f9b15 100644

kernel/sched/fair.c static inline void update_sg_lb_stats(struct lb_env *env, · line 7961

Quoted 8 lines
kernel/sched/fair.c +1 -1
@@ -7955,7 +7955,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
 		if (env->sd->flags & SD_ASYM_CPUCAPACITY &&
 		    sgs->group_misfit_task_load < rq->misfit_task_load) {
 			sgs->group_misfit_task_load = rq->misfit_task_load;
-			*overload = 1;
+			*overload = true;
 		}
 	}
 

Anyway, this code is going away anyway:

https://lkml.kernel.org/r/[email protected]

#3 lore raw
Quoted 4 lines · Peter Zijlstra
Quoted 3 lines · Wen Yang

Fix the following warnings reported by coccinelle:
kernel//sched/fair.c:7958:3-12: WARNING: Assignment of bool to 0/1

Duh, Patrick raised that one to me last week but I got caught up in other things. I realized I could keep the local 'overload' as bool in

    575638d1047e ("sched/core: Change root_domain->overload type to int")

but probably forgot to update

    757ffdd705ee ("sched/fair: Set rq->rd->overload when misfit")

accordingly.

Quoted 31 lines
Quoted 1 line

This also makes the code more readable.

I disagree; anybody that has trouble with 0/1 vs false/true needs to stay away from C.

Quoted 13 lines
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +0 -0
index a2e8160968cb..f19aa66f9b15 100644

kernel/sched/fair.c static inline void update_sg_lb_stats(struct lb_env *env, · line 7961

Quoted 8 lines
kernel/sched/fair.c +1 -1
@@ -7955,7 +7955,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
 		if (env->sd->flags & SD_ASYM_CPUCAPACITY &&
 		    sgs->group_misfit_task_load < rq->misfit_task_load) {
 			sgs->group_misfit_task_load = rq->misfit_task_load;
-			*overload = 1;
+			*overload = true;
 		}
 	}
 

Anyway, this code is going away anyway:

https://lkml.kernel.org/r/[email protected]