diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 6f09a3568b..7b74dd5beb 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1072,49 +1072,49 @@ void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value) { Error *errp = NULL; object_property_set_bool(OBJECT(dev), value, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value) { Error *errp = NULL; object_property_set_int(OBJECT(dev), value, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value) { Error *errp = NULL; object_property_set_int(OBJECT(dev), value, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value) { Error *errp = NULL; object_property_set_int(OBJECT(dev), value, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value) { Error *errp = NULL; object_property_set_int(OBJECT(dev), value, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value) { Error *errp = NULL; object_property_set_int(OBJECT(dev), value, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_string(DeviceState *dev, const char *name, char *value) { Error *errp = NULL; object_property_set_str(OBJECT(dev), value, name, &errp); - assert(!errp); + assert_no_error(errp); } int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) @@ -1143,7 +1143,7 @@ void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *valu assert(!value || value->label); object_property_set_str(OBJECT(dev), value ? value->label : "", name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value) @@ -1152,14 +1152,14 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *v assert(!value || value->name); object_property_set_str(OBJECT(dev), value ? value->name : "", name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value) { Error *errp = NULL; object_property_set_int(OBJECT(dev), value ? value->id : -1, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) @@ -1170,7 +1170,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) value[0], value[1], value[2], value[3], value[4], value[5]); object_property_set_str(OBJECT(dev), str, name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_enum(DeviceState *dev, const char *name, int value) @@ -1181,7 +1181,7 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value) prop = qdev_prop_find(dev, name); object_property_set_str(OBJECT(dev), prop->info->enum_table[value], name, &errp); - assert(!errp); + assert_no_error(errp); } void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value) @@ -1213,7 +1213,7 @@ void qdev_prop_set_defaults(DeviceState *dev, Property *props) } else if (props->qtype == QTYPE_QINT) { object_property_set_int(obj, props->defval, props->name, &errp); } - assert(!errp); + assert_no_error(errp); } } diff --git a/qerror.c b/qerror.c index 8e6efafe00..f55d435d11 100644 --- a/qerror.c +++ b/qerror.c @@ -572,6 +572,14 @@ void qerror_report_err(Error *err) } } +void assert_no_error(Error *err) +{ + if (err) { + qerror_report_err(err); + abort(); + } +} + /** * qobject_to_qerror(): Convert a QObject into a QError */ diff --git a/qerror.h b/qerror.h index e8718bfbab..e26c63598d 100644 --- a/qerror.h +++ b/qerror.h @@ -41,6 +41,7 @@ void qerror_print(QError *qerror); void qerror_report_internal(const char *file, int linenr, const char *func, const char *fmt, ...) GCC_FMT_ATTR(4, 5); void qerror_report_err(Error *err); +void assert_no_error(Error *err); QString *qerror_format(const char *fmt, QDict *error); #define qerror_report(fmt, ...) \ qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)