All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH] scsi: mpt3sas: Fix compilation warning
Date: Mon,  6 Jul 2020 09:04:50 +0900	[thread overview]
Message-ID: <20200706000450.358443-1-damien.lemoal@wdc.com> (raw)

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(-)

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;
 	}
 
-- 
2.26.2


             reply	other threads:[~2020-07-06  0:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  0:04 Damien Le Moal [this message]
2020-07-06  7:48 ` [PATCH] scsi: mpt3sas: Fix compilation warning Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200706000450.358443-1-damien.lemoal@wdc.com \
    --to=damien.lemoal@wdc.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.