aboutsummaryrefslogtreecommitdiff
path: root/qapi/qobject-input-visitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-04-27 10:41:26 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-05-09 09:14:40 +0200
commit8b2e41d733850ec6a67a85743138e023cbb8921b (patch)
treefd7d17396b28e4028d7474cffadc3264048bfd2c /qapi/qobject-input-visitor.c
parented0ba0f47e8cb6d924db0a54090bbb7b095fe9ea (diff)
downloadqemu-8b2e41d733850ec6a67a85743138e023cbb8921b.zip
qemu-8b2e41d733850ec6a67a85743138e023cbb8921b.tar.gz
qemu-8b2e41d733850ec6a67a85743138e023cbb8921b.tar.bz2
qobject-input-visitor: Catch misuse of end_struct vs. end_list
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1493282486-28338-5-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [More elaborate assertions for clarity]
Diffstat (limited to 'qapi/qobject-input-visitor.c')
-rw-r--r--qapi/qobject-input-visitor.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 2530959..d0f0002 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -291,6 +291,15 @@ static void qobject_input_start_struct(Visitor *v, const char *name, void **obj,
}
}
+static void qobject_input_end_struct(Visitor *v, void **obj)
+{
+ QObjectInputVisitor *qiv = to_qiv(v);
+ StackObject *tos = QSLIST_FIRST(&qiv->stack);
+
+ assert(qobject_type(tos->obj) == QTYPE_QDICT && tos->h);
+ qobject_input_pop(v, obj);
+}
+
static void qobject_input_start_list(Visitor *v, const char *name,
GenericList **list, size_t size,
@@ -346,6 +355,14 @@ static void qobject_input_check_list(Visitor *v, Error **errp)
}
}
+static void qobject_input_end_list(Visitor *v, void **obj)
+{
+ QObjectInputVisitor *qiv = to_qiv(v);
+ StackObject *tos = QSLIST_FIRST(&qiv->stack);
+
+ assert(qobject_type(tos->obj) == QTYPE_QLIST && !tos->h);
+ qobject_input_pop(v, obj);
+}
static void qobject_input_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
@@ -645,11 +662,11 @@ static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj)
v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qobject_input_start_struct;
v->visitor.check_struct = qobject_input_check_struct;
- v->visitor.end_struct = qobject_input_pop;
+ v->visitor.end_struct = qobject_input_end_struct;
v->visitor.start_list = qobject_input_start_list;
v->visitor.next_list = qobject_input_next_list;
v->visitor.check_list = qobject_input_check_list;
- v->visitor.end_list = qobject_input_pop;
+ v->visitor.end_list = qobject_input_end_list;
v->visitor.start_alternate = qobject_input_start_alternate;
v->visitor.optional = qobject_input_optional;
v->visitor.free = qobject_input_free;