From patchwork Mon Aug 6 06:53:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 953706 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41kT0f5hjgz9s7c for ; Mon, 6 Aug 2018 16:54:42 +1000 (AEST) Received: from localhost ([::1]:60948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmZPc-0001aN-7h for incoming@patchwork.ozlabs.org; Mon, 06 Aug 2018 02:54:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmZOp-0001XG-2n for qemu-devel@nongnu.org; Mon, 06 Aug 2018 02:53:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmZOm-00087v-HL for qemu-devel@nongnu.org; Mon, 06 Aug 2018 02:53:51 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58348 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fmZOm-00087F-7F for qemu-devel@nongnu.org; Mon, 06 Aug 2018 02:53:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB0F14021700; Mon, 6 Aug 2018 06:53:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DC142026D68; Mon, 6 Aug 2018 06:53:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A76A51138666; Mon, 6 Aug 2018 08:53:44 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 6 Aug 2018 08:53:30 +0200 Message-Id: <20180806065344.7103-10-armbru@redhat.com> In-Reply-To: <20180806065344.7103-1-armbru@redhat.com> References: <20180806065344.7103-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 06 Aug 2018 06:53:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 06 Aug 2018 06:53:47 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'armbru@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 09/23] test-qobject-input-visitor: Avoid format string ambiguity 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: thuth@redhat.com, f4bug@amsat.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When visitor_input_test_init_internal()'s argument @ap is null, then @json_string is interpreted literally, else it's gets %-escapes interpolated. This is awkward. One caller always passes null @ap, and the others never do. Lift the building of the QObject into the callers, where it can be done without such ambiguity. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-qobject-input-visitor.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index 0f4d234c3f..caa90b3d7e 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -47,15 +47,13 @@ static void visitor_input_teardown(TestInputVisitorData *data, /* The various test_init functions are provided instead of a test setup function so that the JSON string used by the tests are kept in the test functions (and not in main()). */ -static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data, - bool keyval, - const char *json_string, - va_list *ap) + +static Visitor *test_init_internal(TestInputVisitorData *data, bool keyval, + QObject *obj) { visitor_input_teardown(data, NULL); - data->obj = qobject_from_jsonv(json_string, ap, &error_abort); - g_assert(data->obj); + data->obj = obj; if (keyval) { data->qiv = qobject_input_visitor_new_keyval(data->obj); @@ -75,7 +73,8 @@ Visitor *visitor_input_test_init_full(TestInputVisitorData *data, va_list ap; va_start(ap, json_string); - v = visitor_input_test_init_internal(data, keyval, json_string, &ap); + v = test_init_internal(data, keyval, + qobject_from_vjsonf_nofail(json_string, ap)); va_end(ap); return v; } @@ -88,7 +87,8 @@ Visitor *visitor_input_test_init(TestInputVisitorData *data, va_list ap; va_start(ap, json_string); - v = visitor_input_test_init_internal(data, false, json_string, &ap); + v = test_init_internal(data, false, + qobject_from_vjsonf_nofail(json_string, ap)); va_end(ap); return v; } @@ -103,7 +103,8 @@ Visitor *visitor_input_test_init(TestInputVisitorData *data, static Visitor *visitor_input_test_init_raw(TestInputVisitorData *data, const char *json_string) { - return visitor_input_test_init_internal(data, false, json_string, NULL); + return test_init_internal(data, false, + qobject_from_json(json_string, &error_abort)); } static void test_visitor_in_int(TestInputVisitorData *data,