Skip to contentSkip to conversation

habanalabs/gaudi: remove redundant assignment to variable err

PATCH In review Colin King 3 participants 3 messages Jun 3, 2021 – Jun 6, 2021

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 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")

---
 drivers/misc/habanalabs/gaudi/gaudi.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/misc/habanalabs/gaudi/gaudi.c +0 -3
index 9e4a6bb3acd1..22f220859b46 100644
@@ -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;
 	}
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 17 lines · Colin King

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")

---
 drivers/misc/habanalabs/gaudi/gaudi.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/misc/habanalabs/gaudi/gaudi.c +0 -0
index 9e4a6bb3acd1..22f220859b46 100644

drivers/misc/habanalabs/gaudi/gaudi.c static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device, · line 7383

Quoted 8 lines
drivers/misc/habanalabs/gaudi/gaudi.c +0 -3
@@ -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

Reviewed-by
#2 lore raw
Quoted 33 lines · Dan Carpenter
Quoted 17 lines · Colin King

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")

---
 drivers/misc/habanalabs/gaudi/gaudi.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/misc/habanalabs/gaudi/gaudi.c +0 -0
index 9e4a6bb3acd1..22f220859b46 100644

drivers/misc/habanalabs/gaudi/gaudi.c static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device, · line 7383

Quoted 8 lines
drivers/misc/habanalabs/gaudi/gaudi.c +0 -3
@@ -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.

Quoted 6 lines

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: