[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 2/2] hw/qdev: Abort rather than ignoring erro
From: |
Anthony Liguori |
Subject: |
Re: [Qemu-devel] [PATCH v4 2/2] hw/qdev: Abort rather than ignoring errors adding device properties |
Date: |
Thu, 25 Oct 2012 13:39:18 -0500 |
User-agent: |
Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) |
Peter Maydell <address@hidden> writes:
> Instead of ignoring any errors that occur when adding properties
> to a new device in device_initfn(), check for them and abort if any
> occur. The most likely cause is accidentally adding a duplicate
> property, which is a programming error by the device author.
>
> Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Anthony Liguori <address@hidden>
Regards,
Anthony Liguori
> ---
> hw/qdev.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 9b9aba3..b34d80a 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -659,6 +659,7 @@ static void device_initfn(Object *obj)
> DeviceState *dev = DEVICE(obj);
> ObjectClass *class;
> Property *prop;
> + Error *err = NULL;
>
> if (qdev_hotplug) {
> dev->hotplugged = 1;
> @@ -671,15 +672,18 @@ static void device_initfn(Object *obj)
> class = object_get_class(OBJECT(dev));
> do {
> for (prop = DEVICE_CLASS(class)->props; prop && prop->name; prop++) {
> - qdev_property_add_legacy(dev, prop, NULL);
> - qdev_property_add_static(dev, prop, NULL);
> + qdev_property_add_legacy(dev, prop, &err);
> + assert_no_error(err);
> + qdev_property_add_static(dev, prop, &err);
> + assert_no_error(err);
> }
> class = object_class_get_parent(class);
> } while (class != object_class_by_name(TYPE_DEVICE));
> qdev_prop_set_globals(dev);
>
> object_property_add_link(OBJECT(dev), "parent_bus", TYPE_BUS,
> - (Object **)&dev->parent_bus, NULL);
> + (Object **)&dev->parent_bus, &err);
> + assert_no_error(err);
> }
>
> /* Unlink device from bus and free the structure. */
> --
> 1.7.9.5