From: trix@redhat.com
To: hare@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Tom Rix <trix@redhat.com>
Subject: [PATCH] scsi: myrb: reorder status check of myrb_get_rbld_progress()
Date: Mon, 16 Aug 2021 13:10:42 -0700 [thread overview]
Message-ID: <20210816201042.1294196-1-trix@redhat.com> (raw)
From: Tom Rix <trix@redhat.com>
Static analysis reports this representative problem
myrb.c:1909: warning: The left operand of '!=' is a garbage value
if (rbld_buf.ldev_num != sdev->id ||
~~~~~~~~~~~~~~~~~ ^
myrb_get_rbld_progress() can return without setting rbld_buf.ldev_num.
Reorder the checks in the if () statement so a failure short circuits
the rbld_buf.ldev_num check.
Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/scsi/myrb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index a4a88323e0209..132aec8e51e5b 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -1906,8 +1906,8 @@ static ssize_t rebuild_show(struct device *dev,
status = myrb_get_rbld_progress(cb, &rbld_buf);
- if (rbld_buf.ldev_num != sdev->id ||
- status != MYRB_STATUS_SUCCESS)
+ if (status != MYRB_STATUS_SUCCESS ||
+ rbld_buf.ldev_num != sdev->id)
return snprintf(buf, 32, "not rebuilding\n");
return snprintf(buf, 32, "rebuilding block %u of %u\n",
--
2.26.3
reply other threads:[~2021-08-16 20:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210816201042.1294196-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=hare@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).