From patchwork Wed Jul 6 09:14:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 9215865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C6D8A60752 for ; Wed, 6 Jul 2016 09:23:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B650028796 for ; Wed, 6 Jul 2016 09:23:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A93B6287BA; Wed, 6 Jul 2016 09:23:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1BC9328796 for ; Wed, 6 Jul 2016 09:23:57 +0000 (UTC) Received: from localhost ([::1]:60434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKj3k-0001ej-4l for patchwork-qemu-devel@patchwork.kernel.org; Wed, 06 Jul 2016 05:23:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKiuN-00074K-90 for qemu-devel@nongnu.org; Wed, 06 Jul 2016 05:14:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKiuK-0000Rr-Vi for qemu-devel@nongnu.org; Wed, 06 Jul 2016 05:14:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKiuK-0000RP-M6 for qemu-devel@nongnu.org; Wed, 06 Jul 2016 05:14:12 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C0F581117 for ; Wed, 6 Jul 2016 09:14:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u669E9Y6021420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 6 Jul 2016 05:14:11 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8A7C51129C47; Wed, 6 Jul 2016 11:14:06 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 6 Jul 2016 11:14:00 +0200 Message-Id: <1467796446-25446-10-git-send-email-armbru@redhat.com> In-Reply-To: <1467796446-25446-1-git-send-email-armbru@redhat.com> References: <1467796446-25446-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 06 Jul 2016 09:14:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/15] qmp-output-visitor: Favor new visit_free() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake 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 Message-Id: <1465490926-28625-10-git-send-email-eblake@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- block/qapi.c | 2 +- blockdev.c | 2 +- include/qapi/qmp-output-visitor.h | 1 - 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(-) diff --git a/block/qapi.c b/block/qapi.c index 5594f74..41fe4f9 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -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, diff --git a/blockdev.c b/blockdev.c index 3a104a0..c05aaa6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -4020,7 +4020,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, diff --git a/include/qapi/qmp-output-visitor.h b/include/qapi/qmp-output-visitor.h index 2266770..29c9a2e 100644 --- a/include/qapi/qmp-output-visitor.h +++ b/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/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 5f0035c..3d12623 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -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) diff --git a/qemu-img.c b/qemu-img.c index debd7f1..728f471 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -500,7 +500,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); } @@ -2190,7 +2190,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); } @@ -2206,7 +2206,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); } diff --git a/qom/qom-qobject.c b/qom/qom-qobject.c index c3c9188..6714565 100644 --- a/qom/qom-qobject.c +++ b/qom/qom-qobject.c @@ -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; } diff --git a/replay/replay-input.c b/replay/replay-input.c index 7b6fa93..9cbb4c1 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -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; } diff --git a/tests/check-qnull.c b/tests/check-qnull.c index d0412e4..6310bf7 100644 --- a/tests/check-qnull.c +++ b/tests/check-qnull.c @@ -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); } diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 75c8e1b..45d87fb 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -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; } diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 3677cd2..01fc154 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1157,7 +1157,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; }