diff mbox

[RFC,1/2] qom: Give type_get_by_name() external linkage

Message ID 1337859784-24097-2-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster May 24, 2012, 11:43 a.m. UTC
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 <armbru@redhat.com>
---
 include/qemu/object.h |    8 ++++++++
 qom/object.c          |    2 +-
 2 files changed, 9 insertions(+), 1 deletions(-)
diff mbox

Patch

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;