All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Wenchao Xia <wenchaoqemu@gmail.com>, qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com, kwolf@redhat.com,
	Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
	armbru@redhat.com, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH V8 02/10] qapi script: add check for duplicated key
Date: Thu, 27 Feb 2014 08:41:07 -0700	[thread overview]
Message-ID: <530F5C93.1000308@redhat.com> (raw)
In-Reply-To: <1393499376-4374-3-git-send-email-wenchaoqemu@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]

On 02/27/2014 04:09 AM, Wenchao Xia wrote:
> From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> 
> It is bad that same key was specified twice, especially when a union have

s/have/has/

> two branches with same condition. This patch can prevent it.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>

Again, the double S-o-B is odd.

> ---
>  scripts/qapi.py                      |    2 ++
>  tests/Makefile                       |    3 ++-
>  tests/qapi-schema/duplicate-key.err  |    1 +
>  tests/qapi-schema/duplicate-key.exit |    1 +
>  tests/qapi-schema/duplicate-key.json |    2 ++
>  5 files changed, 8 insertions(+), 1 deletions(-)
>  create mode 100644 tests/qapi-schema/duplicate-key.err
>  create mode 100644 tests/qapi-schema/duplicate-key.exit
>  create mode 100644 tests/qapi-schema/duplicate-key.json
>  create mode 100644 tests/qapi-schema/duplicate-key.out
> 

> +++ b/tests/qapi-schema/duplicate-key.json
> @@ -0,0 +1,2 @@
> +{ 'key': 'value',
> +  'key': 'value' }

This tests a duplicate key in a dictionary.  Since unions use
'data':{dictionary}, that means you caught duplicate branches within a
union.  Based on your test, your patch also has the nice effect of
catching duplicates unrelated to unions!  This test is of a top-level
struct; a bit more realistic might be:

{ 'command': 'foo',
  'command': 'foo', 'data': {} }

Meanwhile, should we also test for duplicates in non-dict locations,
such as:

{ 'enum': 'Foo', 'data': [ 'value', 'value' ] }

or even tests of duplicate top-level items, such as:

{ 'type': 'Dup', 'data': { 'field':'str' } }
{ 'type': 'Dup', 'data': { 'field':'str' } }

But I'm okay with that as a followup, in the interest of getting this
series in.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-02-27 16:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27 11:09 [Qemu-devel] [PATCH V8 00/10] qapi script: support enum as discriminator and better enum name Wenchao Xia
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 01/10] qapi script: remember explicitly defined enum values Wenchao Xia
2014-02-27 13:45   ` Eric Blake
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 02/10] qapi script: add check for duplicated key Wenchao Xia
2014-02-27 15:41   ` Eric Blake [this message]
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 03/10] qapi script: remember line number in schema parsing Wenchao Xia
2014-02-27 18:03   ` Eric Blake
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 04/10] qapi script: check correctness of union Wenchao Xia
2014-02-27 19:21   ` Eric Blake
2014-02-28 23:19     ` Wenchao Xia
2014-03-04 12:47   ` Markus Armbruster
2014-03-04 14:54     ` Wenchao Xia
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 05/10] qapi script: code move for generate_enum_name() Wenchao Xia
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 06/10] qapi script: use same function to generate enum string Wenchao Xia
2014-02-27 20:12   ` Eric Blake
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 07/10] qapi script: support enum type as discriminator in union Wenchao Xia
2014-02-27 21:27   ` Eric Blake
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 08/10] qapi: convert BlockdevOptions to use enum discriminator Wenchao Xia
2014-02-27 21:54   ` Eric Blake
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 09/10] qapi script: do not allow string discriminator Wenchao Xia
2014-02-27 22:05   ` Eric Blake
2014-02-27 11:09 ` [Qemu-devel] [PATCH V8 10/10] qapi script: do not add "_" for every capitalized char in enum Wenchao Xia
2014-02-28 23:25 ` [Qemu-devel] [PATCH V8 00/10] qapi script: support enum as discriminator and better enum name Wenchao Xia
2014-03-01  7:09   ` Markus Armbruster
2014-03-04 13:03 ` Markus Armbruster
2014-03-04 13:35   ` Luiz Capitulino
2014-03-04 13:53     ` Markus Armbruster
2014-03-04 14:55       ` Wenchao Xia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=530F5C93.1000308@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wenchaoqemu@gmail.com \
    --cc=xiawenc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.