From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH v2 1/7] qapi: Allow decimal values
Date: Tue, 20 May 2014 09:11:51 -0600 [thread overview]
Message-ID: <537B70B7.1090107@redhat.com> (raw)
In-Reply-To: <1400576881-6954-2-git-send-email-famz@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1978 bytes --]
On 05/20/2014 03:07 AM, Fam Zheng wrote:
> This allows giving decimal constants in the schema as expr.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> scripts/qapi.py | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 0265b40..4c945ad 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -157,6 +157,21 @@ class QAPISchema:
> return
> else:
> string += ch
> + elif self.tok in "-0123456789":
> + val = self.tok
> + while self.src[self.cursor] in "0123456789":
> + val += self.src[self.cursor]
> + self.cursor += 1
> + try:
> + if val.startswith("0") and len(val) > 1:
This fails to diagnose '-0123' as invalid. Which means your test case
in 3/7 is incomplete.
> + raise Exception("Leading zero for non-zero integer")
For the string "00", this message makes no sense. You are properly
diagnosing that double 0 is not a valid JSON int, but it is also not a
"non-zero integer". Maybe just "Leading zero not permitted for integer".
> + self.val = int(val)
> + if self.val > 0x7fffffffffffffffL or self.val < -0x7fffffffffffffffL - 1:
> + raise Exception("Value too big")
Forces the user to use int64_t rather than allowing for uint64_t
defaults (if we have an unsigned value that defaults to anything larger
than INT64_MAX, it would have to be written in 2s-complement negative
form) - but that's okay with me (I really doubt we'd have any default in
that situation except possibly UINT64_MAX, but writing -1 for UINT64_MAX
doesn't feel too bad).
--
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-05-20 15:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 9:07 [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json Fam Zheng
2014-05-20 9:07 ` [Qemu-devel] [RFC PATCH v2 1/7] qapi: Allow decimal values Fam Zheng
2014-05-20 15:11 ` Eric Blake [this message]
2014-05-20 9:07 ` [Qemu-devel] [RFC PATCH v2 2/7] qapi: Allow true, false and null in schema json Fam Zheng
2014-05-20 19:20 ` Eric Blake
2014-05-20 9:07 ` [Qemu-devel] [RFC PATCH v2 3/7] tests: Add decimal test cases for qapi-schema Fam Zheng
2014-05-20 12:43 ` Eric Blake
2014-05-20 9:07 ` [Qemu-devel] [RFC PATCH v2 4/7] qapi: Add c_val(t, val) for int Fam Zheng
2014-05-20 9:07 ` [Qemu-devel] [RFC PATCH v2 5/7] qapi: Add @arg property dictionary syntax Fam Zheng
2014-05-20 9:08 ` [Qemu-devel] [RFC PATCH v2 6/7] qapi: Initialize argument value in generated code if has 'default' Fam Zheng
2014-05-20 9:08 ` [Qemu-devel] [RFC PATCH v2 7/7] qmp: Convert block-commit speed to arg property dict Fam Zheng
2014-05-20 9:16 ` [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json Fam Zheng
2014-05-20 19:13 ` Eric Blake
2014-05-21 1:59 ` Fam Zheng
2014-05-21 5:54 ` Markus Armbruster
2014-05-21 7:09 ` Fam Zheng
2014-05-21 7:46 ` Markus Armbruster
2014-05-21 8:23 ` Kevin Wolf
2014-05-21 8:42 ` Fam Zheng
2014-05-21 9:01 ` Kevin Wolf
2014-05-21 11:32 ` Eric Blake
2014-05-21 9:35 ` Markus Armbruster
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=537B70B7.1090107@redhat.com \
--to=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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.