From: Luiz Capitulino <lcapitulino@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2] qapi: treat all negative return of strtosz_suffix() as error
Date: Mon, 5 May 2014 16:10:17 -0400 [thread overview]
Message-ID: <20140505161017.557b0f13@redhat.com> (raw)
In-Reply-To: <1398664429-10682-1-git-send-email-akong@redhat.com>
On Mon, 28 Apr 2014 13:53:49 +0800
Amos Kong <akong@redhat.com> wrote:
> strtosz_suffix() might return negative error, this patch fixes
> the error handling.
>
> This patch also changes to handle error in the if statement
> rather than handle success specially, this will make this use
> of strtosz_suffix consistent with all other uses.
>
> Signed-off-by: Amos Kong <akong@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Applied to the qmp branch, thanks.
> ---
> qapi/opts-visitor.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
> index 5d830a2..87c1c78 100644
> --- a/qapi/opts-visitor.c
> +++ b/qapi/opts-visitor.c
> @@ -472,13 +472,14 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
>
> val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
> STRTOSZ_DEFSUFFIX_B);
> - if (val != -1 && *endptr == '\0') {
> - *obj = val;
> - processed(ov, name);
> + if (val < 0 || *endptr) {
> + error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
> + "a size value representible as a non-negative int64");
> return;
> }
> - error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
> - "a size value representible as a non-negative int64");
> +
> + *obj = val;
> + processed(ov, name);
> }
>
>
parent reply other threads:[~2014-05-05 21:04 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1398664429-10682-1-git-send-email-akong@redhat.com>]
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=20140505161017.557b0f13@redhat.com \
--to=lcapitulino@redhat.com \
--cc=akong@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mst@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).