qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]