2014-06-26 11:30:11

by Rickard Strandqvist

[permalink] [raw]
Subject: [PATCH] pinctrl: pinctrl-msm.c: Cleaning up if unsigned is less than zero

Remove checking if a unsigned is less than zero

This was found using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <[email protected]>
---
drivers/pinctrl/pinctrl-msm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-msm.c b/drivers/pinctrl/pinctrl-msm.c
index df6dda4c..cde8b2b 100644
--- a/drivers/pinctrl/pinctrl-msm.c
+++ b/drivers/pinctrl/pinctrl-msm.c
@@ -176,7 +176,7 @@ static void msm_pinmux_disable(struct pinctrl_dev *pctldev,

g = &pctrl->soc->groups[group];

- if (WARN_ON(g->mux_bit < 0))
+ if (WARN_ON(g->mux_bit != 0))
return;

spin_lock_irqsave(&pctrl->lock, flags);
--
1.7.10.4


2014-07-07 15:40:59

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: pinctrl-msm.c: Cleaning up if unsigned is less than zero

On Thu, Jun 26, 2014 at 1:31 PM, Rickard Strandqvist
<[email protected]> wrote:

> Remove checking if a unsigned is less than zero
>
> This was found using a static code analysis program called cppcheck.
>
> Signed-off-by: Rickard Strandqvist <[email protected]>
(...)
> - if (WARN_ON(g->mux_bit < 0))
> + if (WARN_ON(g->mux_bit != 0))

Is that correct?

If the variable cannot be < 0 should the check not simply be
deleted, since this is all it checks for?

Yours,
Linus Walleij

2014-07-07 18:44:46

by Rickard Strandqvist

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: pinctrl-msm.c: Cleaning up if unsigned is less than zero

2014-07-07 17:40 GMT+02:00 Linus Walleij <[email protected]>:
> On Thu, Jun 26, 2014 at 1:31 PM, Rickard Strandqvist
> <[email protected]> wrote:
>
>> Remove checking if a unsigned is less than zero
>>
>> This was found using a static code analysis program called cppcheck.
>>
>> Signed-off-by: Rickard Strandqvist <[email protected]>
> (...)
>> - if (WARN_ON(g->mux_bit < 0))
>> + if (WARN_ON(g->mux_bit != 0))
>
> Is that correct?
>
> If the variable cannot be < 0 should the check not simply be
> deleted, since this is all it checks for?


Hi Linus!

Yes, it was a bit silly. Do not really know how that happened :-/

I guess I thought it was reasonable. But I should do as I have tried
to do in all other cases, the smallest possible change. And let you
check in code, if so, to capture what is missing.

New patch on the way!


Kind regards
Rickard Strandqvist