qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Qemu-block <qemu-block@nongnu.org>, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] nvme: Make nvme_init error handling code more readable
Date: Mon, 21 May 2018 16:56:33 +0800	[thread overview]
Message-ID: <20180521085633.GA12591@lemon.usersys.redhat.com> (raw)
In-Reply-To: <CAFEAcA9oCa926wr=-GL0uEUv3kEs2-X0LGfheY95raji13ckBQ@mail.gmail.com>

On Mon, 05/21 09:35, Peter Maydell wrote:
> On 21 May 2018 at 07:35, Fam Zheng <famz@redhat.com> wrote:
> > 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>
> > ---
> >  block/nvme.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/block/nvme.c b/block/nvme.c
> > index 6f71122bf5..8239b920c8 100644
> > --- a/block/nvme.c
> > +++ b/block/nvme.c
> > @@ -560,6 +560,13 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
> >      qemu_co_queue_init(&s->dma_flush_queue);
> >      s->nsid = namespace;
> >      s->aio_context = bdrv_get_aio_context(bs);
> > +
> > +    /* Fields we've not touched should be zero-initialized by block layer
> > +     * already, but reset them anyway to make the error handling code easier to
> > +     * reason. */
> > +    s->regs = NULL;
> > +    s->vfio = NULL;
> > +
> >      ret = event_notifier_init(&s->irq_notifier, 0);
> >      if (ret) {
> >          error_setg(errp, "Failed to init event notifier");
> 
> I suspect that either coverity or some compilers will complain that
> the assignment to s->vfio here is redundant, because we'll either
> return early without looking at it, or we'll get to the assignment
>  s->vfio = qemu_vfio_open_pci(...)
> which overrides it.

Hmm, okay, the compiler wants you to be at least as smart as it is, but no
smarter! I will revise the patch.

Fam

  reply	other threads:[~2018-05-21  8:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21  6:35 [Qemu-devel] [PATCH] nvme: Make nvme_init error handling code more readable Fam Zheng
2018-05-21  8:35 ` Peter Maydell
2018-05-21  8:56   ` Fam Zheng [this message]
2018-05-24 17:16 ` Paolo Bonzini
2018-05-25  2:16   ` Fam Zheng
2018-05-25  5:47     ` Markus Armbruster
2018-05-25  6:25       ` Fam Zheng
2018-05-25  7:27         ` Markus Armbruster
2018-05-25 13:07         ` Eric Blake

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=20180521085633.GA12591@lemon.usersys.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).