qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/2] hw/nvme: fix incorrect use of errp/local_err


From: Markus Armbruster
Subject: Re: [PATCH v3 1/2] hw/nvme: fix incorrect use of errp/local_err
Date: Fri, 11 Nov 2022 07:55:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Klaus Jensen <its@irrelevant.dk> writes:

> 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.

Happens :)

If you have suggestions on improving the doc, shoot.

This commit's message could perhaps be adjusted like

    hw/nvme: Clean up confused use of errp/local_err

    Remove an unnecessary local Error value in nvme_realize(). In the
    process, change nvme_check_constraints() to return a bool.

What do you think?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]