This makes object_class_get_parent() return a const pointer in
case its class argument is a const pointer.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/qom/object.h | 6 +++++-
qom/object.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index 6829735f99..674a45862d 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -873,7 +873,11 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
*
* Returns: The parent for @klass or %NULL if none.
*/
-ObjectClass *object_class_get_parent(ObjectClass *klass);
+#define object_class_get_parent(klass) \
+ (QUALIFIED_CAST(typeof(klass), ObjectClass *) \
+ object_class_get_parent_const(klass))
+
+const ObjectClass *object_class_get_parent_const(const ObjectClass *klass);
/**
* object_class_get_name:
diff --git a/qom/object.c b/qom/object.c
index eb4bc924ff..8f60ad9b8e 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -774,7 +774,7 @@ ObjectClass *object_class_by_name(const char *typename)
return type->class;
}
-ObjectClass *object_class_get_parent(ObjectClass *class)
+const ObjectClass *object_class_get_parent_const(const ObjectClass *class)
{
TypeImpl *type = type_get_parent(class->type);
--
2.11.0.259.g40922b1