[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: |
Eduardo Habkost |
Subject: |
Re: [PATCH 30/41] qom: Make type checker functions accept const pointers |
Date: |
Tue, 18 Aug 2020 16:56:48 -0400 |
On Mon, Aug 17, 2020 at 05:08:41PM +0100, Daniel P. Berrangé wrote:
> On Thu, Aug 13, 2020 at 06:26:14PM -0400, 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.
>
> I'm not sure what you mean by "use _Generic" ?
I meant something like:
#define OBJECT_CHECK(Type, obj, ...) \
_Generic((obj),
void *: (Type *)object_dynamic_cast_assert(obj, ...),
const void *: (const Type *)object_dynamic_cast_assert(obj,
...))
However, now we'll generate type checking functions instead of
type checking macros, so making (for example) DEVICE((Object*)x)
and DEVICE((const Object*)x) return a different type would be
impossible.
--
Eduardo
- [PATCH 20/41] mcf_fec: Move mcf_fec_state typedef to header, (continued)
- [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
- [PATCH 37/41] [automated] Use DECLARE_*CHECKER* when possible (--force mode), Eduardo Habkost, 2020/08/13