From patchwork Thu Oct 25 15:22:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 12525 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 7646A23F9B for ; Thu, 25 Oct 2012 15:22:37 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 23A8CA1888F for ; Thu, 25 Oct 2012 15:22:37 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so2290531iej.11 for ; Thu, 25 Oct 2012 08:22:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=ngg8a0xKXTDwNruAsqd/gLIbXLB7L9x1QQ6Is7dFLzQ=; b=SS7GThZoH3Pzt7S6COIwVLkJPuj6dAjKDTHYqPhdshJfOr66bUWixieB6xEwN8K7Zg o5VbhOe7PBGdksy6eB4VDWbl1aH/r3lbw0ST1GQ6YQb+4WrtzE1yKf+0BGKcJMzTenHV SimvjaDVP3uc7SmErJmT8Z2sz5MViEBiS8FZDx6gHZ7dn5GJNZFeUIYyV6ptpVzzWi/q GMcIhrwPxG+2f36uvtYHc4ZdEPksY2lsLGzIqTddLOegWZ0rpQ2OaERTPB7ugBlacaHr 4cunY0RgQDmWknwnuMwoj+0sMAjdXAYTqmgii1Z/jb3d8cHfLWH3sYINEqbdAjJwcnU+ Z6Ww== Received: by 10.43.7.132 with SMTP id oo4mr16956904icb.6.1351178556572; Thu, 25 Oct 2012 08:22:36 -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.50.67.148 with SMTP id n20csp68157igt; Thu, 25 Oct 2012 08:22:34 -0700 (PDT) Received: by 10.181.13.239 with SMTP id fb15mr14551821wid.22.1351178553354; Thu, 25 Oct 2012 08:22:33 -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 o15si1117073wiv.26.2012.10.25.08.22.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Oct 2012 08:22:33 -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 1TRPGP-0001UQ-NN; Thu, 25 Oct 2012 16:22:29 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Anthony Liguori , Paolo Bonzini Subject: [PATCH v4 2/2] hw/qdev: Abort rather than ignoring errors adding device properties Date: Thu, 25 Oct 2012 16:22:29 +0100 Message-Id: <1351178549-5699-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1351178549-5699-1-git-send-email-peter.maydell@linaro.org> References: <1351178549-5699-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQmkELHpOdmZM/D21wtec4NIglocFbTxkUsYHK853zHiJawmiSszc0JoRcMHyp/7UyLQRfSA 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 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. */