From: Wu Bo <wubo40@huawei.com>
To: <kbusch@kernel.org>, <axboe@fb.com>, <hch@lst.de>,
<sagi@grimberg.me>, <linux-nvme@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Cc: <linfeilong@huawei.com>, <wubo40@huawei.com>
Subject: [PATCH] nvme-multipath: combine grpid and ANA state checks in nvme_parse_ana_log()
Date: Tue, 8 Jun 2021 12:13:36 +0800 [thread overview]
Message-ID: <1623125616-629270-1-git-send-email-wubo40@huawei.com> (raw)
Hi,
Combine grpid and ANA state checks in nvme_parse_ana_log() to
reduce repetitive code and more intuitive meaning.
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/nvme/host/multipath.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index f81871c..19fe16d 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -522,13 +522,11 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data,
nr_nsids = le32_to_cpu(desc->nnsids);
nsid_buf_size = nr_nsids * sizeof(__le32);
- if (WARN_ON_ONCE(desc->grpid == 0))
+ if (WARN_ON_ONCE(desc->grpid == 0 ||
+ le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
return -EINVAL;
- if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
- return -EINVAL;
- if (WARN_ON_ONCE(desc->state == 0))
- return -EINVAL;
- if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
+ if (WARN_ON_ONCE(desc->state == 0 ||
+ desc->state > NVME_ANA_CHANGE))
return -EINVAL;
offset += sizeof(*desc);
--
2.30.2
next reply other threads:[~2021-06-08 3:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 4:13 Wu Bo [this message]
2021-06-08 4:55 ` Chaitanya Kulkarni
2021-06-08 5:23 ` Christoph Hellwig
2021-06-08 12:30 ` Wu Bo
2021-06-08 12:32 ` Wu Bo
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=1623125616-629270-1-git-send-email-wubo40@huawei.com \
--to=wubo40@huawei.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linfeilong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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
all inboxes | Powered by JetHome®