qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 1/5] qobject: ensure base is at offset 0


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v5 1/5] qobject: ensure base is at offset 0
Date: Tue, 17 Apr 2018 13:17:46 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

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 <address@hidden>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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