On 04/17/2018 08:35 AM, Marc-André Lureau wrote: > All QObject types have the base QObject as first field. This allows to
s/as/as their/ > simplify qobject_to() and will allow further simplification in s/allows to simplify/allows the simplification of/ s/in/in the/ > following patch. Might also be worth mentioning that this explicitly guarantees that existing casts work correctly (even though we'd prefer to get rid of such casts in any location except the qobject.h macros); Markus pointed out: >> Uh, there's another reason: existing type casts from QObject * to >> subtypes. I just spotted one in tests/check-qdict.c: >> >> dst = (QDict *)qdict_crumple(src, &error_abort); > +++ b/qobject/qobject.c > @@ -16,6 +16,15 @@ > #include "qapi/qmp/qlist.h" > #include "qapi/qmp/qstring.h" > > +QEMU_BUILD_BUG_MSG( > + offsetof(QNull, base) != 0 || Is the ' != 0' portion necessary? Style-wise, I'd have avoided it, but HACKING doesn't forbid it, so I'm fine if you leave it. With the commit message further improved, Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature