2014-06-26 11:31:42

by Rickard Strandqvist

[permalink] [raw]
Subject: [PATCH] pinctrl: pinctrl-st.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-st.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 1bd6363bc9..f4ee1b1 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -1256,7 +1256,7 @@ static int st_pctl_parse_functions(struct device_node *np,
func = &info->functions[index];
func->name = np->name;
func->ngroups = of_get_child_count(np);
- if (func->ngroups <= 0) {
+ if (func->ngroups == 0) {
dev_err(info->dev, "No groups defined\n");
return -EINVAL;
}
--
1.7.10.4


2014-06-26 11:48:04

by Srinivas Kandagatla

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



On 26/06/14 12:32, Rickard Strandqvist 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]>
> ---
> drivers/pinctrl/pinctrl-st.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
> index 1bd6363bc9..f4ee1b1 100644
> --- a/drivers/pinctrl/pinctrl-st.c
> +++ b/drivers/pinctrl/pinctrl-st.c
> @@ -1256,7 +1256,7 @@ static int st_pctl_parse_functions(struct device_node *np,
> func = &info->functions[index];
> func->name = np->name;
> func->ngroups = of_get_child_count(np);
> - if (func->ngroups <= 0) {
> + if (func->ngroups == 0) {

Makes sense

Acked-by: Srinivas Kandagatla <[email protected]>


> dev_err(info->dev, "No groups defined\n");
> return -EINVAL;
> }
>

2014-06-26 12:04:49

by Maxime Coquelin

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

Hi Rickard,

On 06/26/2014 01:32 PM, Rickard Strandqvist 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]>

You can add my:
Acked-by: Maxime Coquelin <[email protected]>

Thanks,
Maxime
> --- drivers/pinctrl/pinctrl-st.c | 2 +- 1 file changed, 1
> insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-st.c
> b/drivers/pinctrl/pinctrl-st.c index 1bd6363bc9..f4ee1b1 100644 ---
> a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c
> @@ -1256,7 +1256,7 @@ static int st_pctl_parse_functions(struct
> device_node *np, func = &info->functions[index]; func->name =
> np->name; func->ngroups = of_get_child_count(np); - if
> (func->ngroups <= 0) { + if (func->ngroups == 0) {
> dev_err(info->dev, "No groups defined\n"); return -EINVAL; }
>

2014-07-07 15:42:40

by Linus Walleij

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

On Thu, Jun 26, 2014 at 1:32 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]>

Patch applied with the ACKs. Thanks!

Yours,
Linus Walleij