From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, qemu-block@nongnu.org,
Fam Zheng <famz@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>,
pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH v2] nvme: Make nvme_init error handling code more readable
Date: Mon, 21 May 2018 16:58:34 +0800 [thread overview]
Message-ID: <20180521085834.15632-1-famz@redhat.com> (raw)
Coverity doesn't like the tests under fail label (report CID 1385847).
Reset the fields so the clean up order is more apparent.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
v2: Don't play stupid. [Peter]
---
block/nvme.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/nvme.c b/block/nvme.c
index 6f71122bf5..c2eb9e2a4e 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -566,6 +566,10 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
return ret;
}
+ /* Fields we've not touched should be zero-initialized by block layer
+ * already, but reset it anyway to make the error handling code easier to
+ * reason. */
+ s->regs = NULL;
s->vfio = qemu_vfio_open_pci(device, errp);
if (!s->vfio) {
ret = -EINVAL;
--
2.14.3
next reply other threads:[~2018-05-21 8:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 8:58 Fam Zheng [this message]
2018-05-24 7:46 ` [Qemu-devel] [PATCH v2] nvme: Make nvme_init error handling code more readable Fam Zheng
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=20180521085834.15632-1-famz@redhat.com \
--to=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).