From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRSL5-0000Xk-LP for qemu-devel@nongnu.org; Thu, 25 Oct 2012 14:39:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRSL4-0002Bt-Lw for qemu-devel@nongnu.org; Thu, 25 Oct 2012 14:39:31 -0400 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:59202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRSL3-0002BR-VH for qemu-devel@nongnu.org; Thu, 25 Oct 2012 14:39:30 -0400 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Oct 2012 00:09:28 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9PIdPZv39518358 for ; Fri, 26 Oct 2012 00:09:25 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9Q09F8V029577 for ; Fri, 26 Oct 2012 11:09:16 +1100 From: Anthony Liguori In-Reply-To: <1351178549-5699-3-git-send-email-peter.maydell@linaro.org> References: <1351178549-5699-1-git-send-email-peter.maydell@linaro.org> <1351178549-5699-3-git-send-email-peter.maydell@linaro.org> Date: Thu, 25 Oct 2012 13:39:18 -0500 Message-ID: <87y5iu1jmx.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v4 2/2] hw/qdev: Abort rather than ignoring errors adding device properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: Paolo Bonzini , patches@linaro.org Peter Maydell 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 Reviewed-by: Anthony Liguori 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