diff options
author | Greg Kurz | 2017-05-15 13:39:45 +0200 |
---|---|---|
committer | David Gibson | 2017-05-24 03:39:52 +0200 |
commit | 175d2aa038c530d07a8eb5f483c6b1c4b3df43e0 (patch) | |
tree | df9c0c13e950f44f3787d81bf59f02265a951d12 /hw | |
parent | ppc/xics: simplify prototype of xics_spapr_init() (diff) | |
download | qemu-175d2aa038c530d07a8eb5f483c6b1c4b3df43e0.tar.gz qemu-175d2aa038c530d07a8eb5f483c6b1c4b3df43e0.tar.xz qemu-175d2aa038c530d07a8eb5f483c6b1c4b3df43e0.zip |
spapr: sanitize error handling in spapr_ics_create()
The spapr_ics_create() function handles errors in a rather convoluted
way, with two local Error * variables. Moreover, failing to parent the
ICS object to the machine should be considered as a bug but it is
currently ignored.
This patch addresses both issues.
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ppc/spapr.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 18709ad616..a9471b99f5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -101,21 +101,26 @@ static ICSState *spapr_ics_create(sPAPRMachineState *spapr, const char *type_ics, int nr_irqs, Error **errp) { - Error *err = NULL, *local_err = NULL; + Error *local_err = NULL; Object *obj; obj = object_new(type_ics); - object_property_add_child(OBJECT(spapr), "ics", obj, NULL); + object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abort); - object_property_set_int(obj, nr_irqs, "nr-irqs", &err); + object_property_set_int(obj, nr_irqs, "nr-irqs", &local_err); + if (local_err) { + goto error; + } object_property_set_bool(obj, true, "realized", &local_err); - error_propagate(&err, local_err); - if (err) { - error_propagate(errp, err); - return NULL; + if (local_err) { + goto error; } return ICS_SIMPLE(obj); + +error: + error_propagate(errp, local_err); + return NULL; } static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp) |