From patchwork Tue May 10 04:20:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9053891 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 E6F8F9F1C3 for ; Tue, 10 May 2016 04:20:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2742020142 for ; Tue, 10 May 2016 04:20:28 +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 0034D2012B for ; Tue, 10 May 2016 04:20:26 +0000 (UTC) Received: from localhost ([::1]:44433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azz9l-000624-GL for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 May 2016 00:20:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azz9e-0005zX-Mw for qemu-devel@nongnu.org; Tue, 10 May 2016 00:20:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azz9b-0006tP-Dj for qemu-devel@nongnu.org; Tue, 10 May 2016 00:20:18 -0400 Received: from resqmta-po-11v.sys.comcast.net ([2001:558:fe16:19:96:114:154:170]:60012 helo=resqmta-ch2-11v.sys.comcast.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azz9b-0006tC-6t for qemu-devel@nongnu.org; Tue, 10 May 2016 00:20:15 -0400 Received: from resomta-po-13v.sys.comcast.net ([96.114.154.237]) by comcast with SMTP id zz9UaXIrnvJlgzz9YaWO4Z; Tue, 10 May 2016 04:20:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1462854012; bh=BiEqwi9F7dVwrAv5kIx0utcHMbZ6RhlhNVbrvjXy8QE=; h=Received:Received:From:To:Subject:Date:Message-Id; b=Kfy2s1sjPUwlxf/eBb8s4ejDYElcdioYuoDjAAk9i0vnvh3YxWBdY0CC80ZiKS6T1 UEn4yq375AV7fJzA3HrRPZb/m7lt1/g2zNsL0XAHTePkf9/8GBpKTpfKCj1r23PHu0 rN7U/229mS0AOISUWF5ac2KNwSB8m/OQ+ti9WIMWjWeL9ZTHR8afJktTv4srNIwPk1 1M19mdnYf43VtIa3mFuq7Wo1fBmJE2UZVnhc9gu5+gg5HUUB19TjaLRtcXolhrsnLK 5HWGmjnobaSEQjse7Bs4ngmzbOcdcQkppHKen2zp2npOcSfOgawywcsfATWUo4qq7T aEg7gS2vyhWlQ== Received: from red.redhat.com ([24.10.254.122]) by resomta-po-13v.sys.comcast.net with comcast id sUL81s00F2fD5rL01ULB1m; Tue, 10 May 2016 04:20:12 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 9 May 2016 22:20:06 -0600 Message-Id: <1462854006-24658-1-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461879932-9020-18-git-send-email-eblake@redhat.com> References: <1461879932-9020-18-git-send-email-eblake@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:170 Subject: [Qemu-devel] [PATCH v16A 17/24] qmp: Don't reuse qmp visitor after grabbing output 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: armbru@redhat.com, Michael Roth Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 The testsuite was the only client that attempted to reuse a QmpOutputVisitor for a second visit after encountering an error and/or calling qmp_output_get_qobject() on a first visit. The next patch is about to tighten the semantics to be one-shot usage of the visitor, like all other visitors (which will enable further simplifications down the road). Signed-off-by: Eric Blake --- This commit is designed to completely replace commit 51750617 on Markus' qapi-next branch; all other patches in that series remain unchanged and the testsuite still passes. Doing this now will make it easier for my next series to introduce a generalized visit_free(Visitor*) instead of our current duplication of a per-subtype foo_visit_cleanup(FooVisitor*), without having to revert the addition of qmp_output_visitor_reset(). tests/test-qmp-output-visitor.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 8acc229..5543511 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -43,6 +43,12 @@ static void visitor_output_teardown(TestOutputVisitorData *data, data->ov = NULL; } +static void visitor_reset(TestOutputVisitorData *data) +{ + visitor_output_teardown(data, NULL); + visitor_output_setup(data, NULL); +} + static void test_visitor_out_int(TestOutputVisitorData *data, const void *unused) { @@ -139,6 +145,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data, g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, EnumOne_lookup[i]); qobject_decref(obj); + visitor_reset(data); } } @@ -153,6 +160,7 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data, visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err); g_assert(err); error_free(err); + visitor_reset(data); } } @@ -262,6 +270,7 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data, visit_type_UserDefOne(data->ov, "unused", &pu, &err); g_assert(err); error_free(err); + visitor_reset(data); } } @@ -366,6 +375,7 @@ static void test_visitor_out_any(TestOutputVisitorData *data, qobject_decref(obj); qobject_decref(qobj); + visitor_reset(data); qdict = qdict_new(); qdict_put(qdict, "integer", qint_from_int(-42)); qdict_put(qdict, "boolean", qbool_from_bool(true)); @@ -442,6 +452,7 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data, qapi_free_UserDefAlternate(tmp); qobject_decref(arg); + visitor_reset(data); tmp = g_new0(UserDefAlternate, 1); tmp->type = QTYPE_QSTRING; tmp->u.s = g_strdup("hello"); @@ -455,6 +466,7 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data, qapi_free_UserDefAlternate(tmp); qobject_decref(arg); + visitor_reset(data); tmp = g_new0(UserDefAlternate, 1); tmp->type = QTYPE_QDICT; tmp->u.udfu.integer = 1;