2018-12-01 09:12:20

by Wen Yang

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Wen Yang <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Peter Zijlstra <[email protected]>
CC: [email protected]
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a2e8160968cb..f19aa66f9b15 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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;
}
}

--
2.19.1



2018-12-01 21:33:48

by Joey Pabalinas

[permalink] [raw]
Subject: Re: [PATCH] sched/fair: Fix assignment of boolean variables

On Sat, Dec 01, 2018 at 05:09:36PM +0800, Wen Yang wrote:
> 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.
>
> Signed-off-by: Wen Yang <[email protected]>
> CC: Ingo Molnar <[email protected]>
> CC: Peter Zijlstra <[email protected]>
> CC: [email protected]

Ack, earlier assignments in the function like:

if (nr_running > 1)
*overload = true;

use `= true`, so this change keeps things consistent.

Reviewed-by: Joey Pabalinas <[email protected]>

> ---
> kernel/sched/fair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a2e8160968cb..f19aa66f9b15 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -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;
> }
> }
>
> --
> 2.19.1
>

--
Cheers,
Joey Pabalinas


Attachments:
(No filename) (1.21 kB)
signature.asc (849.00 B)
Download all attachments

2018-12-03 08:35:35

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH] sched/fair: Fix assignment of boolean variables

On Sat, Dec 01, 2018 at 05:09:36PM +0800, Wen Yang wrote:
> 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.

> Signed-off-by: Wen Yang <[email protected]>
> CC: Ingo Molnar <[email protected]>
> CC: Peter Zijlstra <[email protected]>
> CC: [email protected]
> ---
> kernel/sched/fair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a2e8160968cb..f19aa66f9b15 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -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]


2018-12-03 10:05:14

by Valentin Schneider

[permalink] [raw]
Subject: Re: [PATCH] sched/fair: Fix assignment of boolean variables

On 03/12/2018 08:33, Peter Zijlstra wrote:
> On Sat, Dec 01, 2018 at 05:09:36PM +0800, Wen Yang wrote:
>> 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.

>> 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.
>
>> Signed-off-by: Wen Yang <[email protected]>
>> CC: Ingo Molnar <[email protected]>
>> CC: Peter Zijlstra <[email protected]>
>> CC: [email protected]
>> ---
>> kernel/sched/fair.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index a2e8160968cb..f19aa66f9b15 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -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]
>