[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 23.5/35] qmp: Tighten output visitor rules, part
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v8 23.5/35] qmp: Tighten output visitor rules, part 2 |
Date: |
Wed, 6 Jan 2016 15:40:28 -0700 |
Nothing was using the return value of qmp_output_pop(). Also,
adding a parameter will let us diagnose any programming bugs
due to mismatched push(struct)/pop(list) or push(list)/pop(struct).
Signed-off-by: Eric Blake <address@hidden>
---
v9: new patch; probably worth squashing into 23/35
---
qapi/qmp-output-visitor.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index f2c39c5..8a297a6 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -1,7 +1,7 @@
/*
* Core Definitions for QAPI/QMP Command Registry
*
- * Copyright (C) 2015 Red Hat, Inc.
+ * Copyright (C) 2015-2016 Red Hat, Inc.
* Copyright IBM, Corp. 2011
*
* Authors:
@@ -57,17 +57,15 @@ static void qmp_output_push_obj(QmpOutputVisitor *qov,
QObject *value)
QTAILQ_INSERT_HEAD(&qov->stack, e, node);
}
-/* Grab and remove the most recent QObject from the stack */
-static QObject *qmp_output_pop(QmpOutputVisitor *qov)
+/* Remove the most recent QObject with given type from the stack */
+static void qmp_output_pop(QmpOutputVisitor *qov, QType type)
{
QStackEntry *e = QTAILQ_FIRST(&qov->stack);
- QObject *value;
assert(e);
QTAILQ_REMOVE(&qov->stack, e, node);
- value = e->value;
+ assert(qobject_type(e->value) == type);
g_free(e);
- return value;
}
/* Grab the most recent QObject from the stack, if any */
@@ -120,7 +118,7 @@ static void qmp_output_start_struct(Visitor *v, const char
*name, void **obj,
static void qmp_output_end_struct(Visitor *v, Error **errp)
{
QmpOutputVisitor *qov = to_qov(v);
- qmp_output_pop(qov);
+ qmp_output_pop(qov, QTYPE_QDICT);
}
static void qmp_output_start_list(Visitor *v, const char *name, Error **errp)
@@ -151,7 +149,7 @@ static GenericList *qmp_output_next_list(Visitor *v,
GenericList **listp,
static void qmp_output_end_list(Visitor *v)
{
QmpOutputVisitor *qov = to_qov(v);
- qmp_output_pop(qov);
+ qmp_output_pop(qov, QTYPE_QLIST);
}
static void qmp_output_type_int64(Visitor *v, const char *name, int64_t *obj,
--
2.4.3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH v8 23.5/35] qmp: Tighten output visitor rules, part 2,
Eric Blake <=