qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 2/5] qobject: use a QObjectBase_ struct


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v6 2/5] qobject: use a QObjectBase_ struct
Date: Fri, 27 Apr 2018 10:24:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Marc-André Lureau <address@hidden> writes:

> By moving the base fields to a QObjectBase_, QObject can be a type
> which also has a 'base' field. This allows writing a generic QOBJECT()
> macro that will work with any QObject type, including QObject
> itself. The container_of() macro ensures that the object to cast has a
> QObjectBase_ base field, giving some type safety guarantees. QObject
> must have no members but QObjectBase_ base, or else QOBJECT() breaks.
>
> QObjectBase_ is not a typedef and uses a trailing underscore to make
> it obvious it is not for normal use and to avoid potential abuse.

The omission of typedef to signal "internal use" is unusual in QEMU.
Doesn't bother *me*, but then I wouldn't typedef any struct or union if
consistency with the bulk of QEMU's code didn't demand it.

I can add the typedef and update the commit message if desired.

> Signed-off-by: Marc-André Lureau <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>

I would've been tempted to try an unnamed field, but (1) that might've
been too clever, and (2) this patch exists and works.

With or without the typedef:
Reviewed-by: Markus Armbruster <address@hidden>



reply via email to

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