From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXWRn-00043m-QQ for qemu-devel@nongnu.org; Thu, 24 May 2012 07:43:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXWRh-0003av-Jv for qemu-devel@nongnu.org; Thu, 24 May 2012 07:43:15 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:48598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXWRh-0003aN-Dt for qemu-devel@nongnu.org; Thu, 24 May 2012 07:43:09 -0400 From: Markus Armbruster Date: Thu, 24 May 2012 13:43:03 +0200 Message-Id: <1337859784-24097-2-git-send-email-armbru@redhat.com> In-Reply-To: <1337859784-24097-1-git-send-email-armbru@redhat.com> References: <1337859784-24097-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH RFC 1/2] qom: Give type_get_by_name() external linkage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, afaerber@suse.de, anthony@codemonkey.ws Following the type_register() precedence, the definition returns "TypeImpl *", while the declaration returns "Type". Fine, because the latter is actually a typedef for the former. For the record, I don't think this typedef'ing away the "*" is a good idea. It only complicates matters. When I see TypeImpl *type_get_by_name(const char *name) it's immediately obvious that the value has pointer semantics, and a null pointer must be the error value. Moreover, it's unusual in QEMU code. Signed-off-by: Markus Armbruster --- include/qemu/object.h | 8 ++++++++ qom/object.c | 2 +- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index d93b772..3648462 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -535,6 +535,14 @@ Type type_register_static(const TypeInfo *info); Type type_register(const TypeInfo *info); /** + * type_get_by_name: + * @name: The name of the type + * + * Returns: The #Type with that name if it exists, else NULL. + */ +Type type_get_by_name(const char *name); + +/** * object_class_dynamic_cast_assert: * @klass: The #ObjectClass to attempt to cast. * @typename: The QOM typename of the class to cast to. diff --git a/qom/object.c b/qom/object.c index 6f839ad..94ea0f9 100644 --- a/qom/object.c +++ b/qom/object.c @@ -140,7 +140,7 @@ TypeImpl *type_register_static(const TypeInfo *info) return type_register(info); } -static TypeImpl *type_get_by_name(const char *name) +TypeImpl *type_get_by_name(const char *name) { if (name == NULL) { return NULL; -- 1.7.6.5