From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUr-0001cp-Lr for qemu-devel@nongnu.org; Mon, 18 Jun 2012 10:00:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgcUV-0003WE-JX for qemu-devel@nongnu.org; Mon, 18 Jun 2012 10:00:01 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53237 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUV-0003Vr-AM for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:59:39 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 18 Jun 2012 15:58:59 +0200 Message-Id: <1340027954-19045-8-git-send-email-afaerber@suse.de> In-Reply-To: <1340027954-19045-1-git-send-email-afaerber@suse.de> References: <1340027954-19045-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 07/22] qom: Assert that public types have a non-NULL parent field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori From: Paolo Bonzini This protects against unwanted effects of changing TYPE_OBJECT from NULL to a string. Suggested-by: Andreas F=C3=A4rber Signed-off-by: Paolo Bonzini Signed-off-by: Andreas F=C3=A4rber --- qom/object.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/qom/object.c b/qom/object.c index dac9de5..cec2d40 100644 --- a/qom/object.c +++ b/qom/object.c @@ -95,7 +95,7 @@ static TypeImpl *type_table_lookup(const char *name) return g_hash_table_lookup(type_table_get(), name); } =20 -TypeImpl *type_register(const TypeInfo *info) +static TypeImpl *type_register_internal(const TypeInfo *info) { TypeImpl *ti =3D g_malloc0(sizeof(*ti)); =20 @@ -137,6 +137,12 @@ TypeImpl *type_register(const TypeInfo *info) return ti; } =20 +TypeImpl *type_register(const TypeInfo *info) +{ + assert(info->parent); + return type_register_internal(info); +} + TypeImpl *type_register_static(const TypeInfo *info) { return type_register(info); @@ -204,7 +210,7 @@ static void type_class_interface_init(TypeImpl *ti, I= nterfaceImpl *iface) char *name =3D g_strdup_printf("<%s::%s>", ti->name, iface->parent); =20 info.name =3D name; - iface->type =3D type_register(&info); + iface->type =3D type_register_internal(&info); g_free(name); } =20 @@ -1239,8 +1245,8 @@ static void register_types(void) .abstract =3D true, }; =20 - type_interface =3D type_register_static(&interface_info); - type_register_static(&object_info); + type_interface =3D type_register_internal(&interface_info); + type_register_internal(&object_info); } =20 type_init(register_types) --=20 1.7.7