aboutsummaryrefslogtreecommitdiff
path: root/qapi/qapi-visit-core.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-04-30 12:53:18 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-04-30 12:53:18 +0100
commit68bfd7db1e8b718187fd0ba4dde32396efcde668 (patch)
tree5ef9a47e0bc096200ae0828053ba0523933bb319 /qapi/qapi-visit-core.c
parent157360331ab3a423e2481b62c60d5399bf2957bd (diff)
parent89bf68f933393a1bc0de4d07b59ffa8920da130f (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-04-30' into staging
QAPI patches for 2020-04-30 # gpg: Signature made Thu 30 Apr 2020 06:29:18 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2020-04-30: qapi: Generate simpler marshalling code when no arguments qapi: Disallow qmp_marshal_FOO(NULL, ...) qom: Simplify object_property_get_enum() qapi: Only input visitors can actually fail qapi: Assert non-input visitors see only valid alternate tags qapi: Clean up visitor's recovery from input with invalid type qapi: Assert non-input visitors see only valid narrow integers qapi: Assert output visitors see only valid enum values qapi: Fix Visitor contract for start_alternate() qapi: Assert incomplete object occurs only in dealloc visitor qapi: Polish prose in visitor.h qapi: Document @errp usage more thoroughly in visitor.h qapi: Fix typo in visit_start_list()'s contract qapi: Fix the virtual walk example in visitor.h's big comment qapi: Belatedly update visitor.h's big comment for QAPI modules qemu-option: Clean up after the previous commit qobject: Eliminate qdict_iter(), use qdict_first(), qdict_next() qobject: Eliminate qlist_iter(), use QLIST_FOREACH_ENTRY() instead qobject: Factor out helper json_pretty_newline() qobject: Clean up QLIST_FOREACH_ENTRY() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qapi/qapi-visit-core.c')
-rw-r--r--qapi/qapi-visit-core.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 5365561b07..74aa9c04bd 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -142,6 +142,11 @@ bool visit_is_input(Visitor *v)
return v->type == VISITOR_INPUT;
}
+bool visit_is_dealloc(Visitor *v)
+{
+ return v->type == VISITOR_DEALLOC;
+}
+
void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp)
{
assert(obj);
@@ -155,10 +160,13 @@ static void visit_type_uintN(Visitor *v, uint64_t *obj, const char *name,
Error *err = NULL;
uint64_t value = *obj;
+ assert(v->type == VISITOR_INPUT || value <= max);
+
v->type_uint64(v, name, &value, &err);
if (err) {
error_propagate(errp, err);
} else if (value > max) {
+ assert(v->type == VISITOR_INPUT);
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", type);
} else {
@@ -214,10 +222,13 @@ static void visit_type_intN(Visitor *v, int64_t *obj, const char *name,
Error *err = NULL;
int64_t value = *obj;
+ assert(v->type == VISITOR_INPUT || (value >= min && value <= max));
+
v->type_int64(v, name, &value, &err);
if (err) {
error_propagate(errp, err);
} else if (value < min || value > max) {
+ assert(v->type == VISITOR_INPUT);
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", type);
} else {
@@ -336,15 +347,6 @@ static void output_type_enum(Visitor *v, const char *name, int *obj,
int value = *obj;
char *enum_str;
- /*
- * TODO why is this an error, not an assertion? If assertion:
- * delete, and rely on qapi_enum_lookup()
- */
- if (value < 0 || value >= lookup->size) {
- error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null");
- return;
- }
-
enum_str = (char *)qapi_enum_lookup(lookup, value);
visit_type_str(v, name, &enum_str, errp);
}