From nobody Mon Feb 9 11:06:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666810229; cv=none; d=zohomail.com; s=zohoarc; b=g6NilbqC6manVycUrHgYyQWxZX1+VOfnKazoy1M/8rBy6qM8BFVB6PvVYalfFaRrUKJwnkkObiRowXHI9+qJmUkFLhwJE1GViJfBuyESZ9+t3bssi9DmMbcNxxUb6EFxktagCHJbIJYCQ0QnMC5nS+0Dik1Yxzx8HFPzg4de06o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666810229; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4GYhR+l96Nl9KtlAoqhEwKQlAjCxUpwuTcSjjsDZOGc=; b=TCZOKWZsl8oEMynTb3V6+rC3a3vxIiWPcHPQFgvzcKOSEJNoqmlkBbFf5FKjGvalxRSpHuxGFh5EFTW8+OehYIug2GJRl7FhMCrwI5QFvN1j6pHYOeiFYpkaZASX9n25dl5rgffC2JXdWeQUh4MhQmoAGbRqgBfww6ji1CsA5Hk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666810229492363.78106566602287; Wed, 26 Oct 2022 11:50:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onlGM-0007hx-9y; Wed, 26 Oct 2022 14:36:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlFs-00075f-Dm for qemu-devel@nongnu.org; Wed, 26 Oct 2022 14:35:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlFb-0003B0-3n for qemu-devel@nongnu.org; Wed, 26 Oct 2022 14:35:55 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-540-7ycxQW9bMCGI00R5vVxGdg-1; Wed, 26 Oct 2022 14:35:35 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4BFA1C05157 for ; Wed, 26 Oct 2022 18:35:34 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.195.118]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 80CF5414A815; Wed, 26 Oct 2022 18:35:34 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2C2D621E66C9; Wed, 26 Oct 2022 20:35:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666809336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4GYhR+l96Nl9KtlAoqhEwKQlAjCxUpwuTcSjjsDZOGc=; b=E26JNw/D0fz1PMabmVuucdX6dGG4+pXeDfD8KRubDg/NN8cp2ZfCPC3jdmixU/JDAw2Uzp qyLNrEASFlo2KIKymLr+92qCOFPaX5mhhUlAynFrwIQwwwZK0uDoi1006HFbJFeLdQdeE6 q2mpuRDSYP5SnyPe8btllx4rd1VLNF4= X-MC-Unique: 7ycxQW9bMCGI00R5vVxGdg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PULL v2 05/28] qapi tests: Elide redundant has_FOO in generated C Date: Wed, 26 Oct 2022 20:35:09 +0200 Message-Id: <20221026183532.487708-6-armbru@redhat.com> In-Reply-To: <20221026183532.487708-1-armbru@redhat.com> References: <20221026183532.487708-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666810230543100009 The has_FOO for pointer-valued FOO are redundant, except for arrays. They are also a nuisance to work with. Recent commit "qapi: Start to elide redundant has_FOO in generated C" provided the means to elide them step by step. This is the step for tests/qapi-schema/qapi-schema-test.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20221018062849.3420573-6-armbru@redhat.com> --- tests/qtest/qmp-cmd-test.c | 2 +- tests/unit/test-qmp-cmds.c | 26 +++++++++++------------- tests/unit/test-qmp-event.c | 4 ++-- tests/unit/test-qobject-input-visitor.c | 2 +- tests/unit/test-qobject-output-visitor.c | 2 -- tests/unit/test-visitor-serialization.c | 3 +-- scripts/qapi/schema.py | 4 +--- 7 files changed, 18 insertions(+), 25 deletions(-) diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 897e4e937b..98caf6fef6 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -174,7 +174,7 @@ static bool object_type_has_mandatory_members(SchemaInf= o *type) g_assert(type->meta_type =3D=3D SCHEMA_META_TYPE_OBJECT); =20 for (tail =3D type->u.object.members; tail; tail =3D tail->next) { - if (!tail->value->has_q_default) { + if (!tail->value->q_default) { return true; } } diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 6085c09995..2373cd64cb 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -43,15 +43,15 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp) { } =20 -FeatureStruct1 *qmp_test_features0(bool has_fs0, FeatureStruct0 *fs0, - bool has_fs1, FeatureStruct1 *fs1, - bool has_fs2, FeatureStruct2 *fs2, - bool has_fs3, FeatureStruct3 *fs3, - bool has_fs4, FeatureStruct4 *fs4, - bool has_cfs1, CondFeatureStruct1 *cfs1, - bool has_cfs2, CondFeatureStruct2 *cfs2, - bool has_cfs3, CondFeatureStruct3 *cfs3, - bool has_cfs4, CondFeatureStruct4 *cfs4, +FeatureStruct1 *qmp_test_features0(FeatureStruct0 *fs0, + FeatureStruct1 *fs1, + FeatureStruct2 *fs2, + FeatureStruct3 *fs3, + FeatureStruct4 *fs4, + CondFeatureStruct1 *cfs1, + CondFeatureStruct2 *cfs2, + CondFeatureStruct3 *cfs3, + CondFeatureStruct4 *cfs4, Error **errp) { return g_new0(FeatureStruct1, 1); @@ -77,8 +77,7 @@ void qmp_test_command_cond_features3(Error **errp) { } =20 -UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, - bool has_udb1, UserDefOne *ud1b, +UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, UserDefOne *ud1b, Error **errp) { UserDefTwo *ret; @@ -87,8 +86,8 @@ UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, =20 ud1c->string =3D strdup(ud1a->string); ud1c->integer =3D ud1a->integer; - ud1d->string =3D strdup(has_udb1 ? ud1b->string : "blah0"); - ud1d->integer =3D has_udb1 ? ud1b->integer : 0; + ud1d->string =3D strdup(ud1b ? ud1b->string : "blah0"); + ud1d->integer =3D ud1b ? ud1b->integer : 0; =20 ret =3D g_new0(UserDefTwo, 1); ret->string0 =3D strdup("blah1"); @@ -98,7 +97,6 @@ UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, ret->dict1->dict2->userdef =3D ud1c; ret->dict1->dict2->string =3D strdup("blah3"); ret->dict1->dict3 =3D g_new0(UserDefTwoDictDict, 1); - ret->dict1->has_dict3 =3D true; ret->dict1->dict3->userdef =3D ud1d; ret->dict1->dict3->string =3D strdup("blah4"); =20 diff --git a/tests/unit/test-qmp-event.c b/tests/unit/test-qmp-event.c index 7d961d716a..3626d2372f 100644 --- a/tests/unit/test-qmp-event.c +++ b/tests/unit/test-qmp-event.c @@ -109,7 +109,7 @@ static void test_event_c(TestEventData *data, data->expect =3D qdict_from_jsonf_nofail( "{ 'event': 'EVENT_C', 'data': {" " 'a': 1, 'b': { 'integer': 2, 'string': 'test1' }, 'c': 'test2' }= }"); - qapi_event_send_event_c(true, 1, true, &b, "test2"); + qapi_event_send_event_c(true, 1, &b, "test2"); g_assert(data->emitted); qobject_unref(data->expect); } @@ -135,7 +135,7 @@ static void test_event_d(TestEventData *data, " 'struct1': { 'integer': 2, 'string': 'test1', 'enum1': 'value1'= }," " 'string': 'test2', 'enum2': 'value2' }," " 'b': 'test3', 'enum3': 'value3' } }"); - qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE= 3); + qapi_event_send_event_d(&a, "test3", NULL, true, ENUM_ONE_VALUE3); g_assert(data->emitted); qobject_unref(data->expect); } diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobj= ect-input-visitor.c index 5f614afdbf..77fbf985be 100644 --- a/tests/unit/test-qobject-input-visitor.c +++ b/tests/unit/test-qobject-input-visitor.c @@ -431,7 +431,7 @@ static void test_visitor_in_struct_nested(TestInputVisi= torData *data, g_assert_cmpint(udp->dict1->dict2->userdef->integer, =3D=3D, 42); g_assert_cmpstr(udp->dict1->dict2->userdef->string, =3D=3D, "string"); g_assert_cmpstr(udp->dict1->dict2->string, =3D=3D, "string2"); - g_assert(udp->dict1->has_dict3 =3D=3D false); + g_assert(!udp->dict1->dict3); } =20 static void test_visitor_in_list(TestInputVisitorData *data, diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qob= ject-output-visitor.c index 66b27fad66..7f054289fe 100644 --- a/tests/unit/test-qobject-output-visitor.c +++ b/tests/unit/test-qobject-output-visitor.c @@ -182,7 +182,6 @@ static void test_visitor_out_struct_nested(TestOutputVi= sitorData *data, ud2->dict1->dict2->string =3D g_strdup(strings[2]); =20 ud2->dict1->dict3 =3D g_malloc0(sizeof(*ud2->dict1->dict3)); - ud2->dict1->has_dict3 =3D true; ud2->dict1->dict3->userdef =3D g_new0(UserDefOne, 1); ud2->dict1->dict3->userdef->string =3D g_strdup(string); ud2->dict1->dict3->userdef->integer =3D value; @@ -284,7 +283,6 @@ static void test_visitor_out_list_qapi_free(TestOutputV= isitorData *data, value->dict1->dict2->userdef->string =3D g_strdup(string); value->dict1->dict2->userdef->integer =3D 42; value->dict1->dict2->string =3D g_strdup(string); - value->dict1->has_dict3 =3D false; =20 QAPI_LIST_PREPEND(head, value); } diff --git a/tests/unit/test-visitor-serialization.c b/tests/unit/test-visi= tor-serialization.c index 667e8fed82..c2056c3eaa 100644 --- a/tests/unit/test-visitor-serialization.c +++ b/tests/unit/test-visitor-serialization.c @@ -223,7 +223,6 @@ static UserDefTwo *nested_struct_create(void) udnp->dict1->dict2->userdef->string =3D strdup("test_string"); udnp->dict1->dict2->string =3D strdup("test_string2"); udnp->dict1->dict3 =3D g_malloc0(sizeof(*udnp->dict1->dict3)); - udnp->dict1->has_dict3 =3D true; udnp->dict1->dict3->userdef =3D g_new0(UserDefOne, 1); udnp->dict1->dict3->userdef->integer =3D 43; udnp->dict1->dict3->userdef->string =3D strdup("test_string"); @@ -243,7 +242,7 @@ static void nested_struct_compare(UserDefTwo *udnp1, Us= erDefTwo *udnp2) udnp2->dict1->dict2->userdef->string); g_assert_cmpstr(udnp1->dict1->dict2->string, =3D=3D, udnp2->dict1->dict2->string); - g_assert(udnp1->dict1->has_dict3 =3D=3D udnp2->dict1->has_dict3); + g_assert(!udnp1->dict1->dict3 =3D=3D !udnp2->dict1->dict3); g_assert_cmpint(udnp1->dict1->dict3->userdef->integer, =3D=3D, udnp2->dict1->dict3->userdef->integer); g_assert_cmpstr(udnp1->dict1->dict3->userdef->string, =3D=3D, diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 58b00982ea..ae09c38103 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -767,7 +767,6 @@ def need_has(self): 'qapi/char.json', 'qapi/crypto.json', 'qapi/dump.json', - 'qapi/introspect.json', 'qapi/job.json', 'qapi/machine.json', 'qapi/machine-target.json', @@ -785,8 +784,7 @@ def need_has(self): 'qapi/transaction.json', 'qapi/ui.json', 'qapi/virtio.json', - 'qga/qapi-schema.json', - 'tests/qapi-schema/qapi-schema-test.json'] + 'qga/qapi-schema.json'] if self.info and any(self.info.fname.endswith(mod) for mod in opt_out): return self.optional --=20 2.37.3