Minor error handling cleanups
cover Minor error handling cleanups
Markus Armbruster (3):
Use &error_abort instead of separate assert() hw/misc/ivshmem: Use one Error * variable instead of two
xen-block: Use one Error * variable instead of two
block/monitor/block-hmp-cmds.c | 4 +--- hw/block/xen-block.c | 5 +---- hw/misc/ivshmem.c | 7 +++---- target/arm/monitor.c | 8 ++------ tests/qtest/fuzz/qos_fuzz.c | 6 ++---- 5 files changed, 9 insertions(+), 21 deletions(-)
Signature · 1 line
2.21.1
PATCH 1/3 Use &error_abort instead of separate assert()
--- block/monitor/block-hmp-cmds.c | 4 +--- target/arm/monitor.c | 8 ++------ tests/qtest/fuzz/qos_fuzz.c | 6 ++---- 3 files changed, 5 insertions(+), 13 deletions(-)
block/monitor/block-hmp-cmds.c +1 -3
@@ -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" );
target/arm/monitor.c +2 -6
@@ -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); }
tests/qtest/fuzz/qos_fuzz.c +2 -4
@@ -57,8 +57,7 @@ static void qos_set_machines_devices_available(void)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 +69,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);
Signature · 1 line
2.21.1
Re: [PATCH 1/3] Use &error_abort instead of separate assert()
tests/qtest/fuzz/qos_fuzz.c static void qos_set_machines_devices_available(void) · line 58
Quoted 9 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>index
1a99277d60..aa9eee6ebf100644tests/qtest/fuzz/qos_fuzz.c +0
-0@@ -57,8 +57,7 @@ static void qos_set_machines_devices_available(void)QList *lst;Error *err =NULL ;
Can this err declaration be removed? Don't think it's used anywhere else.
Quoted 20 lines
tests/qtest/fuzz/qos_fuzz.c +2
-4-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 +69,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);Signature · 1 line
2.21.1
Thanks!
Eric Blake
Reviewed-byRe: [PATCH 1/3] Use &error_abort instead of separate assert()
Quoted 4 lines · Alexander Bulekov
Quoted 1 line · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>
Quoted 8 lines
tests/qtest/fuzz/qos_fuzz.c static void qos_set_machines_devices_available(void) · line 58
Quoted 6 lines
index
1a99277d60..aa9eee6ebf100644tests/qtest/fuzz/qos_fuzz.c +0
-0@@ -57,8 +57,7 @@ static void qos_set_machines_devices_available(void)QList *lst;Error *err =NULL ;Can this err declaration be removed? Don't think it's used anywhere else.
Correct, it is not. With that additional line gone,
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH 1/3] Use &error_abort instead of separate assert()
In reply to Alexander BulekovQuoted 4 lines · Alexander Bulekov
Quoted 1 line · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>
Quoted 8 lines
tests/qtest/fuzz/qos_fuzz.c static void qos_set_machines_devices_available(void) · line 58
Quoted 6 lines
index
1a99277d60..aa9eee6ebf100644tests/qtest/fuzz/qos_fuzz.c +0
-0@@ -57,8 +57,7 @@ static void qos_set_machines_devices_available(void)QList *lst;Error *err =NULL ;Can this err declaration be removed? Don't think it's used anywhere else.
Will do.
Quoted 21 lines
Quoted 19 lines
tests/qtest/fuzz/qos_fuzz.c +2
-4-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 +69,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);Signature · 1 line
2.21.1Thanks!
Quoted 1 line
Thanks!
Vladimir Sementsov-Ogievskiy
Reviewed-byRe: [PATCH 1/3] Use &error_abort instead of separate assert()
Quoted 15 lines · Markus Armbruster
Quoted 4 lines · Alexander Bulekov
Quoted 1 line · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>Quoted 8 lines
tests/qtest/fuzz/qos_fuzz.c static void qos_set_machines_devices_available(void) · line 58
Quoted 6 lines
index
1a99277d60..aa9eee6ebf100644tests/qtest/fuzz/qos_fuzz.c +0
-0@@ -57,8 +57,7 @@ static void qos_set_machines_devices_available(void)QList *lst;Error *err =NULL ;Can this err declaration be removed? Don't think it's used anywhere else.
Quoted 1 line
Will do.
with this:
Quoted 26 lines
Quoted 22 lines
Quoted 20 lines
tests/qtest/fuzz/qos_fuzz.c +2
-4-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 +69,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);Signature · 1 line
2.21.1Thanks!
Quoted 1 line
Thanks!
Signature · 2 lines
Best regards, Vladimir
PATCH 2/3 hw/misc/ivshmem: Use one Error * variable instead of two
In reply to Markus ArmbrusterCommit fe44dc9180 "migration: disallow migrate_add_blocker during migration" accidentally added a second Error * variable. Use the first one instead.
--- hw/misc/ivshmem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
hw/misc/ivshmem.c +3 -4
@@ -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 ; }
Signature · 1 line
2.21.1
Re: [PATCH 2/3] hw/misc/ivshmem: Use one Error * variable instead of two
Quoted 8 lines · Markus Armbruster
Commit
fe44dc9180"migration: disallowmigrate_add_blockerduring migration" accidentally added a second Error * variable. Use the first one instead.Signed-off-by Markus Armbruster <[email protected]>--- hw/misc/ivshmem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH 2/3] hw/misc/ivshmem: Use one Error * variable instead of two
In reply to Markus ArmbrusterQuoted 22 lines · Markus Armbruster
Commit
fe44dc9180"migration: disallowmigrate_add_blockerduring migration" accidentally added a second Error * variable. Use the first one instead.Signed-off-by Markus Armbruster <[email protected]>--- hw/misc/ivshmem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)hw/misc/ivshmem.c +0
-1@@ -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) &&
hw/misc/ivshmem.c static void ivshmem_common_realize(PCIDevice *dev, Error **errp) · line 900
Quoted 3 lines
hw/misc/ivshmem.c +0
-0@@ -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'" );
Hmm, if you want, you may fix this over-80 line while we are here.
hw/misc/ivshmem.c static void ivshmem_common_realize(PCIDevice *dev, Error **errp) · line 906
Quoted 10 lines
hw/misc/ivshmem.c +3
-3-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 ; }
migrate_add_blocker returns error code, so we can just do
if (migrate_add_blocker(s->migration_blocker, errp)) {
error_free(s->migration_blocker;
return;
}
With or without this:
Signature · 2 lines
Best regards, Vladimir
PATCH 3/3 xen-block: Use one Error * variable instead of two
In reply to Markus Armbruster--- hw/block/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/block/xen-block.c +1 -4
@@ -998,14 +998,13 @@ 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,
@@ -1015,8 +1014,6 @@ static void xen_block_device_destroy(XenBackendInstance *backend, }if (drive) { -Error *local_err =NULL ; -xen_block_drive_destroy (drive, &local_err);if (local_err) { error_propagate_prepend(errp, local_err,
Signature · 1 line
2.21.1
Re: [PATCH 3/3] xen-block: Use one Error * variable instead of two
Quoted 4 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/block/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH 3/3] xen-block: Use one Error * variable instead of two
In reply to Markus ArmbrusterQuoted 27 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/block/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/block/xen-block.c +1
-2@@ -998,14 +998,13 @@ 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,
hw/block/xen-block.c static void xen_block_device_destroy(XenBackendInstance *backend, · line 1019
Quoted 8 lines
hw/block/xen-block.c +0
-2@@ -1015,8 +1014,6 @@ static void xen_block_device_destroy(XenBackendInstance *backend, }if (drive) { -Error *local_err =NULL ; -xen_block_drive_destroy (drive, &local_err);if (local_err) { error_propagate_prepend(errp, local_err,
Re: [PATCH 3/3] xen-block: Use one Error * variable instead of two
In reply to Markus ArmbrusterQuoted 26 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/block/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/block/xen-block.c +1
-2@@ -998,14 +998,13 @@ 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,
hw/block/xen-block.c static void xen_block_device_destroy(XenBackendInstance *backend, · line 1019
Quoted 8 lines
hw/block/xen-block.c +0
-2@@ -1015,8 +1014,6 @@ static void xen_block_device_destroy(XenBackendInstance *backend, }if (drive) { -Error *local_err =NULL ; -xen_block_drive_destroy (drive, &local_err);if (local_err) { error_propagate_prepend(errp, local_err,
Hmm, no "return;" statement after this propagation. It's OK, as there no more code in the function after this "if", but I'd add it to be consistent and to avoid forgetting to add a return here when add more code to the function.
(and if you do this, you may also fix indentation of string paramter of error_propagate_prepend...)
Anyway,
Signature · 2 lines
Best regards, Vladimir
Markus Armbruster
Reviewed-by Peter Maydell Reviewed-by Eric Blake Reviewed-by Philippe Mathieu-Daudé Reviewed-by Vladimir Sementsov-OgievskiyRe: [PATCH 3/3] xen-block: Use one Error * variable instead of two
Uh, I failed to actually send this. It's in my pull request now.
Quoted 34 lines · Vladimir Sementsov-Ogievskiy
Quoted 23 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/block/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/block/xen-block.c +1
-2@@ -998,14 +998,13 @@ 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,hw/block/xen-block.c static void xen_block_device_destroy(XenBackendInstance *backend, · line 1018
Quoted 7 lines
hw/block/xen-block.c +0
-2@@ -1015,8 +1014,6 @@ static void xen_block_device_destroy(XenBackendInstance *backend, }if (drive) { -Error *local_err =NULL ; -xen_block_drive_destroy (drive, &local_err);if (local_err) { error_propagate_prepend(errp, local_err,Hmm, no "return;" statement after this propagation. It's OK, as there no more code in the function after this "if", but I'd add it to be consistent and to avoid forgetting to add a return here when add more code to the function.
Quoted 6 lines
(and if you do this, you may also fix indentation of string paramter of
error_propagate_prepend...)Anyway,
Reviewed-by Vladimir Sementsov-Ogievskiy <[email protected]>
Like this, I guess:
xen-block: Use one Error * variable instead of two
While there, tidy up indentation, and add return just for consistency and robustness.
Message-Id: <[email protected]>
hw/block/xen-block.c +4 -6
@@ -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 ; } } }
Re: [PATCH 3/3] xen-block: Use one Error * variable instead of two
Quoted 88 lines · Markus Armbruster
Uh, I failed to actually send this. It's in my pull request now.
Quoted 34 lines · Vladimir Sementsov-Ogievskiy
Quoted 23 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/block/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/block/xen-block.c +1
-2@@ -998,14 +998,13 @@ 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,hw/block/xen-block.c static void xen_block_device_destroy(XenBackendInstance *backend, · line 1018
Quoted 7 lines
hw/block/xen-block.c +0
-2@@ -1015,8 +1014,6 @@ static void xen_block_device_destroy(XenBackendInstance *backend, }if (drive) { -Error *local_err =NULL ; -xen_block_drive_destroy (drive, &local_err);if (local_err) { error_propagate_prepend(errp, local_err,Hmm, no "return;" statement after this propagation. It's OK, as there no more code in the function after this "if", but I'd add it to be consistent and to avoid forgetting to add a return here when add more code to the function.
Quoted 6 lines
(and if you do this, you may also fix indentation of string paramter of
error_propagate_prepend...)Anyway,
Reviewed-by Vladimir Sementsov-Ogievskiy <[email protected]>Like this, I guess:
xen-block: Use one Error * variable instead of two
While there, tidy up indentation, and add return just for consistency and robustness.
Signed-off-by Markus Armbruster <[email protected]>Message-Id: <[email protected]>
Reviewed-by Peter Maydell <[email protected]>Reviewed-by Eric Blake <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Vladimir Sementsov-Ogievskiy <[email protected]>hw/block/xen-block.c +2
-4@@ -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 ;
hw/block/xen-block.c static void xen_block_device_destroy(XenBackendInstance *backend, · line 1024
Quoted 10 lines
hw/block/xen-block.c +2
-2-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 ; } } }
Yes, that's what I meant, thanks!
Signature · 2 lines
Best regards, Vladimir
Quoted 6 lines · Markus Armbruster
Markus Armbruster (3):
Use&error_abortinstead of separateassert()hw/misc/ivshmem: Use one Error * variable instead of two
xen-block: Use one Error * variable instead of two
Quoted 6 lines
block/monitor/block-hmp-cmds.c | 4 +--- hw/block/xen-block.c | 5 +---- hw/misc/ivshmem.c | 7 +++---- target/arm/monitor.c | 8 ++------ tests/qtest/fuzz/qos_fuzz.c | 6 ++---- 5 files changed, 9 insertions(+), 21 deletions(-)
series
-- PMM
[PATCH v10 4/3] hw/sd/ssi-sd: fix error handling in ssi_sd_realize
In reply to Markus ArmbrusterIt'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.
---
Forgive me for sending this into your series, but seems it is very appropriate.
It's rephrasing of my
[PATCH v9 03/10] hw/sd/ssi-sd: fix error handling in ssi_sd_realize
for partI series but but without use of ERRP_AUTO_PROPAGATE.
hw/sd/ssi-sd.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
hw/sd/ssi-sd.c +14 -2
@@ -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)
Signature · 1 line
2.21.0
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH v10 4/3] hw/sd/ssi-sd: fix error handling in ssi_sd_realize
Quoted 40 lines · Vladimir Sementsov-Ogievskiy
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 <[email protected]>---
Forgive me for sending this into your series, but seems it is very appropriate.
It's rephrasing of my
[PATCH v9 03/10] hw/sd/ssi-sd: fix error handling inssi_sd_realize
for partI series but but without use ofERRP_AUTO_PROPAGATE.hw/sd/ssi-sd.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)hw/sd/ssi-sd.c +8
-2@@ -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 ;
hw/sd/ssi-sd.c static void ssi_sd_realize(SSISlave *d, Error **errp) · line 279
Quoted 10 lines
hw/sd/ssi-sd.c +6
-0+ goto fail; } + +return ; + +fail: +error_propagate_prepend (errp, err,"failed to init SD card: " ); }static void ssi_sd_reset (DeviceState *dev)
Markus Armbruster
Reviewed-byRe: [PATCH v10 4/3] hw/sd/ssi-sd: fix error handling in ssi_sd_realize
In reply to Vladimir Sementsov-OgievskiyQuoted 39 lines · Vladimir Sementsov-Ogievskiy
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 <[email protected]>---
Forgive me for sending this into your series, but seems it is very appropriate.
It's rephrasing of my
[PATCH v9 03/10] hw/sd/ssi-sd: fix error handling inssi_sd_realize
for partI series but but without use ofERRP_AUTO_PROPAGATE.hw/sd/ssi-sd.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)hw/sd/ssi-sd.c +8
-2@@ -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 ;
hw/sd/ssi-sd.c static void ssi_sd_realize(SSISlave *d, Error **errp) · line 279
Quoted 10 lines
hw/sd/ssi-sd.c +6
-0+ goto fail; } + +return ; + +fail: +error_propagate_prepend (errp, err,"failed to init SD card: " ); }static void ssi_sd_reset (DeviceState *dev)
Re: [PATCH v10 4/3] hw/sd/ssi-sd: fix error handling in ssi_sd_realize
In reply to Vladimir Sementsov-OgievskiyQuoted 5 lines · Vladimir Sementsov-Ogievskiy
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 <[email protected]>
Quoted 8 lines
---
Forgive me for sending this into your series, but seems it is very appropriate.
It's rephrasing of my
[PATCH v9 03/10] hw/sd/ssi-sd: fix error handling inssi_sd_realize
for partI series but but without use ofERRP_AUTO_PROPAGATE.
Forgive? Thank you for extracting a bug fix for 5.0! Got more? :)
Markus Armbruster
AppliedQueued, including Vladimir's PATCH 4/3. Thanks!