From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: Luiz Capitulino <lcapitul@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] monitor: fix parsing of big int
Date: Thu, 01 Aug 2013 07:52:17 -0600 [thread overview]
Message-ID: <51FA6811.3090909@redhat.com> (raw)
In-Reply-To: <1375338695-670-1-git-send-email-famz@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1688 bytes --]
On 08/01/2013 12:31 AM, Fam Zheng wrote:
> Fix it by calling strtoll instead, which will report ERANGE as expected.
>
> (HMP) block_set_io_throttle ide0-hd0 999999999999999999 0 0 0 0 0
> (HMP) block_set_io_throttle ide0-hd0 9999999999999999999 0 0 0 0 0
> number too large
> (HMP) block_set_io_throttle ide0-hd0 99999999999999999999 0 0 0 0 0
> number too large
Your change causes this error message:
(HMP) block_set_io_throttle ide0-hd0 -99999999999999999999 0 0 0 0 0
number too large
Does the "too large" mean in magnitude (correct message) or in value
(misleading message, as any negative number is smaller in value than our
minimum of 0)?
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> monitor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/monitor.c b/monitor.c
> index 5dc0aa9..7bfb469 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3286,7 +3286,7 @@ static int64_t expr_unary(Monitor *mon)
> break;
> default:
> errno = 0;
> - n = strtoull(pch, &p, 0);
> + n = strtoll(pch, &p, 0);
I'm worried that this will break callers that treat their argument as
unsigned, and where the full range of unsigned input was desirable. At
this point, it's probably safer to do a case-by-case analysis of all
callers that use expr_unary() to decide which callers must reject
negative values, instead of making the parser reject numbers that it
previously accepted, thus changing the behavior of callers that treated
the result as unsigned.
--
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: 621 bytes --]
next prev parent reply other threads:[~2013-08-01 14:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-01 6:31 [Qemu-devel] [PATCH] monitor: fix parsing of big int Fam Zheng
2013-08-01 13:52 ` Eric Blake [this message]
2013-08-01 14:00 ` Luiz Capitulino
2013-08-02 2:39 ` Fam Zheng
2013-08-02 3:07 ` Fam Zheng
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=51FA6811.3090909@redhat.com \
--to=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=lcapitul@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).