2020-03-30 01:27:09

by Jules Irenge

[permalink] [raw]
Subject: [PATCH v2 0/4] Coccinelle cleanups

This patch series clean up some warnings by the Coccinelle tool.

Jules Irenge (4):
cpu: Remove Comparison to bool
rcu: Replace 1 by true
genirq: Replace 1 by true
locking/rtmutex: Remove Comparison to bool

kernel/cpu.c | 2 +-
kernel/irq/spurious.c | 2 +-
kernel/locking/rtmutex.c | 2 +-
kernel/rcu/tree.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

--
Changes since v2:
- Improve on commit log
- Correct mistake of mixing two different subsystems patches into one.
2.25.1


2020-03-30 01:27:10

by Jules Irenge

[permalink] [raw]
Subject: [PATCH v2 4/4] locking/rtmutex: Remove Comparison to bool

Coccinelle reports a warning inside __sched rt_mutex_slowunlock()

WARNING: Comparison to bool

To fix this,
a comparison (==) of a bool type function result to value true
together with the value are removed.

Signed-off-by: Jules Irenge <[email protected]>
---
kernel/locking/rtmutex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 851bbb10819d..7289e7b26be4 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1378,7 +1378,7 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock,
*/
while (!rt_mutex_has_waiters(lock)) {
/* Drops lock->wait_lock ! */
- if (unlock_rt_mutex_safe(lock, flags) == true)
+ if (unlock_rt_mutex_safe(lock, flags))
return false;
/* Relock the rtmutex and try again */
raw_spin_lock_irqsave(&lock->wait_lock, flags);
--
2.25.1

2020-03-30 01:27:40

by Jules Irenge

[permalink] [raw]
Subject: [PATCH v2 2/4] rcu: Replace 1 by true

Coccinelle reports a warning at use_softirq declaration

WARNING: Assignment of 0/1 to bool variable

The root cause is
use_softirq a variable of bool type is initialised with the integer 1
Replacing 1 with value true solve the issue.

Signed-off-by: Jules Irenge <[email protected]>
---
kernel/rcu/tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index d91c9156fab2..c2ffea31eae8 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -100,7 +100,7 @@ static struct rcu_state rcu_state = {
static bool dump_tree;
module_param(dump_tree, bool, 0444);
/* By default, use RCU_SOFTIRQ instead of rcuc kthreads. */
-static bool use_softirq = 1;
+static bool use_softirq = true;
module_param(use_softirq, bool, 0444);
/* Control rcu_node-tree auto-balancing at boot time. */
static bool rcu_fanout_exact;
--
2.25.1

2020-03-30 11:23:22

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] locking/rtmutex: Remove Comparison to bool

On Mon, Mar 30, 2020 at 02:24:50AM +0100, Jules Irenge wrote:
> Coccinelle reports a warning inside __sched rt_mutex_slowunlock()
>
> WARNING: Comparison to bool

I don't mind the patch; but WTH is that a WARNING ?!? Superfluous, but
definitely not wrong or even dangerous AFAICT.

> To fix this,
> a comparison (==) of a bool type function result to value true
> together with the value are removed.
>
> Signed-off-by: Jules Irenge <[email protected]>
> ---
> kernel/locking/rtmutex.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index 851bbb10819d..7289e7b26be4 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -1378,7 +1378,7 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock,
> */
> while (!rt_mutex_has_waiters(lock)) {
> /* Drops lock->wait_lock ! */
> - if (unlock_rt_mutex_safe(lock, flags) == true)
> + if (unlock_rt_mutex_safe(lock, flags))
> return false;
> /* Relock the rtmutex and try again */
> raw_spin_lock_irqsave(&lock->wait_lock, flags);
> --
> 2.25.1
>

2020-03-30 21:17:05

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] rcu: Replace 1 by true

On Mon, Mar 30, 2020 at 02:24:48AM +0100, Jules Irenge wrote:
> Coccinelle reports a warning at use_softirq declaration
>
> WARNING: Assignment of 0/1 to bool variable
>
> The root cause is
> use_softirq a variable of bool type is initialised with the integer 1
> Replacing 1 with value true solve the issue.
>
> Signed-off-by: Jules Irenge <[email protected]>

Queued for review and testing, thank you!

Thanx, Paul

> ---
> kernel/rcu/tree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index d91c9156fab2..c2ffea31eae8 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -100,7 +100,7 @@ static struct rcu_state rcu_state = {
> static bool dump_tree;
> module_param(dump_tree, bool, 0444);
> /* By default, use RCU_SOFTIRQ instead of rcuc kthreads. */
> -static bool use_softirq = 1;
> +static bool use_softirq = true;
> module_param(use_softirq, bool, 0444);
> /* Control rcu_node-tree auto-balancing at boot time. */
> static bool rcu_fanout_exact;
> --
> 2.25.1
>

2020-04-03 16:18:15

by Jules Irenge

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] locking/rtmutex: Remove Comparison to bool



On Mon, 30 Mar 2020, Peter Zijlstra wrote:

> On Mon, Mar 30, 2020 at 02:24:50AM +0100, Jules Irenge wrote:
>> Coccinelle reports a warning inside __sched rt_mutex_slowunlock()
>>
>> WARNING: Comparison to bool
>
> I don't mind the patch; but WTH is that a WARNING ?!? Superfluous, but
> definitely not wrong or even dangerous AFAICT.
>
>> To fix this,
>> a comparison (==) of a bool type function result to value true
>> together with the value are removed.
>>
>> Signed-off-by: Jules Irenge <[email protected]>
>> ---
>> kernel/locking/rtmutex.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
>> index 851bbb10819d..7289e7b26be4 100644
>> --- a/kernel/locking/rtmutex.c
>> +++ b/kernel/locking/rtmutex.c
>> @@ -1378,7 +1378,7 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock,
>> */
>> while (!rt_mutex_has_waiters(lock)) {
>> /* Drops lock->wait_lock ! */
>> - if (unlock_rt_mutex_safe(lock, flags) == true)
>> + if (unlock_rt_mutex_safe(lock, flags))
>> return false;
>> /* Relock the rtmutex and try again */
>> raw_spin_lock_irqsave(&lock->wait_lock, flags);
>> --
>> 2.25.1
>>
>
Thanks for the reply, I will take good note.