From patchwork Thu May 24 11:43:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 161123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7B77AB6FC2 for ; Thu, 24 May 2012 21:43:33 +1000 (EST) Received: from localhost ([::1]:34007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXWS3-0004QW-BB for incoming@patchwork.ozlabs.org; Thu, 24 May 2012 07:43:31 -0400 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 Received: from blackfin.pond.sub.org (p5B32BDDC.dip.t-dialin.net [91.50.189.220]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 24296A3DFA; Thu, 24 May 2012 13:43:05 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 13A9760091; Thu, 24 May 2012 13:43:05 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 24 May 2012 13:43:03 +0200 Message-Id: <1337859784-24097-2-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1337859784-24097-1-git-send-email-armbru@redhat.com> References: <1337859784-24097-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.46.104.156 Cc: pbonzini@redhat.com, afaerber@suse.de, anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH RFC 1/2] qom: Give type_get_by_name() external linkage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;