diff mbox series

scsi: mpt3sas: Fix compilation warning

Message ID 20200706000450.358443-1-damien.lemoal@wdc.com (mailing list archive)
State Accepted
Headers show
Series scsi: mpt3sas: Fix compilation warning | expand

Commit Message

Damien Le Moal July 6, 2020, 12:04 a.m. UTC
Commit c7e4dd5d84fc ("scsi: mpt3sas: Fix error returns in
BRM_status_show") introduced a compilation warning:

>> drivers/scsi/mpt3sas/mpt3sas_ctl.c:3188:5: warning: Variable 'rc' is
reassigned a value before the old one has been used.
[redundantAssignment]
    rc = snprintf(buf, PAGE_SIZE, "%dn", (backup_rail_monitor_status & 1));
       ^
   drivers/scsi/mpt3sas/mpt3sas_ctl.c:3165:5: note: Variable 'rc' is
   reassigned a value before the old one has been used.
    rc = -EINVAL;
       ^
   drivers/scsi/mpt3sas/mpt3sas_ctl.c:3188:5: note: Variable 'rc' is
   reassigned a value before the old one has been used.
    rc = snprintf(buf, PAGE_SIZE, "%dn", (backup_rail_monitor_status & 1));
       ^

Remove this warning by moving -EINVAL rc assignement inside the error
condition paths.

Fixes: c7e4dd5d84fc ("scsi: mpt3sas: Fix error returns in BRM_status_show")
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/scsi/mpt3sas/mpt3sas_ctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Johannes Thumshirn July 6, 2020, 7:48 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff mbox series

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 70aedd15223c..983e568ff231 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3162,11 +3162,11 @@  BRM_status_show(struct device *cdev, struct device_attribute *attr,
 		goto out;
 	}
 
-	rc = -EINVAL;
 	if (mpt3sas_config_get_iounit_pg3(ioc, &mpi_reply, io_unit_pg3, sz) !=
 	    0) {
 		ioc_err(ioc, "%s: failed reading iounit_pg3\n",
 			__func__);
+		rc = -EINVAL;
 		goto out;
 	}
 
@@ -3174,12 +3174,14 @@  BRM_status_show(struct device *cdev, struct device_attribute *attr,
 	if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
 		ioc_err(ioc, "%s: iounit_pg3 failed with ioc_status(0x%04x)\n",
 			__func__, ioc_status);
+		rc = -EINVAL;
 		goto out;
 	}
 
 	if (io_unit_pg3->GPIOCount < 25) {
 		ioc_err(ioc, "%s: iounit_pg3->GPIOCount less than 25 entries, detected (%d) entries\n",
 			__func__, io_unit_pg3->GPIOCount);
+		rc = -EINVAL;
 		goto out;
 	}