From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLDP3-0000kc-87 for qemu-devel@nongnu.org; Mon, 08 Oct 2012 09:29:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLDOw-0003yn-S2 for qemu-devel@nongnu.org; Mon, 08 Oct 2012 09:29:49 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:45603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLDOw-0003rG-BF for qemu-devel@nongnu.org; Mon, 08 Oct 2012 09:29:42 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Oct 2012 23:27:43 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q98DJML063963254 for ; Tue, 9 Oct 2012 00:19:22 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q98DTA5E015933 for ; Tue, 9 Oct 2012 00:29:10 +1100 From: Anthony Liguori In-Reply-To: References: <1347026144-15098-1-git-send-email-peter.maydell@linaro.org> Date: Mon, 08 Oct 2012 08:29:03 -0500 Message-ID: <87haq5rt28.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v2] qom: Reject attempts to add a property that already exists List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: Paolo Bonzini , Markus Armbruster , patches@linaro.org Peter Maydell writes: > Ping! This is wrong. Container properties are added by the user. You will turn a gracefully failure (during hotplug) into an abort(). Please limit this to static properties as they are not added by a user. Regards, Anthony Liguori > > -- PMM > > On 7 September 2012 14:55, Peter Maydell wrote: >> Reject attempts to add a property to an object if one of >> that name already exists. This is always a bug in the caller; >> this is merely diagnosing it gracefully rather than behaving >> oddly later. >> >> Signed-off-by: Peter Maydell >> --- >> Changes v1->v2: >> * use abort() rather than assert(0), as suggested by Paolo >> * make the diagnostic message a little more helpful by >> including the type name, and adding '' around names >> * the patches fixing bugs which this patch makes fatal errors >> have both now been committed to master, so there's no >> barrier to committing it now >> >> qom/object.c | 13 ++++++++++++- >> 1 file changed, 12 insertions(+), 1 deletion(-) >> >> diff --git a/qom/object.c b/qom/object.c >> index e3e9242..3da4c0e 100644 >> --- a/qom/object.c >> +++ b/qom/object.c >> @@ -620,7 +620,18 @@ void object_property_add(Object *obj, const char *name, const char *type, >> ObjectPropertyRelease *release, >> void *opaque, Error **errp) >> { >> - ObjectProperty *prop = g_malloc0(sizeof(*prop)); >> + ObjectProperty *prop; >> + >> + QTAILQ_FOREACH(prop, &obj->properties, node) { >> + if (strcmp(prop->name, name) == 0) { >> + /* This is always a bug in the caller */ >> + fprintf(stderr, "attempt to add duplicate property '%s'" >> + " to object (type '%s')\n", name, object_get_typename(obj)); >> + abort(); >> + } >> + } >> + >> + prop = g_malloc0(sizeof(*prop)); >> >> prop->name = g_strdup(name); >> prop->type = g_strdup(type); >> -- >> 1.7.9.5 >> >>