summaryrefslogtreecommitdiffstats
path: root/include/qapi/visitor.h
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-12-01 22:20:51 -0700
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:19 -0600
commit579ce02dc1dadfb2a98e2f9d62ec0228f5dad6fa (patch)
treec9776b7755e4b780b55fd903a6bb84673a35af74 /include/qapi/visitor.h
parent68dfce67bc7a7c18cfc1d45090f17a34f061ef0b (diff)
downloadhqemu-579ce02dc1dadfb2a98e2f9d62ec0228f5dad6fa.zip
hqemu-579ce02dc1dadfb2a98e2f9d62ec0228f5dad6fa.tar.gz
qapi: Fix alternates that accept 'number' but not 'int'
The QMP input visitor allows integral values to be assigned by promotion to a QTYPE_QFLOAT. However, when parsing an alternate, we did not take this into account, such that an alternate that accepts 'number' and some other type, but not 'int', would reject integral values. With this patch, we now have the following desirable table: alternate has case selected for 'int' 'number' QTYPE_QINT QTYPE_QFLOAT no no error error no yes 'number' 'number' yes no 'int' error yes yes 'int' 'number' While it is unlikely that we will ever use 'number' in an alternate other than in the testsuite, it never hurts to be more precise in what we allow. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1449033659-25497-8-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qapi/visitor.h')
-rw-r--r--include/qapi/visitor.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 6d25ad2..1414de1 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -43,8 +43,9 @@ void visit_optional(Visitor *v, bool *present, const char *name,
* Determine the qtype of the item @name in the current object visit.
* For input visitors, set *@type to the correct qtype of a qapi
* alternate type; for other visitors, leave *@type unchanged.
+ * If @promote_int, treat integers as QTYPE_FLOAT.
*/
-void visit_get_next_type(Visitor *v, QType *type,
+void visit_get_next_type(Visitor *v, QType *type, bool promote_int,
const char *name, Error **errp);
void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp);
OpenPOWER on IntegriCloud