[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>
Re: [Qemu-devel] [PATCH v6 1/5] qobject: ensure base is at offset 0, Markus Armbruster, 2018/04/27
[Qemu-devel] [PATCH v6 2/5] qobject: use a QObjectBase_ struct, Marc-André Lureau, 2018/04/19
- Re: [Qemu-devel] [PATCH v6 2/5] qobject: use a QObjectBase_ struct,
Markus Armbruster <=
[Qemu-devel] [PATCH v6 5/5] qobject: modify qobject_ref() to assert on NULL, Marc-André Lureau, 2018/04/19
[Qemu-devel] [PATCH v6 4/5] qobject: modify qobject_ref() to return obj, Marc-André Lureau, 2018/04/19
[Qemu-devel] [PATCH v6 3/5] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF, Marc-André Lureau, 2018/04/19