2021-12-18 15:27:22

by Tom Rix

[permalink] [raw]
Subject: [PATCH] gpio: sim: fix uninitialized ret variable

From: Tom Rix <[email protected]>

Building with clang returns this error:

gpio-sim.c:889:7: error: variable 'ret' is uninitialized
when used here

ret should be the status of the call to
gpio_sim_make_bank_swnode stored in bank->swnode.

Fixes: 83960fcf4818 ("gpio: sim: new testing module")
Signed-off-by: Tom Rix <[email protected]>
---
drivers/gpio/gpio-sim.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index ef6145f51c8ae..bef00dcc4dc8f 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -886,7 +886,8 @@ static int gpio_sim_device_activate_unlocked(struct gpio_sim_device *dev)

list_for_each_entry(bank, &dev->bank_list, siblings) {
bank->swnode = gpio_sim_make_bank_swnode(bank, swnode);
- if (ret) {
+ if (IS_ERR(bank->swnode)) {
+ ret = PTR_ERR(bank->swnode);
gpio_sim_remove_swnode_recursive(swnode);
return ret;
}
--
2.26.3



2021-12-18 21:59:55

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] gpio: sim: fix uninitialized ret variable

On Sat, Dec 18, 2021 at 07:27:12AM -0800, [email protected] wrote:
> From: Tom Rix <[email protected]>
>
> Building with clang returns this error:
>
> gpio-sim.c:889:7: error: variable 'ret' is uninitialized
> when used here
>
> ret should be the status of the call to
> gpio_sim_make_bank_swnode stored in bank->swnode.
>
> Fixes: 83960fcf4818 ("gpio: sim: new testing module")
> Signed-off-by: Tom Rix <[email protected]>

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> drivers/gpio/gpio-sim.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
> index ef6145f51c8ae..bef00dcc4dc8f 100644
> --- a/drivers/gpio/gpio-sim.c
> +++ b/drivers/gpio/gpio-sim.c
> @@ -886,7 +886,8 @@ static int gpio_sim_device_activate_unlocked(struct gpio_sim_device *dev)
>
> list_for_each_entry(bank, &dev->bank_list, siblings) {
> bank->swnode = gpio_sim_make_bank_swnode(bank, swnode);
> - if (ret) {
> + if (IS_ERR(bank->swnode)) {
> + ret = PTR_ERR(bank->swnode);
> gpio_sim_remove_swnode_recursive(swnode);
> return ret;
> }
> --
> 2.26.3
>

2021-12-19 13:48:53

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH] gpio: sim: fix uninitialized ret variable

On Sat, Dec 18, 2021 at 4:27 PM <[email protected]> wrote:
>
> From: Tom Rix <[email protected]>
>
> Building with clang returns this error:
>
> gpio-sim.c:889:7: error: variable 'ret' is uninitialized
> when used here
>
> ret should be the status of the call to
> gpio_sim_make_bank_swnode stored in bank->swnode.
>
> Fixes: 83960fcf4818 ("gpio: sim: new testing module")
> Signed-off-by: Tom Rix <[email protected]>
> ---
> drivers/gpio/gpio-sim.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
> index ef6145f51c8ae..bef00dcc4dc8f 100644
> --- a/drivers/gpio/gpio-sim.c
> +++ b/drivers/gpio/gpio-sim.c
> @@ -886,7 +886,8 @@ static int gpio_sim_device_activate_unlocked(struct gpio_sim_device *dev)
>
> list_for_each_entry(bank, &dev->bank_list, siblings) {
> bank->swnode = gpio_sim_make_bank_swnode(bank, swnode);
> - if (ret) {
> + if (IS_ERR(bank->swnode)) {
> + ret = PTR_ERR(bank->swnode);
> gpio_sim_remove_swnode_recursive(swnode);
> return ret;
> }
> --
> 2.26.3
>

Applied, thanks!

Bart