aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:06:03 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:18:08 +0200
commitaf175e85f92c870386ad74f466e29537b79611d3 (patch)
treea2b62ef63640b200b969ff3eb7c0a4c1fd0be013 /hw
parent668f62ec621e4e2919fb7d4caa5d805764c5852d (diff)
error: Eliminate error_propagate() with Coccinelle, part 2
When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. The previous commit did that with a Coccinelle script I consider fairly trustworthy. This commit uses the same script with the matching of return taken out, i.e. we convert if (!foo(..., &err)) { ... error_propagate(errp, err); ... } to if (!foo(..., errp)) { ... ... } This is unsound: @err could still be read between afterwards. I don't know how to express "no read of @err without an intervening write" in Coccinelle. Instead, I manually double-checked for uses of @err. Suboptimal line breaks tweaked manually. qdev_realize() simplified further to placate scripts/checkpatch.pl. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200707160613.848843-36-armbru@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/intc/xics.c4
-rw-r--r--hw/vfio/pci.c3
2 files changed, 2 insertions, 5 deletions
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index c1feb649fb..68f9d44feb 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -376,7 +376,6 @@ static const TypeInfo icp_info = {
Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
{
- Error *local_err = NULL;
Object *obj;
obj = object_new(type);
@@ -384,9 +383,8 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
object_unref(obj);
object_property_set_link(obj, ICP_PROP_XICS, OBJECT(xi), &error_abort);
object_property_set_link(obj, ICP_PROP_CPU, cpu, &error_abort);
- if (!qdev_realize(DEVICE(obj), NULL, &local_err)) {
+ if (!qdev_realize(DEVICE(obj), NULL, errp)) {
object_unparent(obj);
- error_propagate(errp, local_err);
obj = NULL;
}
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 6fde80cb9a..2e561c06d6 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -292,8 +292,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev);
if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0,
- VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) {
- error_propagate(errp, err);
+ VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) {
qemu_set_fd_handler(fd, NULL, NULL, vdev);
event_notifier_cleanup(&vdev->intx.interrupt);
return -errno;