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: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v6 2/5] qobject: use a QObjectBase_ struct
Date: Fri, 27 Apr 2018 10:29:05 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 04/27/2018 03:24 AM, Markus Armbruster wrote:
> 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.

I'm fine if you leave the typedef out, without modifying anything.

> 
>> 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>
> 
> 

-- 
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]