diff mbox series

[next] power: supply: bq25980: remove redundant zero check on ret

Message ID 20201006170600.545361-1-colin.king@canonical.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [next] power: supply: bq25980: remove redundant zero check on ret | expand

Commit Message

Colin King Oct. 6, 2020, 5:06 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Currently ret is assigned to zero and the following statement checks
if it is non-zero. This check is redundant and can be removed

Addresses-Coverity: ("Logically dead code")
Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/power/supply/bq25980_charger.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Dan Murphy Oct. 6, 2020, 5:23 p.m. UTC | #1
Colin

On 10/6/20 12:06 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently ret is assigned to zero and the following statement checks
> if it is non-zero. This check is redundant and can be removed
>
> Addresses-Coverity: ("Logically dead code")
> Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/power/supply/bq25980_charger.c | 3 ---
>   1 file changed, 3 deletions(-)
>
> diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c
> index 3995fb7cf060..f04f9acdb13b 100644
> --- a/drivers/power/supply/bq25980_charger.c
> +++ b/drivers/power/supply/bq25980_charger.c
> @@ -613,9 +613,6 @@ static int bq25980_set_battery_property(struct power_supply *psy,
>   	struct bq25980_device *bq = power_supply_get_drvdata(psy);
>   	int ret = 0;
>   
> -	if (ret)
> -		return ret;
> -
>   	switch (psp) {
>   	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
>   		ret = bq25980_set_const_charge_curr(bq, val->intval);

Thanks for the patch

Acked-by: Dan Murphy <dmurphy@ti.com>
Dan Carpenter Oct. 6, 2020, 5:52 p.m. UTC | #2
On Tue, Oct 06, 2020 at 06:06:00PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently ret is assigned to zero and the following statement checks
> if it is non-zero. This check is redundant and can be removed
> 
> Addresses-Coverity: ("Logically dead code")
> Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/power/supply/bq25980_charger.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c
> index 3995fb7cf060..f04f9acdb13b 100644
> --- a/drivers/power/supply/bq25980_charger.c
> +++ b/drivers/power/supply/bq25980_charger.c
> @@ -613,9 +613,6 @@ static int bq25980_set_battery_property(struct power_supply *psy,
>  	struct bq25980_device *bq = power_supply_get_drvdata(psy);
>  	int ret = 0;

I'm surprised this doesn't generate a set but not used warning.  And
then at the end of the function it could be changed from "return ret;"
to "return 0;"

regards,
dan carpenter
Sebastian Reichel Oct. 8, 2020, 9:35 p.m. UTC | #3
Hi,

On Tue, Oct 06, 2020 at 12:23:06PM -0500, Dan Murphy wrote:
> Colin
> 
> On 10/6/20 12:06 PM, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Currently ret is assigned to zero and the following statement checks
> > if it is non-zero. This check is redundant and can be removed
> > 
> > Addresses-Coverity: ("Logically dead code")
> > Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >   drivers/power/supply/bq25980_charger.c | 3 ---
> >   1 file changed, 3 deletions(-)
> > 
> > diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c
> > index 3995fb7cf060..f04f9acdb13b 100644
> > --- a/drivers/power/supply/bq25980_charger.c
> > +++ b/drivers/power/supply/bq25980_charger.c
> > @@ -613,9 +613,6 @@ static int bq25980_set_battery_property(struct power_supply *psy,
> >   	struct bq25980_device *bq = power_supply_get_drvdata(psy);
> >   	int ret = 0;
> > -	if (ret)
> > -		return ret;
> > -
> >   	switch (psp) {
> >   	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
> >   		ret = bq25980_set_const_charge_curr(bq, val->intval);
> 
> Thanks for the patch
> 
> Acked-by: Dan Murphy <dmurphy@ti.com>

Thanks, queued.

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/power/supply/bq25980_charger.c b/drivers/power/supply/bq25980_charger.c
index 3995fb7cf060..f04f9acdb13b 100644
--- a/drivers/power/supply/bq25980_charger.c
+++ b/drivers/power/supply/bq25980_charger.c
@@ -613,9 +613,6 @@  static int bq25980_set_battery_property(struct power_supply *psy,
 	struct bq25980_device *bq = power_supply_get_drvdata(psy);
 	int ret = 0;
 
-	if (ret)
-		return ret;
-
 	switch (psp) {
 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
 		ret = bq25980_set_const_charge_curr(bq, val->intval);