All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] qapi: Fix error handling code on alternate conflict
Date: Thu, 20 Jul 2017 14:52:23 -0300	[thread overview]
Message-ID: <20170720175223.GR2757@localhost.localdomain> (raw)
In-Reply-To: <877ez3rsp7.fsf@dusky.pond.sub.org>

On Thu, Jul 20, 2017 at 06:14:44PM +0200, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
> 
> > The conflict check added by commit c0644771 ("qapi: Reject
> > alternates that can't work with keyval_parse()") doesn't work
> > with the following declaration:
> >
> >   { 'alternate': 'Alt',
> >     'data': { 'one': 'bool',
> >               'two': 'str' } }
> >
> > It crashes with:
> >
> >   Traceback (most recent call last):
> >     File "./scripts/qapi-types.py", line 295, in <module>
> >       schema = QAPISchema(input_file)
> >     File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 1468, in __init__
> >       self.exprs = check_exprs(parser.exprs)
> >     File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 958, in check_exprs
> >       check_alternate(expr, info)
> >     File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 830, in check_alternate
> >       % (name, key, types_seen[qtype]))
> >   KeyError: 'QTYPE_QSTRING'
> >
> > This happens because the previously-seen conflicting member
> > ('one') can't be found at types_seen[qtype], but at
> > types_seen['QTYPE_BOOL'].
> >
> > Fix the bug by moving the error check to the same loop that adds
> > new items to types_seen, raising an exception if types_seen[qt]
> > is already set.
> >
> > Add two additional test cases that can detect the bug.
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> [...]
> > diff --git a/tests/qapi-schema/alternate-conflict-num-string.out b/tests/qapi-schema/alternate-conflict-num-string.out
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/tests/qapi-schema/alternate-multi-conflict.json b/tests/qapi-schema/alternate-multi-conflict.json
> > new file mode 100644
> > index 0000000..e69de29
> 
> Accident?  Can drop on commit.

Yes, sorry.  Thanks for spotting it.

-- 
Eduardo

      reply	other threads:[~2017-07-20 17:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 18:09 [Qemu-devel] [PATCH v2] qapi: Fix error handling code on alternate conflict Eduardo Habkost
2017-07-17 18:14 ` Eric Blake
2017-07-19  8:32 ` Markus Armbruster
2017-07-20 16:14 ` Markus Armbruster
2017-07-20 17:52   ` Eduardo Habkost [this message]

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=20170720175223.GR2757@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.