From: Eric Blake <eblake@redhat.com>
To: "Lluís Vilanova" <vilanova@ac.upc.edu>, qemu-devel@nongnu.org
Cc: "Benoît Canet" <benoit.canet@irqsave.net>,
"Markus Armbruster" <armbru@redhat.com>,
"Luiz Capitulino" <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 3/4] qapi: Add a primitive to include other files from a QAPI schema file
Date: Mon, 31 Mar 2014 14:00:16 -0600 [thread overview]
Message-ID: <5339C950.8060308@redhat.com> (raw)
In-Reply-To: <20140331191648.21034.9744.stgit@fimbulvetr.bsc.es>
[-- Attachment #1: Type: text/plain, Size: 3359 bytes --]
On 03/31/2014 01:16 PM, Lluís Vilanova wrote:
> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
> docs/qapi-code-gen.txt | 11 +++++++++++
> scripts/qapi.py | 39 ++++++++++++++++++++++++++++++++++-----
> 2 files changed, 45 insertions(+), 5 deletions(-)
I would consider squashing 3 and 4 together, but not the end of the
world to keep them separate.
> @@ -75,9 +80,33 @@ class QAPISchema:
>
> while self.tok != None:
> expr_info = {'fp': fp, 'line': self.line}
> - expr_elem = {'expr': self.get_expr(False),
> - 'info': expr_info}
> - self.exprs.append(expr_elem)
> + expr = self.get_expr(False)
> + if isinstance(expr, dict) and "include" in expr:
> + if len(expr) != 1:
> + raise QAPIExprError(expr_info, "Invalid 'include' directive")
Not covered in patch 4. Ideally, ALL new error messages also come with
a test that exposes the message.
> + include_path = expr["include"]
> + if not isinstance(include_path, str):
> + raise QAPIExprError(expr_info,
> + 'Expected a file path (string), got: %s'
> + % include_path)
s/path/name/ ("path" implies a series of directories to some people)
Good, this one is covered by include-non-file.err
> + if not os.path.isabs(include_path):
> + include_path = os.path.join(self.input_dir, include_path)
> + if not os.path.isfile(include_path):
> + raise QAPIExprError(
> + expr_info,
> + 'Non-existing included file "%s"' %
> + include_path)
Is this error necessary, or would you get a sane error message by just
trying to open the file?
s/included/include/
Good, covered by include-no-file.err
> + if include_path in self.included:
> + raise QAPIExprError(expr_info, "Infinite inclusion loop: %s"
> + % " -> ".join(self.included +
> + [include_path]))
Good, include-self-cycle.err covers a one-file loop, and
include-cycle.err covers a 3-file loop.
Not so good: your error message is an extremely long line:
+tests/qapi-schema/include-cycle-c.json:1: Infinite inclusion loop:
tests/qapi-schema/include-cycle.json ->
tests/qapi-schema/include-cycle-b.json ->
tests/qapi-schema/include-cycle-c.json ->
tests/qapi-schema/include-cycle.json
The formatting in Benoît's series was a little nicer aesthetically:
+Inclusion loop detected with file: multi_file_loop_include.json
+Path to the broken include is:
+ multi_file_loop_include.json
+ multi_loop.json
Furthermore, it had the benefit of using the spelling provided by the
user, rather than the absolute path to the files. You want to track
canonical paths for detecting the loop, but do NOT want to report
absolute paths back to the user - instead, it's nicer to report back the
names as they spelled it.
--
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 --]
next prev parent reply other threads:[~2014-03-31 20:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-31 19:16 [Qemu-devel] [PATCH v6 0/4] qapi: Allow modularization of QAPI schema files Lluís Vilanova
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 1/4] qapi: [trivial] Break long command lines Lluís Vilanova
2014-03-31 19:32 ` Eric Blake
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 2/4] qapi: Use an explicit input file Lluís Vilanova
2014-03-31 19:42 ` Eric Blake
2014-04-01 14:05 ` Lluís Vilanova
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 3/4] qapi: Add a primitive to include other files from a QAPI schema file Lluís Vilanova
2014-03-31 20:00 ` Eric Blake [this message]
2014-04-01 13:46 ` Lluís Vilanova
2014-04-01 14:47 ` Eric Blake
2014-04-01 16:05 ` Lluís Vilanova
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 4/4] qapi: Add tests for the "include" directive Lluís Vilanova
2014-03-31 20:17 ` Eric Blake
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=5339C950.8060308@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=benoit.canet@irqsave.net \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vilanova@ac.upc.edu \
/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).