From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHbE9-0007e5-M4 for qemu-devel@nongnu.org; Mon, 18 Mar 2013 10:40:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHbE6-0005Rp-BO for qemu-devel@nongnu.org; Mon, 18 Mar 2013 10:39:53 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47451 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHbE6-0005Rh-4q for qemu-devel@nongnu.org; Mon, 18 Mar 2013 10:39:50 -0400 Message-ID: <51472734.50401@suse.de> Date: Mon, 18 Mar 2013 15:39:48 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1363451962-25952-1-git-send-email-peter.maydell@linaro.org> <1363451962-25952-2-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1363451962-25952-2-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 1/2] qom: Detect attempts to add a property that already exists List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , Anthony Liguori , qemu-devel@nongnu.org, Markus Armbruster , patches@linaro.org Am 16.03.2013 17:39, schrieb Peter Maydell: > Detect attempts to add a property to an object if one of > that name already exists, and report them as errors. >=20 > Signed-off-by: Peter Maydell > Reviewed-by: Anthony Liguori > --- > qom/object.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) >=20 > diff --git a/qom/object.c b/qom/object.c > index 3d638ff..875315a 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -629,7 +629,18 @@ void object_property_add(Object *obj, const char *= name, const char *type, > ObjectPropertyRelease *release, > void *opaque, Error **errp) > { > - ObjectProperty *prop =3D g_malloc0(sizeof(*prop)); > + ObjectProperty *prop; > + > + QTAILQ_FOREACH(prop, &obj->properties, node) { > + if (strcmp(prop->name, name) =3D=3D 0) { > + error_setg(errp, "attempt to add duplicate property '%s'" > + " to object (type '%s')\n", name, No \n in error_setg(), there was a recent cleanup series. Andreas > + object_get_typename(obj)); > + return; > + } > + } > + > + prop =3D g_malloc0(sizeof(*prop)); > =20 > prop->name =3D g_strdup(name); > prop->type =3D g_strdup(type); >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg