qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH RFC 1/2] qom: Give type_get_by_name() external linka


From: Markus Armbruster
Subject: [Qemu-devel] [PATCH RFC 1/2] qom: Give type_get_by_name() external linkage
Date: Thu, 24 May 2012 13:43:03 +0200

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]