Received: from eggs.gnu.org ([2001:4830:134:3::10]:35310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fKgeW-0006G2-Ak for qemu-devel@nongnu.org; Mon, 21 May 2018 04:58:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fKgeV-00039E-Kn for qemu-devel@nongnu.org; Mon, 21 May 2018 04:58:48 -0400 From: Fam Zheng Date: Mon, 21 May 2018 16:58:34 +0800 Message-Id: <20180521085834.15632-1-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2] nvme: Make nvme_init error handling code more readable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, qemu-block@nongnu.org, Fam Zheng , Kevin Wolf , Max Reitz , pbonzini@redhat.com 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 --- 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