[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v9 02/37] qapi: Avoid use of misnamed DO_UPCAST(
Re: [Qemu-devel] [PATCH v9 02/37] qapi: Avoid use of misnamed DO_UPCAST()
Wed, 20 Jan 2016 08:59:14 -0700
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0
On 01/20/2016 03:04 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>> The macro DO_UPCAST() is incorrectly named: it converts from a
>> parent class to a derived class (which is a downcast). Better,
>> and more consistent with some of the other qapi visitors, is
>> to use the container_of() macro through a to_FOO() helper.
>> Our current definition of container_of() is weaker than
>> DO_UPCAST(), in that it does not require the derived class to
>> have Visitor as its first member, but this does not hurt our
>> usage patterns in qapi visitors.
>> Signed-off-by: Eric Blake <address@hidden>
>> Reviewed-by: Marc-André Lureau <address@hidden>
>> +static OptsVisitor *to_ov(Visitor *v)
>> + return container_of(v, OptsVisitor, visitor);
> The name to_ov() is rather laconic even for my taste. Tolerable, since
> it's static.
And matches existing practice pre-patch:
qapi/qapi-dealloc-visitor.c:static QapiDeallocVisitor *to_qov(Visitor *v)
qapi/qmp-input-visitor.c:static QmpInputVisitor *to_qiv(Visitor *v)
qapi/qmp-output-visitor.c:static QmpOutputVisitor *to_qov(Visitor *v)
> Patch gets rid of all DO_UPCAST() in qapi/. PATCH 33 brings one back;
> it should use to_ov() instead.
D'oh. You can tell what order I wrote the patches in :)
If I need to respin, I'll fix it; otherwise, I assume you can handle it.
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Description: OpenPGP digital signature
[Qemu-devel] [PATCH v9 13/37] qom: Use typedef for Visitor, Eric Blake, 2016/01/19
[Qemu-devel] [PATCH v9 02/37] qapi: Avoid use of misnamed DO_UPCAST(), Eric Blake, 2016/01/19
[Qemu-devel] [PATCH v9 12/37] qapi: Don't cast Enum* to int*, Eric Blake, 2016/01/19
[Qemu-devel] [PATCH v9 10/37] qapi: Make all visitors supply uint64 callbacks, Eric Blake, 2016/01/19
- [Qemu-devel] [PATCH v9 03/37] qapi: Drop dead dealloc visitor variable, (continued)