qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qapi: Fix error handling code on alternate conflict
Date: Mon, 17 Jul 2017 15:04:18 -0300	[thread overview]
Message-ID: <20170717180418.GZ6020@localhost.localdomain> (raw)
In-Reply-To: <68543d33-8f49-5948-dc4c-fc678ac6aee7@redhat.com>

On Mon, Jul 17, 2017 at 09:45:01AM -0500, Eric Blake wrote:
> On 07/14/2017 03:33 PM, Eduardo Habkost wrote:
> > 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>
> > ---
> 
> > +++ b/tests/qapi-schema/alternate-conflict-bool-string.err
> > @@ -0,0 +1 @@
> > +tests/qapi-schema/alternate-conflict-bool-string.json:3: Alternate 'Alt' member 'two' can't be distinguished from member 'one'
> 
> Claims the error is at line 3,
> 
> > +++ b/tests/qapi-schema/alternate-conflict-bool-string.json
> > @@ -0,0 +1,4 @@
> > +# alternate branches of 'str' type conflict with all scalar types
> > +{ 'alternate': 'Alt',
> 
> but the declaration starts at line 2.  That's probably why patchew
> complained that your patch doesn't build.  The idea looks sane, though;
> looking forward to v2.

Oops, sorry!  I had a two-line comment in the beginning of the
file and decided to update it just before submitting the series.

-- 
Eduardo

      reply	other threads:[~2017-07-17 18:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 20:33 [Qemu-devel] [PATCH] qapi: Fix error handling code on alternate conflict Eduardo Habkost
2017-07-15  2:33 ` no-reply
2017-07-17 14:45 ` Eric Blake
2017-07-17 18:04   ` 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=20170717180418.GZ6020@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).