From 20ac582d0cdf78348650318eeabba5bcd486613f Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Mar 2020 18:05:15 +0100 Subject: [PATCH 1/4] Use &error_abort instead of separate assert() Signed-off-by: Markus Armbruster Message-Id: <20200313170517.22480-2-armbru@redhat.com> Reviewed-by: Peter Maydell Acked-by: Alexander Bulekov Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy [Unused Error *variable deleted] --- block/monitor/block-hmp-cmds.c | 4 +--- target/arm/monitor.c | 8 ++------ tests/qtest/fuzz/qos_fuzz.c | 7 ++----- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index c3a6368dfc..4c8c375172 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -838,10 +838,8 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict) void hmp_info_block_jobs(Monitor *mon, const QDict *qdict) { BlockJobInfoList *list; - Error *err = NULL; - list = qmp_query_block_jobs(&err); - assert(!err); + list = qmp_query_block_jobs(&error_abort); if (!list) { monitor_printf(mon, "No active jobs\n"); diff --git a/target/arm/monitor.c b/target/arm/monitor.c index c2dc7908de..ea6598c412 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -206,9 +206,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, return NULL; } } else { - Error *err = NULL; - arm_cpu_finalize_features(ARM_CPU(obj), &err); - assert(err == NULL); + arm_cpu_finalize_features(ARM_CPU(obj), &error_abort); } expansion_info = g_new0(CpuModelExpansionInfo, 1); @@ -221,12 +219,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, while ((name = cpu_model_advertised_features[i++]) != NULL) { ObjectProperty *prop = object_property_find(obj, name, NULL); if (prop) { - Error *err = NULL; QObject *value; assert(prop->get); - value = object_property_get_qobject(obj, name, &err); - assert(!err); + value = object_property_get_qobject(obj, name, &error_abort); qdict_put_obj(qdict_out, name, value); } diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c index 1a99277d60..af28c92866 100644 --- a/tests/qtest/fuzz/qos_fuzz.c +++ b/tests/qtest/fuzz/qos_fuzz.c @@ -55,10 +55,8 @@ static void qos_set_machines_devices_available(void) QObject *response; QDict *args = qdict_new(); QList *lst; - Error *err = NULL; - qmp_marshal_query_machines(NULL, &response, &err); - assert(!err); + qmp_marshal_query_machines(NULL, &response, &error_abort); lst = qobject_to(QList, response); apply_to_qlist(lst, true); @@ -70,8 +68,7 @@ static void qos_set_machines_devices_available(void) qdict_put_bool(args, "abstract", true); qdict_put_obj(req, "arguments", (QObject *) args); - qmp_marshal_qom_list_types(args, &response, &err); - assert(!err); + qmp_marshal_qom_list_types(args, &response, &error_abort); lst = qobject_to(QList, response); apply_to_qlist(lst, false); qobject_unref(response); From 364effc0eb90f440e0355d6326d46fed8e23fb6a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Mar 2020 18:05:16 +0100 Subject: [PATCH 2/4] hw/misc/ivshmem: Use one Error * variable instead of two Commit fe44dc9180 "migration: disallow migrate_add_blocker during migration" accidentally added a second Error * variable. Use the first one instead. Signed-off-by: Markus Armbruster Message-Id: <20200313170517.22480-3-armbru@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- hw/misc/ivshmem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 1a0fad74e1..a8dc9b377d 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -832,7 +832,6 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp) IVShmemState *s = IVSHMEM_COMMON(dev); Error *err = NULL; uint8_t *pci_conf; - Error *local_err = NULL; /* IRQFD requires MSI */ if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) && @@ -899,9 +898,9 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp) if (!ivshmem_is_master(s)) { error_setg(&s->migration_blocker, "Migration is disabled when using feature 'peer mode' in device 'ivshmem'"); - migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + migrate_add_blocker(s->migration_blocker, &err); + if (err) { + error_propagate(errp, err); error_free(s->migration_blocker); return; } From 526ab8e8630f17f6f412c160d4e9571766960be9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Mar 2020 18:05:17 +0100 Subject: [PATCH 3/4] xen-block: Use one Error * variable instead of two MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While there, tidy up indentation, and add return just for consistency and robustness. Signed-off-by: Markus Armbruster Message-Id: <20200313170517.22480-4-armbru@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Vladimir Sementsov-Ogievskiy [The "while there" cleanups squashed in] --- hw/block/xen-block.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 3885464513..07bb32e22b 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -998,29 +998,27 @@ static void xen_block_device_destroy(XenBackendInstance *backend, XenBlockVdev *vdev = &blockdev->props.vdev; XenBlockDrive *drive = blockdev->drive; XenBlockIOThread *iothread = blockdev->iothread; + Error *local_err = NULL; trace_xen_block_device_destroy(vdev->number); object_unparent(OBJECT(xendev)); if (iothread) { - Error *local_err = NULL; - xen_block_iothread_destroy(iothread, &local_err); if (local_err) { error_propagate_prepend(errp, local_err, - "failed to destroy iothread: "); + "failed to destroy iothread: "); return; } } if (drive) { - Error *local_err = NULL; - xen_block_drive_destroy(drive, &local_err); if (local_err) { error_propagate_prepend(errp, local_err, - "failed to destroy drive: "); + "failed to destroy drive: "); + return; } } } From 709dfb64925ed2b2978bf4c17ab98b2c7a9a05c1 Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Tue, 17 Mar 2020 15:57:41 +0300 Subject: [PATCH 4/4] hw/sd/ssi-sd: fix error handling in ssi_sd_realize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's wrong to use same err object as errp parameter for several function calls without intermediate checking for error: we'll crash if try to set err object twice. Fix that. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200317125741.15301-1-vsementsov@virtuozzo.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- hw/sd/ssi-sd.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index 91db069212..829797b597 100644 --- a/hw/sd/ssi-sd.c +++ b/hw/sd/ssi-sd.c @@ -255,13 +255,25 @@ static void ssi_sd_realize(SSISlave *d, Error **errp) carddev = qdev_create(BUS(&s->sdbus), TYPE_SD_CARD); if (dinfo) { qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err); + if (err) { + goto fail; + } } + object_property_set_bool(OBJECT(carddev), true, "spi", &err); + if (err) { + goto fail; + } + object_property_set_bool(OBJECT(carddev), true, "realized", &err); if (err) { - error_setg(errp, "failed to init SD card: %s", error_get_pretty(err)); - return; + goto fail; } + + return; + +fail: + error_propagate_prepend(errp, err, "failed to init SD card: "); } static void ssi_sd_reset(DeviceState *dev)