Skip to contentSkip to conversation

scsi: Remove ignoring unreachable code warning

PATCH Applied Yang Li 2 participants 2 messages Mar 1, 2022 – Mar 19, 2022 SCSI

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 scsi: Remove ignoring unreachable code warning

The smatch tool reported the following warning:
drivers/scsi/scsi_error.c:1988 scsi_decide_disposition() warn: ignoring unreachable code.

Remove the "default:return FAILED;" instead of "return FAILED;" reported by smatch, because compilers can provide more useful diagnostics about switch/case statements that do not have a default statement, especially if the "switch" applies to a value with enumeration type.

---
 drivers/scsi/scsi_error.c | 2 --
 1 file changed, 2 deletions(-)
drivers/scsi/scsi_error.c +0 -2
index 9c237b223e63..ee752b4512f8 100644
@@ -1982,8 +1982,6 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd)
 			    "reservation conflict\n");
 		set_host_byte(scmd, DID_NEXUS_FAILURE);
 		return SUCCESS; /* causes immediate i/o error */
-	default:
-		return FAILED;
 	}
 	return FAILED;
 
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 10 lines · Yang Li

The smatch tool reported the following warning:
drivers/scsi/scsi_error.c:1988 scsi_decide_disposition() warn: ignoring unreachable code.

Remove the "default:return FAILED;" instead of "return FAILED;" reported by smatch, because compilers can provide more useful diagnostics about switch/case statements that do not have a default statement, especially if the "switch" applies to a value with enumeration type.

[...]

Applied to 5.18/scsi-queue, thanks!

[1/1] scsi: Remove ignoring unreachable code warning

      https://git.kernel.org/mkp/scsi/c/e1b353e7a31d
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering