[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V6 02/10] qapi script: add check for duplicated
From: |
Wenchao Xia |
Subject: |
Re: [Qemu-devel] [PATCH V6 02/10] qapi script: add check for duplicated key |
Date: |
Fri, 14 Feb 2014 09:50:31 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
δΊ 2014/2/13 23:14, Markus Armbruster ει:
> Wenchao Xia <address@hidden> writes:
>
>> It is bad that same key was specified twice, especially when a union have
>> two branches with same condition. This patch can prevent it.
>>
>> Signed-off-by: Wenchao Xia <address@hidden>
>> Reviewed-by: Eric Blake <address@hidden>
>> ---
>> scripts/qapi.py | 2 ++
>> 1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/scripts/qapi.py b/scripts/qapi.py
>> index aec6bbb..cf34768 100644
>> --- a/scripts/qapi.py
>> +++ b/scripts/qapi.py
>> @@ -116,6 +116,8 @@ class QAPISchema:
>> if self.tok != ':':
>> raise QAPISchemaError(self, 'Expected ":"')
>> self.accept()
>> + if key in expr:
>> + raise QAPISchemaError(self, 'Duplicated key "%s"' % key)
>> expr[key] = self.get_expr(True)
>> if self.tok == '}':
>> self.accept()
>
> All errors should have a test in tests/qapi-schema/. I can try to add
> tests for you when I rebase your 09/10.
>
I considered error path test before but didn't find a good place to
go. It would be great if you can add one.
- [Qemu-devel] [PATCH V6 00/10] qapi script: support enum as discriminator and better enum name, Wenchao Xia, 2014/02/11
- [Qemu-devel] [PATCH V6 01/10] qapi script: remember enum values, Wenchao Xia, 2014/02/11
- [Qemu-devel] [PATCH V6 06/10] qapi script: support pre-defined enum type as discriminator in union, Wenchao Xia, 2014/02/11
- [Qemu-devel] [PATCH V6 04/10] qapi script: code move for generate_enum_name(), Wenchao Xia, 2014/02/11
- [Qemu-devel] [PATCH V6 05/10] qapi script: use same function to generate enum string, Wenchao Xia, 2014/02/11
- [Qemu-devel] [PATCH V6 08/10] qapi script: do not allow string discriminator, Wenchao Xia, 2014/02/11
- [Qemu-devel] [PATCH V6 07/10] qapi: convert BlockdevOptions to use enum discriminator, Wenchao Xia, 2014/02/11
- [Qemu-devel] [PATCH V6 09/10] tests: add cases for inherited struct and union with discriminator, Wenchao Xia, 2014/02/11