Skip to contentSkip to conversation

scsi: sd: Fix unsigned expression compared with zero in sd_spinup_disk()

PATCH In review Jiapeng Chong 2 participants 2 messages Jul 4, 2024 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: sd: Fix unsigned expression compared with zero in sd_spinup_disk()

The return value from the call to scsi_execute_cmd() is int. However, the return value is being assigned to an unsigned int variable 'the_result', so making 'the_result' an int.

./drivers/scsi/sd.c:2333:6-16: WARNING: Unsigned expression compared with zero: the_result > 0.

---
Changes in v2:
-Refine the title to make it more precise.

 drivers/scsi/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd.c +1 -1
index 979795dad62b..ade8c6cca295 100644
@@ -2396,7 +2396,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 	static const u8 cmd[10] = { TEST_UNIT_READY };
 	unsigned long spintime_expire = 0;
 	int spintime, sense_valid = 0;
-	unsigned int the_result;
+	int the_result;
 	struct scsi_sense_hdr sshdr;
 	struct scsi_failure failure_defs[] = {
 		/* Do not retry Medium Not Present */
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 9 lines · Jiapeng Chong

The return value from the call to scsi_execute_cmd() is int. However, the return value is being assigned to an unsigned int variable 'the_result', so making 'the_result' an int.

./drivers/scsi/sd.c:2333:6-16: WARNING: Unsigned expression compared with zero: the_result > 0.

The following is missing from this patch:
- An explanation of why this patch fixes a read of uninitialized data.
- Fixed: and Cc: stable tags.

Thanks,

Bart.