qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 1.1] qapi: QMP input visitor, handle floats parsed as ints
Date: Fri, 11 May 2012 16:30:40 -0300	[thread overview]
Message-ID: <20120511163040.5c3b825e@doriath.home> (raw)
In-Reply-To: <1336758204-9118-1-git-send-email-mdroth@linux.vnet.ibm.com>

On Fri, 11 May 2012 12:43:24 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> JSON numbers can be interpreted as either integers or floating point
> values depending on their representation. As a result, QMP input visitor
> might visit a QInt when it was expecting a QFloat, so add handling to
> account for this.
> 
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Applied to the QMP branch, thanks.

> ---
>  qapi/qmp-input-visitor.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
> index 4cdc47d..107d8d3 100644
> --- a/qapi/qmp-input-visitor.c
> +++ b/qapi/qmp-input-visitor.c
> @@ -246,13 +246,18 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
>      QmpInputVisitor *qiv = to_qiv(v);
>      QObject *qobj = qmp_input_get_object(qiv, name);
>  
> -    if (!qobj || qobject_type(qobj) != QTYPE_QFLOAT) {
> +    if (!qobj || (qobject_type(qobj) != QTYPE_QFLOAT &&
> +        qobject_type(qobj) != QTYPE_QINT)) {
>          error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
> -                  "double");
> +                  "number");
>          return;
>      }
>  
> -    *obj = qfloat_get_double(qobject_to_qfloat(qobj));
> +    if (qobject_type(qobj) == QTYPE_QINT) {
> +        *obj = qint_get_int(qobject_to_qint(qobj));
> +    } else {
> +        *obj = qfloat_get_double(qobject_to_qfloat(qobj));
> +    }
>  }
>  
>  static void qmp_input_start_optional(Visitor *v, bool *present,

      parent reply	other threads:[~2012-05-11 19:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 17:43 [Qemu-devel] [PATCH 1.1] qapi: QMP input visitor, handle floats parsed as ints Michael Roth
2012-05-11 17:49 ` Andreas Färber
2012-05-11 19:30 ` Luiz Capitulino [this message]

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=20120511163040.5c3b825e@doriath.home \
    --to=lcapitulino@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=mdroth@linux.vnet.ibm.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).