[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 30/41] qom: Make type checker functions accept const pointers
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH 30/41] qom: Make type checker functions accept const pointers |
Date: |
Fri, 14 Aug 2020 20:05:50 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 8/14/20 12:26 AM, Eduardo Habkost wrote:
> 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.
>
> In the future, we might use _Generic to preserve const-ness of
> the cast function arguments.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> 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); }
>
> /**
>
- [PATCH 27/41] qom: Fix G_DEFINE_AUTOPTR_CLEANUP_FUNC, (continued)
- [PATCH 27/41] qom: Fix G_DEFINE_AUTOPTR_CLEANUP_FUNC, Eduardo Habkost, 2020/08/13
- [PATCH 20/41] mcf_fec: Move mcf_fec_state typedef to header, Eduardo Habkost, 2020/08/13
- [PATCH 23/41] nubus: Delete unused NUBUS_BRIDGE macro, Eduardo Habkost, 2020/08/13
- [PATCH 25/41] qom: make object_ref/unref use a void * instead of Object *., Eduardo Habkost, 2020/08/13
- [PATCH 26/41] qom: provide convenient macros for declaring and defining types, Eduardo Habkost, 2020/08/13
- [PATCH 30/41] qom: Make type checker functions accept const pointers, Eduardo Habkost, 2020/08/13
- [PATCH 29/41] qom: DECLARE_*_CHECKERS macros, Eduardo Habkost, 2020/08/13
- [PATCH 31/41] qom: TYPE_INFO macro, Eduardo Habkost, 2020/08/13
- [PATCH 33/41] [automated] Delete duplicate QOM typedefs, Eduardo Habkost, 2020/08/13
- [PATCH 32/41] codeconverter: script for automating QOM code cleanups, Eduardo Habkost, 2020/08/13
- [PATCH 39/41] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible, Eduardo Habkost, 2020/08/13