diff mbox series

scsi: dc395x: Remove leftover if statement in reselect()

Message ID 20250429-scsi-dc395x-fix-uninit-var-v1-1-25215d481020@kernel.org
State New
Headers show
Series scsi: dc395x: Remove leftover if statement in reselect() | expand

Commit Message

Nathan Chancellor April 30, 2025, 12:46 a.m. UTC
Clang warns (or errors with CONFIG_WERROR=y):

  drivers/scsi/dc395x.c:2553:6: error: variable 'id' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
   2553 |         if (!(rsel_tar_lun_id & (IDENTIFY_BASE << 8)))
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/scsi/dc395x.c:2556:22: note: uninitialized use occurs here
   2556 |         dcb = find_dcb(acb, id, lun);
        |                             ^~
  drivers/scsi/dc395x.c:2553:2: note: remove the 'if' if its condition is always true
   2553 |         if (!(rsel_tar_lun_id & (IDENTIFY_BASE << 8)))
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   2554 |         id = rsel_tar_lun_id & 0xff;

This if statement only existed for a debugging print but it was not
removed with the debugging print in a recent cleanup, leading to id only
being initialized when the if condition is true. Remove the if
statement to ensure id is always initialized, clearing up the warning.

Fixes: 62b434b0db2c ("scsi: dc395x: Remove DEBUG conditional compilation")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/scsi/dc395x.c | 1 -
 1 file changed, 1 deletion(-)


---
base-commit: e142de4aac2aae697d7e977b01e7a889e9f454df
change-id: 20250429-scsi-dc395x-fix-uninit-var-c1cfd889a63d

Best regards,

Comments

Martin K. Petersen May 6, 2025, 2:01 a.m. UTC | #1
Nathan,

>   drivers/scsi/dc395x.c:2553:6: error: variable 'id' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>    2553 |         if (!(rsel_tar_lun_id & (IDENTIFY_BASE << 8)))
>         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Applied to 6.16/scsi-staging, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 95145b9d9ce3..96b335c92603 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -2550,7 +2550,6 @@  static void reselect(struct AdapterCtlBlk *acb)
 		}
 	}
 	/* Read Reselected Target Id and LUN */
-	if (!(rsel_tar_lun_id & (IDENTIFY_BASE << 8)))
 	id = rsel_tar_lun_id & 0xff;
 	lun = (rsel_tar_lun_id >> 8) & 7;
 	dcb = find_dcb(acb, id, lun);