[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions |
Date: |
Fri, 31 Jul 2015 11:46:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Markus Armbruster <address@hidden> writes:
> Eric Blake <address@hidden> writes:
>
>> On 07/01/2015 02:21 PM, Markus Armbruster wrote:
>>> The struct generated for a flat union is weird: the members of its
>>> base are at the end, except for the union tag, which is renamed to
>>> 'kind' and put at the beginning.
>>
>> The renaming to 'kind' was a bug waiting to happen. Consider this
>> example, which is broken before your series:
>>
>> diff --git i/tests/qapi-schema/qapi-schema-test.json
>> w/tests/qapi-schema/qapi-schema-test.json
>> index c7eaa86..12c09e3 100644
>> --- i/tests/qapi-schema/qapi-schema-test.json
>> +++ w/tests/qapi-schema/qapi-schema-test.json
>> @@ -37,7 +37,7 @@
>> 'data': { 'string1': 'str', 'string2': 'str' } }
>>
>> { 'struct': 'UserDefUnionBase',
>> - 'data': { 'string': 'str', 'enum1': 'EnumOne' } }
>> + 'data': { 'kind': 'str', 'enum1': 'EnumOne' } }
>>
>> { 'union': 'UserDefFlatUnion',
>> 'base': 'UserDefUnionBase',
>>
>>
>> leading to this compilation error during 'make check-unit':
>>
>> In file included from tests/test-qmp-output-visitor.c:17:0:
>> tests/test-qapi-types.h:617:11: error: duplicate member ‘kind’
>> char *kind;
>> ^
>> tests/test-qapi-types.h:631:11: error: duplicate member ‘kind’
>> char *kind;
>> ^
>>
>> Therefore, it might be worth mentioning that avoiding the rename to
>> 'kind' is a bug fix, not just a nicer struct :)
>
> Cool! I'll work (a variation of) this test case into my series.
I split the bug fix off this patch. I put the test in the commit
message, because I feel it has little value as regression test going
forward.
- Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, (continued)
Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Eric Blake, 2015/07/28
- Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Markus Armbruster, 2015/07/29
- Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Eric Blake, 2015/07/29
- Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Markus Armbruster, 2015/07/30
- Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Eric Blake, 2015/07/30
- Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Markus Armbruster, 2015/07/30
- Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Eric Blake, 2015/07/30
Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Markus Armbruster, 2015/07/31
Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions,
Markus Armbruster <=
[Qemu-devel] [PATCH RFC v2 01/47] qapi: Clarify docs on including the same file multiple times, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 05/47] qapi: Reject -p arguments that break qapi-event.py, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 10/47] qapi-visit: Fix two name arguments passed to visitors, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 11/47] tests/qapi-schema: Document alternate's enum lacks visit function, Markus Armbruster, 2015/07/01