qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Anthony Liguori" <aliguori@us.ibm.com>,
	"Andreas Färber" <afaerber@suse.de>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH v7 2/2] hw/qdev: Abort rather than ignoring errors adding device properties
Date: Mon, 25 Mar 2013 13:15:14 +0000	[thread overview]
Message-ID: <1364217314-7400-3-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1364217314-7400-1-git-send-email-peter.maydell@linaro.org>

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 <peter.maydell@linaro.org>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 708a058..909c405 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -710,6 +710,7 @@ static void device_initfn(Object *obj)
     DeviceState *dev = DEVICE(obj);
     ObjectClass *class;
     Property *prop;
+    Error *err = NULL;
 
     if (qdev_hotplug) {
         dev->hotplugged = 1;
@@ -725,15 +726,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

  parent reply	other threads:[~2013-03-25 13:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 13:15 [Qemu-devel] [PATCH v7 0/2] qdev: Detect duplicate device properties Peter Maydell
2013-03-25 13:15 ` [Qemu-devel] [PATCH v7 1/2] qom: Detect attempts to add a property that already exists Peter Maydell
2013-03-25 13:15 ` Peter Maydell [this message]
2013-03-26 18:33 ` [Qemu-devel] [PATCH v7 0/2] qdev: Detect duplicate device properties Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364217314-7400-3-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).