From ec53301cda848b078d7539b3717a584052d3bb21 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sun, 25 Feb 2018 01:12:22 -0500 Subject: [PATCH] qmp-output-visitor: Favor new visit_free() function 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(). Backports commit 1830f22a6777cedaccd67a08f675d30f7a85ebfd from qemu --- qemu/include/qapi/qmp-output-visitor.h | 1 - qemu/qapi/qmp-output-visitor.c | 14 ++++---------- qemu/qom/qom-qobject.c | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/qemu/include/qapi/qmp-output-visitor.h b/qemu/include/qapi/qmp-output-visitor.h index 22667706..29c9a2e3 100644 --- a/qemu/include/qapi/qmp-output-visitor.h +++ b/qemu/include/qapi/qmp-output-visitor.h @@ -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); diff --git a/qemu/qapi/qmp-output-visitor.c b/qemu/qapi/qmp-output-visitor.c index 95915180..5272281e 100644 --- a/qemu/qapi/qmp-output-visitor.c +++ b/qemu/qapi/qmp-output-visitor.c @@ -218,21 +218,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) diff --git a/qemu/qom/qom-qobject.c b/qemu/qom/qom-qobject.c index 9dc2adb9..fff1e074 100644 --- a/qemu/qom/qom-qobject.c +++ b/qemu/qom/qom-qobject.c @@ -41,6 +41,6 @@ QObject *object_property_get_qobject(struct uc_struct *uc, Object *obj, const ch 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; }