* [Qemu-devel] [PATCH] pci: Set err to errp directly rather than through error_porpagate()
@ 2017-05-26 8:29 Mao Zhongyi
2017-05-26 9:43 ` Igor Mammedov
0 siblings, 1 reply; 5+ messages in thread
From: Mao Zhongyi @ 2017-05-26 8:29 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, marcel, armbru
ioh3420_interrupts_init() and its callers, rp_realize() and
pci_qdev_realize() fill error message to local_err, then
propagate it to errp by error_porpagate(), which's not necessary.
So eliminate it and pass errp directly instead of local_err.
Of course, error_propagate() also will be removed.
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
---
hw/pci-bridge/ioh3420.c | 4 +---
hw/pci-bridge/pcie_root_port.c | 7 ++-----
hw/pci/pci.c | 11 ++++-------
3 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index da4e5bd..5f56a2f 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -64,15 +64,13 @@ static uint8_t ioh3420_aer_vector(const PCIDevice *d)
static int ioh3420_interrupts_init(PCIDevice *d, Error **errp)
{
int rc;
- Error *local_err = NULL;
rc = msi_init(d, IOH_EP_MSI_OFFSET, IOH_EP_MSI_NR_VECTOR,
IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT,
- &local_err);
+ errp);
if (rc < 0) {
assert(rc == -ENOTSUP);
- error_propagate(errp, local_err);
}
return rc;
diff --git a/hw/pci-bridge/pcie_root_port.c b/hw/pci-bridge/pcie_root_port.c
index cf36318..9022996 100644
--- a/hw/pci-bridge/pcie_root_port.c
+++ b/hw/pci-bridge/pcie_root_port.c
@@ -59,7 +59,6 @@ static void rp_realize(PCIDevice *d, Error **errp)
PCIDeviceClass *dc = PCI_DEVICE_GET_CLASS(d);
PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(d);
int rc;
- Error *local_err = NULL;
pci_config_set_interrupt_pin(d->config, 1);
pci_bridge_initfn(d, TYPE_PCIE_BUS);
@@ -72,9 +71,8 @@ static void rp_realize(PCIDevice *d, Error **errp)
}
if (rpc->interrupts_init) {
- rc = rpc->interrupts_init(d, &local_err);
+ rc = rpc->interrupts_init(d, errp);
if (rc < 0) {
- error_propagate(errp, local_err);
goto err_bridge;
}
}
@@ -98,9 +96,8 @@ static void rp_realize(PCIDevice *d, Error **errp)
}
rc = pcie_aer_init(d, PCI_ERR_VER, rpc->aer_offset,
- PCI_ERR_SIZEOF, &local_err);
+ PCI_ERR_SIZEOF, errp);
if (rc < 0) {
- error_propagate(errp, local_err);
goto err;
}
pcie_aer_root_init(d);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 98ccc27..0d4a3ff 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1982,7 +1982,6 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
{
PCIDevice *pci_dev = (PCIDevice *)qdev;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
- Error *local_err = NULL;
PCIBus *bus;
bool is_default_rom;
@@ -1999,9 +1998,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
return;
if (pc->realize) {
- pc->realize(pci_dev, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ pc->realize(pci_dev, errp);
+ if (errp && *errp) {
do_pci_unregister_device(pci_dev);
return;
}
@@ -2014,9 +2012,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
is_default_rom = true;
}
- pci_add_option_rom(pci_dev, is_default_rom, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ pci_add_option_rom(pci_dev, is_default_rom, errp);
+ if (errp && *errp) {
pci_qdev_unrealize(DEVICE(pci_dev), NULL);
return;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] pci: Set err to errp directly rather than through error_porpagate()
2017-05-26 8:29 [Qemu-devel] [PATCH] pci: Set err to errp directly rather than through error_porpagate() Mao Zhongyi
@ 2017-05-26 9:43 ` Igor Mammedov
2017-05-26 11:08 ` Mao Zhongyi
2017-05-29 7:51 ` Markus Armbruster
0 siblings, 2 replies; 5+ messages in thread
From: Igor Mammedov @ 2017-05-26 9:43 UTC (permalink / raw)
To: Mao Zhongyi; +Cc: qemu-devel, marcel, armbru, mst
On Fri, 26 May 2017 16:29:25 +0800
Mao Zhongyi <maozy.fnst@cn.fujitsu.com> wrote:
> ioh3420_interrupts_init() and its callers, rp_realize() and
> pci_qdev_realize() fill error message to local_err, then
> propagate it to errp by error_porpagate(), which's not necessary.
> So eliminate it and pass errp directly instead of local_err.
> Of course, error_propagate() also will be removed.
>
> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
> ---
[...]
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 98ccc27..0d4a3ff 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1982,7 +1982,6 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
> {
> PCIDevice *pci_dev = (PCIDevice *)qdev;
> PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
> - Error *local_err = NULL;
> PCIBus *bus;
> bool is_default_rom;
>
> @@ -1999,9 +1998,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
> return;
>
> if (pc->realize) {
> - pc->realize(pci_dev, &local_err);
> - if (local_err) {
> - error_propagate(errp, local_err);
> + pc->realize(pci_dev, errp);
> + if (errp && *errp) {
> do_pci_unregister_device(pci_dev);
> return;
> }
> @@ -2014,9 +2012,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
> is_default_rom = true;
> }
>
> - pci_add_option_rom(pci_dev, is_default_rom, &local_err);
> - if (local_err) {
> - error_propagate(errp, local_err);
> + pci_add_option_rom(pci_dev, is_default_rom, errp);
> + if (errp && *errp) {
> pci_qdev_unrealize(DEVICE(pci_dev), NULL);
> return;
> }
dropping local_error here looks wrong since it's used
to check error status inside these functions and to undo
side effects in case of failure.
consider if caller pass errp = NULL
then error handling path won't be executed.
So keep the rest of the patch but drop above hunks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] pci: Set err to errp directly rather than through error_porpagate()
2017-05-26 9:43 ` Igor Mammedov
@ 2017-05-26 11:08 ` Mao Zhongyi
2017-05-29 7:51 ` Markus Armbruster
1 sibling, 0 replies; 5+ messages in thread
From: Mao Zhongyi @ 2017-05-26 11:08 UTC (permalink / raw)
To: Igor Mammedov; +Cc: qemu-devel, marcel, armbru, mst
Hi, Markus
On 05/26/2017 05:43 PM, Igor Mammedov wrote:
> On Fri, 26 May 2017 16:29:25 +0800
> Mao Zhongyi <maozy.fnst@cn.fujitsu.com> wrote:
>
>> ioh3420_interrupts_init() and its callers, rp_realize() and
>> pci_qdev_realize() fill error message to local_err, then
>> propagate it to errp by error_porpagate(), which's not necessary.
>> So eliminate it and pass errp directly instead of local_err.
>> Of course, error_propagate() also will be removed.
>>
>> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
>> ---
> [...]
>
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index 98ccc27..0d4a3ff 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -1982,7 +1982,6 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
>> {
>> PCIDevice *pci_dev = (PCIDevice *)qdev;
>> PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
>> - Error *local_err = NULL;
>> PCIBus *bus;
>> bool is_default_rom;
>>
>> @@ -1999,9 +1998,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
>> return;
>>
>> if (pc->realize) {
>> - pc->realize(pci_dev, &local_err);
>> - if (local_err) {
>> - error_propagate(errp, local_err);
>> + pc->realize(pci_dev, errp);
>> + if (errp && *errp) {
>> do_pci_unregister_device(pci_dev);
>> return;
>> }
>> @@ -2014,9 +2012,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
>> is_default_rom = true;
>> }
>>
>> - pci_add_option_rom(pci_dev, is_default_rom, &local_err);
>> - if (local_err) {
>> - error_propagate(errp, local_err);
>> + pci_add_option_rom(pci_dev, is_default_rom, errp);
>> + if (errp && *errp) {
>> pci_qdev_unrealize(DEVICE(pci_dev), NULL);
>> return;
>> }
>
> dropping local_error here looks wrong since it's used
> to check error status inside these functions and to undo
> side effects in case of failure.
>
> consider if caller pass errp = NULL
> then error handling path won't be executed.
Thanks for you detailed explanation, I ignored this question
actually. The specified error message will not be converted to
Error. Because error handling function returned directly when
caller pass errp = NULL, right?
> So keep the rest of the patch but drop above hunks.
I will drop this part of wrong process and commit the next
version right away.
Thanks a lot.
Mao
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] pci: Set err to errp directly rather than through error_porpagate()
2017-05-26 9:43 ` Igor Mammedov
2017-05-26 11:08 ` Mao Zhongyi
@ 2017-05-29 7:51 ` Markus Armbruster
2017-05-31 1:38 ` Mao Zhongyi
1 sibling, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2017-05-29 7:51 UTC (permalink / raw)
To: Igor Mammedov; +Cc: Mao Zhongyi, marcel, mst, qemu-devel
Igor Mammedov <imammedo@redhat.com> writes:
> On Fri, 26 May 2017 16:29:25 +0800
> Mao Zhongyi <maozy.fnst@cn.fujitsu.com> wrote:
>
>> ioh3420_interrupts_init() and its callers, rp_realize() and
>> pci_qdev_realize() fill error message to local_err, then
>> propagate it to errp by error_porpagate(), which's not necessary.
>> So eliminate it and pass errp directly instead of local_err.
>> Of course, error_propagate() also will be removed.
>>
>> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
>> ---
> [...]
>
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index 98ccc27..0d4a3ff 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -1982,7 +1982,6 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
>> {
>> PCIDevice *pci_dev = (PCIDevice *)qdev;
>> PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
>> - Error *local_err = NULL;
>> PCIBus *bus;
>> bool is_default_rom;
>>
>> @@ -1999,9 +1998,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
>> return;
>>
>> if (pc->realize) {
>> - pc->realize(pci_dev, &local_err);
>> - if (local_err) {
>> - error_propagate(errp, local_err);
>> + pc->realize(pci_dev, errp);
>> + if (errp && *errp) {
>> do_pci_unregister_device(pci_dev);
>> return;
>> }
>> @@ -2014,9 +2012,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
>> is_default_rom = true;
>> }
>>
>> - pci_add_option_rom(pci_dev, is_default_rom, &local_err);
>> - if (local_err) {
>> - error_propagate(errp, local_err);
>> + pci_add_option_rom(pci_dev, is_default_rom, errp);
>> + if (errp && *errp) {
>> pci_qdev_unrealize(DEVICE(pci_dev), NULL);
>> return;
>> }
>
> dropping local_error here looks wrong since it's used
> to check error status inside these functions and to undo
> side effects in case of failure.
>
> consider if caller pass errp = NULL
> then error handling path won't be executed.
Exactly. The big comment in include/qapi/error.h explains this and
more.
> So keep the rest of the patch but drop above hunks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] pci: Set err to errp directly rather than through error_porpagate()
2017-05-29 7:51 ` Markus Armbruster
@ 2017-05-31 1:38 ` Mao Zhongyi
0 siblings, 0 replies; 5+ messages in thread
From: Mao Zhongyi @ 2017-05-31 1:38 UTC (permalink / raw)
To: Markus Armbruster, Igor Mammedov; +Cc: marcel, mst, qemu-devel
Hi, Markus
On 05/29/2017 03:51 PM, Markus Armbruster wrote:
> Igor Mammedov <imammedo@redhat.com> writes:
>
>> On Fri, 26 May 2017 16:29:25 +0800
>> Mao Zhongyi <maozy.fnst@cn.fujitsu.com> wrote:
>>
>>> ioh3420_interrupts_init() and its callers, rp_realize() and
>>> pci_qdev_realize() fill error message to local_err, then
>>> propagate it to errp by error_porpagate(), which's not necessary.
>>> So eliminate it and pass errp directly instead of local_err.
>>> Of course, error_propagate() also will be removed.
>>>
>>> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
>>> ---
[...]
>>
>> dropping local_error here looks wrong since it's used
>> to check error status inside these functions and to undo
>> side effects in case of failure.
>>
>> consider if caller pass errp = NULL
>> then error handling path won't be executed.
>
> Exactly. The big comment in include/qapi/error.h explains this and
> more.
Thanks for providing the specific path, I have seen detailed comments
that have really helped me.
Thanks,
Mao
>
>> So keep the rest of the patch but drop above hunks.
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-31 1:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 8:29 [Qemu-devel] [PATCH] pci: Set err to errp directly rather than through error_porpagate() Mao Zhongyi
2017-05-26 9:43 ` Igor Mammedov
2017-05-26 11:08 ` Mao Zhongyi
2017-05-29 7:51 ` Markus Armbruster
2017-05-31 1:38 ` Mao Zhongyi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.