Message ID | 20170329194148.19015-10-ehabkost@redhat.com |
---|---|
State | New |
Headers | show |
diff --git a/include/qom/object.h b/include/qom/object.h index 2b1513d2f2..de8ab70d13 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -803,7 +803,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename, * * Returns: The #ObjectClass of the type associated with @obj. */ -ObjectClass *object_get_class(Object *obj); +const ObjectClass *object_get_class(Object *obj); /** * object_get_typename: diff --git a/qom/object.c b/qom/object.c index 9b6c990ac5..297cce8fc2 100644 --- a/qom/object.c +++ b/qom/object.c @@ -747,7 +747,7 @@ const char *object_get_typename(Object *obj) return obj->class->type->name; } -ObjectClass *object_get_class(Object *obj) +const ObjectClass *object_get_class(Object *obj) { return obj->class; }
To avoid having code accidentaly changing class structs outside class_init, make object_get_class() return a const pointer. This will automatically affect OBJECT_GET_CLASS, OBJECT_CLASS_CHECK, and the macros defined using them, because OBJECT_CLASS_CHECK is already const-aware. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- include/qom/object.h | 2 +- qom/object.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)