[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 47/58] qom: Make type checker functions accept const pointers
From: |
Eduardo Habkost |
Subject: |
[PATCH v2 47/58] qom: Make type checker functions accept const pointers |
Date: |
Wed, 19 Aug 2020 20:12:25 -0400 |
The existing type check macros all unconditionally drop const
qualifiers from their arguments. Keep this behavior in the
macros generated by DECLARE_*CHECKER* by now.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
* Removed note about _Generic from commit message, because it
won't be possible to do what I was planning without manual
#defines
---
include/qom/object.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index 4cd84998c2..1d6a520d35 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -567,7 +567,7 @@ struct Object
*/
#define DECLARE_INSTANCE_CHECKER(InstanceType, OBJ_NAME, TYPENAME) \
static inline G_GNUC_UNUSED InstanceType * \
- OBJ_NAME(void *obj) \
+ OBJ_NAME(const void *obj) \
{ return OBJECT_CHECK(InstanceType, obj, TYPENAME); }
/**
@@ -581,14 +581,16 @@ struct Object
*
* This macro will provide the three standard type cast functions for a
* QOM type.
+ *
+ *FIXME: Use _Generic to make this const-safe
*/
#define DECLARE_CLASS_CHECKERS(ClassType, OBJ_NAME, TYPENAME) \
static inline G_GNUC_UNUSED ClassType * \
- OBJ_NAME##_GET_CLASS(void *obj) \
+ OBJ_NAME##_GET_CLASS(const void *obj) \
{ return OBJECT_GET_CLASS(ClassType, obj, TYPENAME); } \
\
static inline G_GNUC_UNUSED ClassType * \
- OBJ_NAME##_CLASS(void *klass) \
+ OBJ_NAME##_CLASS(const void *klass) \
{ return OBJECT_CLASS_CHECK(ClassType, klass, TYPENAME); }
/**
--
2.26.2
- [PATCH v2 40/58] mptsas: Move QOM macros to header, (continued)
- [PATCH v2 40/58] mptsas: Move QOM macros to header, Eduardo Habkost, 2020/08/19
- [PATCH v2 41/58] kvm: Move QOM macros to kvm.h, Eduardo Habkost, 2020/08/19
- [PATCH v2 42/58] vfio/pci: Move QOM macros to header, Eduardo Habkost, 2020/08/19
- [PATCH v2 43/58] qom: make object_ref/unref use a void * instead of Object *., Eduardo Habkost, 2020/08/19
- [PATCH v2 45/58] qom: Allow class type name to be specified in OBJECT_DECLARE*, Eduardo Habkost, 2020/08/19
- [PATCH v2 47/58] qom: Make type checker functions accept const pointers,
Eduardo Habkost <=
- [PATCH v2 46/58] qom: DECLARE_*_CHECKERS macros, Eduardo Habkost, 2020/08/19
- [PATCH v2 48/58] qom: TYPE_INFO macro, Eduardo Habkost, 2020/08/19
- [PATCH v2 50/58] [automated] Delete duplicate QOM typedefs, Eduardo Habkost, 2020/08/19
- [PATCH v2 44/58] qom: provide convenient macros for declaring and defining types, Eduardo Habkost, 2020/08/19
- [PATCH v2 54/58] [semi-automated] Use DECLARE_*CHECKER* when possible (--force mode), Eduardo Habkost, 2020/08/19