From patchwork Thu May 12 07:59:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 9077421 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 AF4A79F1D3 for ; Thu, 12 May 2016 08:07:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13A1F201EC for ; Thu, 12 May 2016 08:07:05 +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 4EA3D20155 for ; Thu, 12 May 2016 08:07:04 +0000 (UTC) Received: from localhost ([::1]:55907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0leB-0005ek-AM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 May 2016 04:07:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0lWp-000120-Qv for qemu-devel@nongnu.org; Thu, 12 May 2016 03:59:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0lWi-0006PA-QS for qemu-devel@nongnu.org; Thu, 12 May 2016 03:59:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0lWi-0006OD-Fr for qemu-devel@nongnu.org; Thu, 12 May 2016 03:59:20 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 E148363307 for ; Thu, 12 May 2016 07:59:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4C7xGcZ028706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 12 May 2016 03:59:17 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9D7A211421EE; Thu, 12 May 2016 09:59:10 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 12 May 2016 09:59:04 +0200 Message-Id: <1463039950-4021-18-git-send-email-armbru@redhat.com> In-Reply-To: <1463039950-4021-1-git-send-email-armbru@redhat.com> References: <1463039950-4021-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 12 May 2016 07:59:19 +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 17/23] 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: , 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 From: Eric Blake 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 Message-Id: <1462854006-24658-1-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster --- 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;