@@ -20,7 +20,6 @@
typedef struct QmpOutputVisitor QmpOutputVisitor;
QmpOutputVisitor *qmp_output_visitor_new(void);
-void qmp_output_visitor_cleanup(QmpOutputVisitor *v);
QObject *qmp_output_get_qobject(QmpOutputVisitor *v);
Visitor *qmp_output_get_visitor(QmpOutputVisitor *v);
@@ -699,7 +699,7 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
assert(qobject_type(obj) == QTYPE_QDICT);
data = qdict_get(qobject_to_qdict(obj), "data");
dump_qobject(func_fprintf, f, 1, data);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
}
void bdrv_image_info_dump(fprintf_function func_fprintf, void *f,
@@ -4013,7 +4013,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
}
fail:
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
}
void qmp_x_blockdev_del(bool has_id, const char *id,
@@ -217,21 +217,15 @@ Visitor *qmp_output_get_visitor(QmpOutputVisitor *v)
static void qmp_output_free(Visitor *v)
{
QmpOutputVisitor *qov = to_qov(v);
-
- qmp_output_visitor_cleanup(qov);
-}
-
-void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
-{
QStackEntry *e, *tmp;
- QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) {
- QTAILQ_REMOVE(&v->stack, e, node);
+ QTAILQ_FOREACH_SAFE(e, &qov->stack, node, tmp) {
+ QTAILQ_REMOVE(&qov->stack, e, node);
g_free(e);
}
- qobject_decref(v->root);
- g_free(v);
+ qobject_decref(qov->root);
+ g_free(qov);
}
QmpOutputVisitor *qmp_output_visitor_new(void)
@@ -493,7 +493,7 @@ static void dump_json_image_check(ImageCheck *check, bool quiet)
assert(str != NULL);
qprintf(quiet, "%s\n", qstring_get_str(str));
qobject_decref(obj);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
QDECREF(str);
}
@@ -2183,7 +2183,7 @@ static void dump_json_image_info_list(ImageInfoList *list)
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_decref(obj);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
QDECREF(str);
}
@@ -2199,7 +2199,7 @@ static void dump_json_image_info(ImageInfo *info)
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_decref(obj);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
QDECREF(str);
}
@@ -41,6 +41,6 @@ QObject *object_property_get_qobject(Object *obj, const char *name,
ret = qmp_output_get_qobject(qov);
}
error_propagate(errp, local_err);
- qmp_output_visitor_cleanup(qov);
+ visit_free(qmp_output_get_visitor(qov));
return ret;
}
@@ -31,7 +31,7 @@ static InputEvent *qapi_clone_InputEvent(InputEvent *src)
ov = qmp_output_get_visitor(qov);
visit_type_InputEvent(ov, NULL, &src, &error_abort);
obj = qmp_output_get_qobject(qov);
- qmp_output_visitor_cleanup(qov);
+ visit_free(ov);
if (!obj) {
return NULL;
}
@@ -58,7 +58,7 @@ static void qnull_visit_test(void)
obj = qmp_output_get_qobject(qov);
g_assert(obj == &qnull_);
qobject_decref(obj);
- qmp_output_visitor_cleanup(qov);
+ visit_free(qmp_output_get_visitor(qov));
g_assert(qnull_.refcnt == 1);
}
@@ -38,7 +38,7 @@ static void visitor_output_setup(TestOutputVisitorData *data,
static void visitor_output_teardown(TestOutputVisitorData *data,
const void *unused)
{
- qmp_output_visitor_cleanup(data->qov);
+ visit_free(data->ov);
data->qov = NULL;
data->ov = NULL;
}
@@ -1139,7 +1139,7 @@ void qapi_copy_SocketAddress(SocketAddress **p_dest,
ov = qmp_output_get_visitor(qov);
visit_type_SocketAddress(ov, NULL, &src, &error_abort);
obj = qmp_output_get_qobject(qov);
- qmp_output_visitor_cleanup(qov);
+ visit_free(ov);
if (!obj) {
return;
}
Now that we have a polymorphic visit_free(), we no longer need qmp_output_visitor_cleanup(); however, we still need to expose the subtype for qmp_output_get_qobject(). Signed-off-by: Eric Blake <eblake@redhat.com> --- v5: blank line after declaration v4: new patch --- include/qapi/qmp-output-visitor.h | 1 - block/qapi.c | 2 +- blockdev.c | 2 +- qapi/qmp-output-visitor.c | 14 ++++---------- qemu-img.c | 6 +++--- qom/qom-qobject.c | 2 +- replay/replay-input.c | 2 +- tests/check-qnull.c | 2 +- tests/test-qmp-output-visitor.c | 2 +- util/qemu-sockets.c | 2 +- 10 files changed, 14 insertions(+), 21 deletions(-)