From patchwork Thu May 19 04:40:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9124041 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 905619F1D3 for ; Thu, 19 May 2016 04:55:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCBA0201FA for ; Thu, 19 May 2016 04:55:09 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id D261D201BB for ; Thu, 19 May 2016 04:55:08 +0000 (UTC) Received: from localhost ([::1]:48309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3FzH-0005eE-Tz for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 May 2016 00:55:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3FmD-0002Zv-OQ for qemu-devel@nongnu.org; Thu, 19 May 2016 00:41:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3Fm6-00055E-Kg for qemu-devel@nongnu.org; Thu, 19 May 2016 00:41:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3Fm6-000557-CJ for qemu-devel@nongnu.org; Thu, 19 May 2016 00:41:30 -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 E9358C0467C9; Thu, 19 May 2016 04:41:29 +0000 (UTC) Received: from red.redhat.com (ovpn-116-47.phx2.redhat.com [10.3.116.47]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4J4fFNL010616; Thu, 19 May 2016 00:41:29 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 18 May 2016 22:40:55 -0600 Message-Id: <1463632874-28559-10-git-send-email-eblake@redhat.com> In-Reply-To: <1463632874-28559-1-git-send-email-eblake@redhat.com> References: <1463632874-28559-1-git-send-email-eblake@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.31]); Thu, 19 May 2016 04:41:29 +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] [PATCH v4 09/28] string-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: , Cc: Michael Roth , Jason Wang , armbru@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Luiz Capitulino Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we have a polymorphic visit_free(), we no longer need string_output_visitor_cleanup(); however, we still need to expose the subtype for string_output_get_string(). Signed-off-by: Eric Blake --- v4: new patch --- include/qapi/string-output-visitor.h | 1 - hmp.c | 2 +- net/net.c | 2 +- qapi/string-output-visitor.c | 4 ---- qom/object.c | 11 ++++++----- tests/test-string-output-visitor.c | 2 +- tests/test-visitor-serialization.c | 4 ++-- 7 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/qapi/string-output-visitor.h b/include/qapi/string-output-visitor.h index e10522a..03e377e 100644 --- a/include/qapi/string-output-visitor.h +++ b/include/qapi/string-output-visitor.h @@ -23,7 +23,6 @@ typedef struct StringOutputVisitor StringOutputVisitor; * requires a non-null list argument to visit_start_list(). */ StringOutputVisitor *string_output_visitor_new(bool human); -void string_output_visitor_cleanup(StringOutputVisitor *v); char *string_output_get_string(StringOutputVisitor *v); Visitor *string_output_get_visitor(StringOutputVisitor *v); diff --git a/hmp.c b/hmp.c index eef208c..4a0a502 100644 --- a/hmp.c +++ b/hmp.c @@ -1954,7 +1954,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) monitor_printf(mon, " host nodes: %s\n", str); g_free(str); - string_output_visitor_cleanup(ov); + visit_free(string_output_get_visitor(ov)); m = m->next; i++; } diff --git a/net/net.c b/net/net.c index b411770..557800d 100644 --- a/net/net.c +++ b/net/net.c @@ -1212,7 +1212,7 @@ static void netfilter_print_info(Monitor *mon, NetFilterState *nf) object_property_get(OBJECT(nf), string_output_get_visitor(ov), prop->name, NULL); str = string_output_get_string(ov); - string_output_visitor_cleanup(ov); + visit_free(string_output_get_visitor(ov)); monitor_printf(mon, ",%s=%s", prop->name, str); g_free(str); } diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c index 8923898..91ee694 100644 --- a/qapi/string-output-visitor.c +++ b/qapi/string-output-visitor.c @@ -322,11 +322,7 @@ static void free_range(void *range, void *dummy) static void string_output_free(Visitor *v) { StringOutputVisitor *sov = to_sov(v); - string_output_visitor_cleanup(sov); -} -void string_output_visitor_cleanup(StringOutputVisitor *sov) -{ if (sov->string) { g_string_free(sov->string, true); } diff --git a/qom/object.c b/qom/object.c index 00dd68c..5c834eb 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1236,14 +1236,15 @@ int object_property_get_enum(Object *obj, const char *name, enumprop = prop->opaque; sov = string_output_visitor_new(false); - object_property_get(obj, string_output_get_visitor(sov), name, &err); + v = string_output_get_visitor(sov); + object_property_get(obj, v, name, &err); if (err) { error_propagate(errp, err); - string_output_visitor_cleanup(sov); + visit_free(v); return 0; } str = string_output_get_string(sov); - string_output_visitor_cleanup(sov); + visit_free(v); v = string_input_visitor_new(str); visit_type_enum(v, name, &ret, enumprop->strings, errp); @@ -1275,7 +1276,7 @@ void object_property_get_uint16List(Object *obj, const char *name, g_free(str); visit_free(v); out: - string_output_visitor_cleanup(ov); + visit_free(string_output_get_visitor(ov)); } void object_property_parse(Object *obj, const char *string, @@ -1303,7 +1304,7 @@ char *object_property_print(Object *obj, const char *name, bool human, string = string_output_get_string(sov); out: - string_output_visitor_cleanup(sov); + visit_free(string_output_get_visitor(sov)); return string; } diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c index 1ecd75b..2a62a2f 100644 --- a/tests/test-string-output-visitor.c +++ b/tests/test-string-output-visitor.c @@ -51,7 +51,7 @@ static void visitor_output_setup_human(TestOutputVisitorData *data, static void visitor_output_teardown(TestOutputVisitorData *data, const void *unused) { - string_output_visitor_cleanup(data->sov); + visit_free(data->ov); data->sov = NULL; data->ov = NULL; } diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index bc1afd3..63027e1 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -1048,7 +1048,7 @@ static void qmp_deserialize(void **native_out, void *datap, static void qmp_cleanup(void *datap) { QmpSerializeData *d = datap; - qmp_output_visitor_cleanup(d->qov); + visit_free(qmp_output_get_visitor(d->qov)); visit_free(d->qiv); g_free(d); @@ -1084,7 +1084,7 @@ static void string_cleanup(void *datap) { StringSerializeData *d = datap; - string_output_visitor_cleanup(d->sov); + visit_free(string_output_get_visitor(d->sov)); visit_free(d->siv); g_free(d->string); g_free(d);