From patchwork Sat Mar 16 16:39:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15390 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 96F4723E2C for ; Sat, 16 Mar 2013 16:39:30 +0000 (UTC) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by fiordland.canonical.com (Postfix) with ESMTP id 4FFD9A19810 for ; Sat, 16 Mar 2013 16:39:30 +0000 (UTC) Received: by mail-ve0-f175.google.com with SMTP id cy12so3361400veb.20 for ; Sat, 16 Mar 2013 09:39:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=LLdH/BEsIThNZdeR/MkJZT6CExcO9VCqY7Y7nlZxCdk=; b=OzEiah+mTVmqe2eOiB0cUtcvlkUiSUrAL8I/6v99VDz6cRGVpe5A9AZM2vsv+BxF1v 2kf9hWFtVtgN0eD06+yyz9Ne+qTG6MOcIS+Uoexmx0fHGmZMqNTqBs5w4wzaU4pDuhGH VrrjrGdDa8WJdxnQdb0LQbyKEVN57s03GGar3l6dAo7GGQtjEGdc1u7j5jUMVaceq0Gr QA85kHpxRzCA8ZY5j2RaAnUdrlFSqjlK/2nhBHSaAosFiQs4L+5Z75F5C+0wygJmFpsx gQhEW98kFUfS+6Us3CwxlhtzSv3QY4e1wqrDQbI71M0hhc947AbNqlfxHXU0sDCFLrhW gmlQ== X-Received: by 10.58.188.48 with SMTP id fx16mr12562085vec.22.1363451969790; Sat, 16 Mar 2013 09:39:29 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp168326veb; Sat, 16 Mar 2013 09:39:29 -0700 (PDT) X-Received: by 10.14.219.7 with SMTP id l7mr30400238eep.12.1363451965897; Sat, 16 Mar 2013 09:39:25 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id a9si18491445eem.113.2013.03.16.09.39.25 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 16 Mar 2013 09:39:25 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UGu8g-0006l5-Ds; Sat, 16 Mar 2013 16:39:22 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Paolo Bonzini , Anthony Liguori Subject: [PATCH v6 2/2] hw/qdev: Abort rather than ignoring errors adding device properties Date: Sat, 16 Mar 2013 16:39:22 +0000 Message-Id: <1363451962-25952-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1363451962-25952-1-git-send-email-peter.maydell@linaro.org> References: <1363451962-25952-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQkcydTbDbZzCGCkjojhhdx22FA8bKBolqtNveY+jhxRTfWpgwvUbnvcoN6X4wOhixOHtPUj 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 --- hw/qdev.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 0b20280..df9737d 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -711,6 +711,7 @@ static void device_initfn(Object *obj) DeviceState *dev = DEVICE(obj); ObjectClass *class; Property *prop; + Error *err = NULL; if (qdev_hotplug) { dev->hotplugged = 1; @@ -726,15 +727,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. */