Skip to contentSkip to conversation

ata: pata_ali: remove redundant return statement

PATCH In review Colin Ian King 2 participants 3 messages Jan 12, 2022 – Jan 13, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: pata_ali: remove redundant return statement

A return statement is unnecessarily complicated, currently value in variable mask is bitwise-masked and the variable is being updated and then returned. Just updating the mask is all that is required as the following statement is a return.

---
 drivers/ata/pata_ali.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_ali.c +1 -1
index ab28a6707b94..1b90cda27246 100644
@@ -123,7 +123,7 @@ static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask)
 		mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
 	ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 	if (strstr(model_num, "WDC"))
-		return mask &= ~ATA_MASK_UDMA;
+		mask &= ~ATA_MASK_UDMA;
 	return mask;
 }
 
Signature · 1 line
2.33.1
#1 lore raw
Quoted 15 lines · Colin Ian King

A return statement is unnecessarily complicated, currently value in variable mask is bitwise-masked and the variable is being updated and then returned. Just updating the mask is all that is required as the following statement is a return.

---
 drivers/ata/pata_ali.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_ali.c +0 -0
index ab28a6707b94..1b90cda27246 100644

drivers/ata/pata_ali.c static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask) · line 126

Quoted 4 lines
drivers/ata/pata_ali.c +0 -1
@@ -123,7 +123,7 @@ static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask)
 		mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
 	ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 	if (strstr(model_num, "WDC"))
-		return mask &= ~ATA_MASK_UDMA;

Yeah, not to mention that is really ugly as the return should really have been:

return mask & ~ATA_MASK_UDMA;

drivers/ata/pata_ali.c static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask) · line 129

Quoted 4 lines
drivers/ata/pata_ali.c +1 -0
+		mask &= ~ATA_MASK_UDMA;
 	return mask;
 }
 

Will queue this up.

Signature · 2 lines
Damien Le Moal
Western Digital Research
#2 lore raw
Quoted 24 lines · Damien Le Moal
Quoted 15 lines · Colin Ian King

A return statement is unnecessarily complicated, currently value in variable mask is bitwise-masked and the variable is being updated and then returned. Just updating the mask is all that is required as the following statement is a return.

---
  drivers/ata/pata_ali.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_ali.c +0 -0
index ab28a6707b94..1b90cda27246 100644

drivers/ata/pata_ali.c static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask) · line 126

Quoted 4 lines
drivers/ata/pata_ali.c +0 -1
@@ -123,7 +123,7 @@ static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask)
  		mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
  	ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
  	if (strstr(model_num, "WDC"))
-		return mask &= ~ATA_MASK_UDMA;

Yeah, not to mention that is really ugly as the return should really have been:

Quoted 1 line

return mask & ~ATA_MASK_UDMA;

Yep, I did think of that as the original intention, but two return statements one after the other was equally as ugly. It was a 50/50 choice of what was perceived as the better fix :-)

Quoted 8 lines

drivers/ata/pata_ali.c static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask) · line 129

Quoted 5 lines
drivers/ata/pata_ali.c +1 -0
+		mask &= ~ATA_MASK_UDMA;
  	return mask;
  }
 

Will queue this up.

Thank you.