qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, "Keith Busch" <kbusch@kernel.org>,
	qemu-block@nongnu.org, "Klaus Jensen" <k.jensen@samsung.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v3 1/2] hw/nvme: fix incorrect use of errp/local_err
Date: Fri, 11 Nov 2022 07:41:13 +0100	[thread overview]
Message-ID: <Y23uiV5Ue2YKaIS7@cormorant.local> (raw)
In-Reply-To: <87iljmdmlk.fsf@pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]

On Nov 11 07:36, Markus Armbruster wrote:
> Klaus Jensen <its@irrelevant.dk> writes:
> 
> > From: Klaus Jensen <k.jensen@samsung.com>
> >
> > Remove an unnecessary local Error value in nvme_realize(). In the
> > process, change nvme_check_constraints() into returning a bool.
> >
> > Finally, removing the local Error value also fixes a bug where an error
> > returned from nvme_init_subsys() would be lost.
> 
> Would it be lost?  It's the hunk below:
> 
> > Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> > ---
> >  hw/nvme/ctrl.c | 48 +++++++++++++++++++++++-------------------------
> >  1 file changed, 23 insertions(+), 25 deletions(-)
> >
> > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> > index ac3885ce5079..a5c0a5fa6ce2 100644
> > --- a/hw/nvme/ctrl.c
> > +++ b/hw/nvme/ctrl.c
> 
> [...]
> 
> > @@ -7586,7 +7585,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>    static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>    {
>        NvmeCtrl *n = NVME(pci_dev);
>        NvmeNamespace *ns;
>        Error *local_err = NULL;
> 
> @local_err is null.
> 
>        NvmeCtrl *pn = NVME(pcie_sriov_get_pf(pci_dev));
> 
>        if (pci_is_vf(pci_dev)) {
>            /*
>             * VFs derive settings from the parent. PF's lifespan exceeds
>             * that of VF's, so it's safe to share params.serial.
>             */
>            memcpy(&n->params, &pn->params, sizeof(NvmeParams));
>            n->subsys = pn->subsys;
>        }
> 
>        nvme_check_constraints(n, &local_err);
>        if (local_err) {
>            error_propagate(errp, local_err);
>            return;
>        }
> 
> @local_err still is null.
> 
>        qbus_init(&n->bus, sizeof(NvmeBus), TYPE_NVME_BUS,
> >                &pci_dev->qdev, n->parent_obj.qdev.id);
> >  
> >      if (nvme_init_subsys(n, errp)) {
> > -        error_propagate(errp, local_err);
> 
> Since @local_err is null, this error_propagate() does nothing.  The
> error from nvme_init_subsys() remains in @errp.
> 

Oh, right. Thanks.

I misread the function documentation, getting the impression that it
would overwrite dst_errp regardless of the value of local_err.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-11-11  6:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 22:08 [PATCH v3 0/2] hw/nvme: errp fixes Klaus Jensen
2022-11-10 22:08 ` [PATCH v3 1/2] hw/nvme: fix incorrect use of errp/local_err Klaus Jensen
2022-11-11  6:36   ` Markus Armbruster
2022-11-11  6:41     ` Klaus Jensen [this message]
2022-11-11  6:55       ` Markus Armbruster
2022-11-11  7:09         ` Klaus Jensen
2022-11-11 11:17           ` Markus Armbruster
2022-11-10 22:08 ` [PATCH v3 2/2] hw/nvme: cleanup error reporting in nvme_init_pci() Klaus Jensen
2022-11-11 11:40   ` Philippe Mathieu-Daudé
2022-11-11 12:32     ` Klaus Jensen
2022-11-11 12:56       ` Philippe Mathieu-Daudé

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=Y23uiV5Ue2YKaIS7@cormorant.local \
    --to=its@irrelevant.dk \
    --cc=armbru@redhat.com \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=philmd@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).