From: Fam Zheng <famz@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] blockdev: Error out on negative throttling option values
Date: Thu, 14 Jan 2016 11:14:15 +0800 [thread overview]
Message-ID: <20160114031415.GB8550@ad.usersys.redhat.com> (raw)
In-Reply-To: <w517fjdivg1.fsf@maestria.local.igalia.com>
On Wed, 01/13 12:13, Alberto Garcia wrote:
> On Wed 13 Jan 2016 12:02:00 PM CET, Fam Zheng wrote:
>
> >> > Check the number range so this case is catched and reported.
> >>
> >> I still don't know why qemu_opt_get_number() convert silently
> >> negative numbers into positive ones, shouldn't it just fail with an
> >> "invalid parameter" error?
> >
> > Because the parsing is done with strtoull(3) and unfortunately its man
> > page says "negative values are considered valid input and are silently
> > converted to the equivalent unsigned long int value."
>
> I see... parse_uint() from cutils.c handles that by making an explicit
> check for negative numbers. It probably makes sense to apply the same
> solution (or even merge the code to the extent to which it's possible).
>
> I also noticed that there's a couple of places where we're calling
> qemu_opt_get_number() passing -1 as default value, so maybe that API
> needs to be reviewed anyway.
Those callers rely on casting preserves the MSB as the sign, but that's ugly.
Anyway I'd leave the API change for a separate series and keep this patch local
to fix this particular regression. :)
Fam
next prev parent reply other threads:[~2016-01-14 3:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 0:52 [Qemu-devel] [PATCH v2 0/2] block: Reject negative values for throttling options Fam Zheng
2016-01-13 0:52 ` [Qemu-devel] [PATCH v2 1/2] blockdev: Error out on negative throttling option values Fam Zheng
2016-01-13 10:17 ` Alberto Garcia
2016-01-13 11:02 ` Fam Zheng
2016-01-13 11:13 ` Alberto Garcia
2016-01-14 3:14 ` Fam Zheng [this message]
2016-01-14 3:21 ` Eric Blake
2016-01-13 0:52 ` [Qemu-devel] [PATCH v2 2/2] iotests: Test that negative throttle values are rejected Fam Zheng
2016-01-13 10:02 ` Alberto Garcia
2016-01-14 3:17 ` 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=20160114031415.GB8550@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--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).