2021-06-03 13:16:30

by Colin King

[permalink] [raw]
Subject: [PATCH] habanalabs/gaudi: remove redundant assignment to variable err

From: Colin Ian King <[email protected]>

The variable err is being assigned a value that is never read, the
assignment is redundant and can be removed. Also remove some empty
lines.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <[email protected]>
---
drivers/misc/habanalabs/gaudi/gaudi.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
index 9e4a6bb3acd1..22f220859b46 100644
--- a/drivers/misc/habanalabs/gaudi/gaudi.c
+++ b/drivers/misc/habanalabs/gaudi/gaudi.c
@@ -7379,9 +7379,6 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
device, ch, hbm_ecc_data->first_addr, type,
hbm_ecc_data->sec_cont_cnt, hbm_ecc_data->sec_cnt,
hbm_ecc_data->dec_cnt);
-
- err = 1;
-
return 0;
}

--
2.31.1


2021-06-04 08:06:41

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] habanalabs/gaudi: remove redundant assignment to variable err

On Thu, Jun 03, 2021 at 02:12:10PM +0100, Colin King wrote:
> From: Colin Ian King <[email protected]>
>
> The variable err is being assigned a value that is never read, the
> assignment is redundant and can be removed. Also remove some empty
> lines.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <[email protected]>
> ---
> drivers/misc/habanalabs/gaudi/gaudi.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
> index 9e4a6bb3acd1..22f220859b46 100644
> --- a/drivers/misc/habanalabs/gaudi/gaudi.c
> +++ b/drivers/misc/habanalabs/gaudi/gaudi.c
> @@ -7379,9 +7379,6 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
> device, ch, hbm_ecc_data->first_addr, type,
> hbm_ecc_data->sec_cont_cnt, hbm_ecc_data->sec_cnt,
> hbm_ecc_data->dec_cnt);
> -
> - err = 1;
> -
> return 0;
> }

Not related to your patch (which seems fine), but I always feel like
there should be a rule that function which return a mix of negative
error codes and either zero or one on success should have to have
documentation explaining why.

It's impossible to tell from the context here and neither of the callers
check the return. :P

regards,
dan carpenter

2021-06-06 08:36:09

by Oded Gabbay

[permalink] [raw]
Subject: Re: [PATCH] habanalabs/gaudi: remove redundant assignment to variable err

On Fri, Jun 4, 2021 at 11:05 AM Dan Carpenter <[email protected]> wrote:
>
> On Thu, Jun 03, 2021 at 02:12:10PM +0100, Colin King wrote:
> > From: Colin Ian King <[email protected]>
> >
> > The variable err is being assigned a value that is never read, the
> > assignment is redundant and can be removed. Also remove some empty
> > lines.
> >
> > Addresses-Coverity: ("Unused value")
> > Signed-off-by: Colin Ian King <[email protected]>
> > ---
> > drivers/misc/habanalabs/gaudi/gaudi.c | 3 ---
> > 1 file changed, 3 deletions(-)
> >
> > diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
> > index 9e4a6bb3acd1..22f220859b46 100644
> > --- a/drivers/misc/habanalabs/gaudi/gaudi.c
> > +++ b/drivers/misc/habanalabs/gaudi/gaudi.c
> > @@ -7379,9 +7379,6 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
> > device, ch, hbm_ecc_data->first_addr, type,
> > hbm_ecc_data->sec_cont_cnt, hbm_ecc_data->sec_cnt,
> > hbm_ecc_data->dec_cnt);
> > -
> > - err = 1;
> > -
> > return 0;
> > }
>
> Not related to your patch (which seems fine), but I always feel like
> there should be a rule that function which return a mix of negative
> error codes and either zero or one on success should have to have
> documentation explaining why.
>
> It's impossible to tell from the context here and neither of the callers
> check the return. :P
>
> regards,
> dan carpenter
>
I agree and I will change the function to return only 0 on success, or
standard error value on error.

Anyway, this patch is:
Reviewed-by: Oded Gabbay <[email protected]>