From nobody Sun Feb 8 12:13:49 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=1666075859; cv=none; d=zohomail.com; s=zohoarc; b=AhOy2Pf6fit1OXrCbyQEEDcZ1HLLvWSeiVe8VCKT5HX3rjAhCBEpUcrvmwNAGWirw04GAL5qvuRMI+gjSM39tK1RWfCWFHboDLOObm2zJjy4/ENGCSmp2cahS5/64jhk5q5J81Ic8xX9joWGXUdfIP3WIgYw23s4i1cGkJHwUvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075859; 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=D+n6IBLpdeiLDJCxgtwJ/yp0DVhy47gMopQmVNq6ID0=; b=CFp/ZnaIopBQv78zVcpEVpbBAtZzaOMz9rNGntnyqDXfPB+gHcS+HS6qbpyG/M6BPUd5JDKBAQN/UOt+PfJOMCf7jkF+LPaRjZwUlVB/e3ZL0cO936olPgws+ZhXxMgQLO6HDQOVv4uYda1iIX9beDxQjNxdi4GShQlV3+PVICc= 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 1666075859754438.12135865757875; Mon, 17 Oct 2022 23:50:59 -0700 (PDT) Received: from localhost ([::1]:49230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgRG-0007bn-2A for importer@patchew.org; Tue, 18 Oct 2022 02:50:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6L-0005jq-1p for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg64-0001Ei-JY for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:12 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-81-FnOLvLGNPPG6glwIHTus4Q-1; Tue, 18 Oct 2022 02:28:50 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93922811E7A; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69D212166B41; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2AB8C21E6928; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=D+n6IBLpdeiLDJCxgtwJ/yp0DVhy47gMopQmVNq6ID0=; b=V+rnX5WKSv0Q4grBUX9aWCFVYvLcH9lOYzcDsGq8KeCaUWnZJREPUNnGsa4dEFSkujMuuY kwIhAeIKHej+/bWxoSWeTvatthKh9E9hE403gUoeHNncSxu9awo31LK9u3HjoiY7tDssMk +I7++Q74PcNsSUWnNHnJaLiSNjkcXfg= X-MC-Unique: FnOLvLGNPPG6glwIHTus4Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 01/28] docs/devel/qapi-code-gen: Update example to match current code Date: Tue, 18 Oct 2022 08:28:22 +0200 Message-Id: <20221018062849.3420573-2-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.6 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075861441100005 Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/devel/qapi-code-gen.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index cd9b544376..997313fce7 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -1748,7 +1748,7 @@ Example:: QTAILQ_INIT(cmds); =20 qmp_register_command(cmds, "my-command", - qmp_marshal_my_command, QCO_NO_OPTIONS); + qmp_marshal_my_command, 0, 0); } [Uninteresting stuff omitted...] =20 --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075956; cv=none; d=zohomail.com; s=zohoarc; b=YyT+bb3dndSgQ1mQT5/xO+SlrcRd71YGdQVXjf6yPf47vqMla6WdB3/1xi8n+iYQvw03a7KaOeSc9WN0yc1kOlPV//D47efaI4/mjTsAlKji04VOgryRcy98PXSZeoPt8QI4ck4izErnmLnOQy/Nt9V+lJMhnglkpEXGcdjAIzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075956; 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=hreIb12W1RQ0B22k4l4Ddb3+Wr0On8JtfkR1lQv+c5I=; b=VC3Cw5WfpXYwRt50SP5rXLlKDhGM/SsGqfv8hdygSwL7zK6FqDghr7VlHZu5xdzGxWEexjgr1J62v4FjZ6zV0zFe/e1Fcefb+iF4d8qpeC3z9mPVzE0f5jEgEGhuls3Qsj8Y0iSjCbEgP2g2CVWAczV0ve0jvz5PRglBEP839A4= 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 166607595673572.96958393377747; Mon, 17 Oct 2022 23:52:36 -0700 (PDT) Received: from localhost ([::1]:36182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgSo-0000pf-Q1 for importer@patchew.org; Tue, 18 Oct 2022 02:52:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6V-0005s1-Qs for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0001ET-Pp for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:31 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-81-T-JfMZHNM92VKtx8pwCVMw-1; Tue, 18 Oct 2022 02:28:50 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F2FB101A52A; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69A53492B0A; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2D35221E6931; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074532; 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=hreIb12W1RQ0B22k4l4Ddb3+Wr0On8JtfkR1lQv+c5I=; b=KgM92VXUFmTSOz3pguGoRcKd9QOqwUuEDaVXla5m2Hve3rP7sOXeQ+rVrnlUQk+rzB5rho ECq61A+FGWa58apM/H3uw1ei4kh5sxiM6PtDUFgsGv06cMwfuYk7UMYFg6633UBf/6YbZr BHux4RQNrJExCKOZXmj7xEVlane35sU= X-MC-Unique: T-JfMZHNM92VKtx8pwCVMw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 02/28] qapi: Tidy up whitespace in generated code Date: Tue, 18 Oct 2022 08:28:23 +0200 Message-Id: <20221018062849.3420573-3-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.10 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075958360100001 Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/devel/qapi-code-gen.rst | 1 - scripts/qapi/commands.py | 7 +++---- scripts/qapi/events.py | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index 997313fce7..b56ea4546d 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -1664,7 +1664,6 @@ Example:: $ cat qapi-generated/example-qapi-commands.c [Uninteresting stuff omitted...] =20 - static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp) { diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 38ca38a7b9..cf68aaf0bf 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -83,7 +83,7 @@ def gen_call(name: str, =20 trace_qmp_enter_%(name)s(req_json->str); } - ''', +''', upper=3Dupper, name=3Dname) =20 ret +=3D mcgen(''' @@ -124,13 +124,13 @@ def gen_call(name: str, =20 trace_qmp_exit_%(name)s(ret_json->str, true); } - ''', +''', upper=3Dupper, name=3Dname) else: ret +=3D mcgen(''' =20 trace_qmp_exit_%(name)s("{}", true); - ''', +''', name=3Dname) =20 return ret @@ -316,7 +316,6 @@ def _begin_user_module(self, name: str) -> None: #include "qapi/error.h" #include "%(visit)s.h" #include "%(commands)s.h" - ''', commands=3Dcommands, visit=3Dvisit)) =20 diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 27b44c49f5..e762d53d19 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -196,7 +196,6 @@ def _begin_user_module(self, name: str) -> None: #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp-event.h" - ''', events=3Devents, visit=3Dvisit, prefix=3Dself._prefix)) --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075801; cv=none; d=zohomail.com; s=zohoarc; b=IZWL5xxuQ7HVWOKbWiiSnUp01PSs6r9+Vk7kY/WzvN5duj+mVfLFl98uZlvd38w5ANsCWPjeV+3AolNPt8SFadtEcCX4GGWYDIeY6VsW5DVWGPjZekvDtes5n3QdHCaoJUv8OYQKad1z1dIyq1T1eY3hyTAzIvgGOj8zaU6mdW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075801; 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=JotlJQDgN1ENEQBGV0rbqvA5DSSxgdMtPnEa9sxJ+Bc=; b=HEBuQBapOYP6q0s81A8b8zcbWlzyN2rJomoVMV3pI1XG6bluxLUk+HAWJNjXf5nUdX3pfr0w+lCr/oMSv7SVXNj2gUnovaoFu/N8cJ6pSo4n88ZDXcJmVq+7HUvtvMlcuXcXZ54m1J2qGbcsbaUZ21Eju+i9SDxLNjxnBfY7QoI= 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 1666075801628194.9724236229481; Mon, 17 Oct 2022 23:50:01 -0700 (PDT) Received: from localhost ([::1]:58882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQJ-00077H-E5 for importer@patchew.org; Tue, 18 Oct 2022 02:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg65-0005g6-1a for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg5y-0001EP-9C for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:03 -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-414-B8ti2YMpMvuJNwSqmgutdg-1; Tue, 18 Oct 2022 02:28:50 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F3A33C0D187; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A334C19145; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2FC5E21E6939; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074532; 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=JotlJQDgN1ENEQBGV0rbqvA5DSSxgdMtPnEa9sxJ+Bc=; b=GDbov88kcAnFn20cYzwUCTqqxi4dQGqu8BVktxjYzZT47HiBc8kvqnM61FQ8Y5EuIJVOU+ AxYjXi7AuKkXlmg4dNIRyChm+elh5qEc0Vi9MkWqK/vnQUi4zIPwoqd7fUXUV5TgA/xPld djf6u29e++HkxnF4/Mks1xbOfmkRF3c= X-MC-Unique: B8ti2YMpMvuJNwSqmgutdg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 03/28] docs/devel/qapi-code-gen: Extend example for next commit's change Date: Tue, 18 Oct 2022 08:28:24 +0200 Message-Id: <20221018062849.3420573-4-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.8 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075803053100007 The next commit will change the code generated for some optional members. The example schema contains an optional member affected by the change. Add one that is not affected. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/devel/qapi-code-gen.rst | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index b56ea4546d..3a817ba498 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -1357,7 +1357,7 @@ qmp_my_command(); everything else is produced by the = generator. :: =20 $ cat example-schema.json { 'struct': 'UserDefOne', - 'data': { 'integer': 'int', '*string': 'str' } } + 'data': { 'integer': 'int', '*string': 'str', '*flag': 'bool' } } =20 { 'command': 'my-command', 'data': { 'arg1': ['UserDefOne'] }, @@ -1412,6 +1412,8 @@ Example:: int64_t integer; bool has_string; char *string; + bool has_flag; + bool flag; }; =20 void qapi_free_UserDefOne(UserDefOne *obj); @@ -1531,6 +1533,11 @@ Example:: return false; } } + if (visit_optional(v, "flag", &obj->has_flag)) { + if (!visit_type_bool(v, "flag", &obj->flag, errp)) { + return false; + } + } return true; } =20 @@ -1916,6 +1923,12 @@ Example:: { "type", QLIT_QSTR("str"), }, {} })), + QLIT_QDICT(((QLitDictEntry[]) { + { "default", QLIT_QNULL, }, + { "name", QLIT_QSTR("flag"), }, + { "type", QLIT_QSTR("bool"), }, + {} + })), {} })), }, { "meta-type", QLIT_QSTR("object"), }, @@ -1949,6 +1962,12 @@ Example:: { "name", QLIT_QSTR("str"), }, {} })), + QLIT_QDICT(((QLitDictEntry[]) { + { "json-type", QLIT_QSTR("boolean"), }, + { "meta-type", QLIT_QSTR("builtin"), }, + { "name", QLIT_QSTR("bool"), }, + {} + })), {} })); =20 --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077914; cv=none; d=zohomail.com; s=zohoarc; b=cDDH6puQcIWb63ED+z1MZTx5BJtoR9oNJT1tXkntuoSCNI78PbuZbyzux+utSGS4cPyF0SIGlO8yPEFivLGj5N/DlkEwWYcTpTdbc9HRBs6cQgYeKyBtEgHahDqtgHcHW+6KgONFngXODvncFWjgr3JL8NUiLl8x9pO/U5vnlfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077914; 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=zoLI2AcjGt8dxumNuqaN1htzKlHKjr7zRnlVSRKXqZA=; b=OFPiC1QATeGzZG9/XM2eqjW1RbydOaDumwPP0u6XMpXiUOrq1ZK2qjdezshAKVNJYdgy8Ae6XzQ1/fLNv5yWwZhZmEH9drA+AnWLjJwfNDhgsF87/rA0dSVvVgE0rIT1Okm/tJBnXQlsGjYNBoTqkMK4e08fGSCtmQ0fRTnXij4= 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 1666077914578913.7026881677309; Tue, 18 Oct 2022 00:25:14 -0700 (PDT) Received: from localhost ([::1]:46672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgyN-0001sU-OC for importer@patchew.org; Tue, 18 Oct 2022 03:25:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6O-0005p3-86 for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg68-0001Eb-An for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:23 -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-91-m25dl8R6MW61AOH4xXaZow-1; Tue, 18 Oct 2022 02:28:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ACAB729AB3E9; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69C19C15BA5; Tue, 18 Oct 2022 06:28:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 324CE21E693E; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=zoLI2AcjGt8dxumNuqaN1htzKlHKjr7zRnlVSRKXqZA=; b=RVqijucByBymwvX2foJKyRjep6dXL22ArtZXypXSRji1OJdj3XJ8aJisHN+vVqHDljrodM L31PxxIHn9otbOs4kPMMbplrkoQeUpcDRnkGRIGYxgcDgYhccrIAS6tnfgpqN+K/Vv4pLV OXiUASGvJcec8m3p76lZGcOohwqE930= X-MC-Unique: m25dl8R6MW61AOH4xXaZow-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 04/28] qapi: Start to elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:25 +0200 Message-Id: <20221018062849.3420573-5-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.8 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077915214100001 In QAPI, absent optional members are distinct from any present value. We thus represent an optional schema member FOO as two C members: a FOO with the member's type, and a bool has_FOO. Likewise for function arguments. However, has_FOO is actually redundant for a pointer-valued FOO, which can be null only when has_FOO is false, i.e. has_FOO =3D=3D !!FOO. Except for arrays, where we a null FOO can also be a present empty array. The redundant has_FOO are a nuisance to work with. Improve the generator to elide them. Uses of has_FOO need to be replaced as follows. Tests of has_FOO become the equivalent comparison of FOO with null. For brevity, this is commonly done by implicit conversion to bool. Assignments to has_FOO get dropped. Likewise for arguments to has_FOO parameters. Beware: code may violate the invariant has_FOO =3D=3D !!FOO before the transformation, and get away with it. The above transformation can then break things. Two cases: * Absent: if code ignores FOO entirely when !has_FOO (except for freeing it if necessary), even non-null / uninitialized FOO works. Such code is known to exist. * Present: if code ignores FOO entirely when has_FOO, even null FOO works. Such code should not exist. In both cases, replacing tests of has_FOO by FOO reverts their sense. We have to fix the value of FOO then. To facilitate review of the necessary updates to handwritten code, add means to opt out of this change, and opt out for all QAPI schema modules where the change requires updates to handwritten code. The next few commits will remove these opt-outs in reviewable chunks, then drop the means to opt out. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/devel/qapi-code-gen.rst | 5 +-- docs/devel/writing-monitor-commands.rst | 14 ++++---- scripts/qapi/commands.py | 2 +- scripts/qapi/events.py | 2 +- scripts/qapi/gen.py | 2 +- scripts/qapi/schema.py | 48 +++++++++++++++++++++++++ scripts/qapi/types.py | 2 +- scripts/qapi/visit.py | 17 +++++++-- 8 files changed, 77 insertions(+), 15 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index 3a817ba498..5edc49aa74 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -1410,7 +1410,6 @@ Example:: =20 struct UserDefOne { int64_t integer; - bool has_string; char *string; bool has_flag; bool flag; @@ -1525,10 +1524,12 @@ Example:: =20 bool visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error = **errp) { + bool has_string =3D !!obj->string; + if (!visit_type_int(v, "integer", &obj->integer, errp)) { return false; } - if (visit_optional(v, "string", &obj->has_string)) { + if (visit_optional(v, "string", &has_string)) { if (!visit_type_str(v, "string", &obj->string, errp)) { return false; } diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-m= onitor-commands.rst index 2fefedcd98..2c11e71665 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -166,9 +166,9 @@ and user defined types. =20 Now, let's update our C implementation in monitor/qmp-cmds.c:: =20 - void qmp_hello_world(bool has_message, const char *message, Error **errp) + void qmp_hello_world(const char *message, Error **errp) { - if (has_message) { + if (message) { printf("%s\n", message); } else { printf("Hello, world\n"); @@ -210,9 +210,9 @@ file. Basically, most errors are set by calling the err= or_setg() function. Let's say we don't accept the string "message" to contain the word "love".= If it does contain it, we want the "hello-world" command to return an error:: =20 - void qmp_hello_world(bool has_message, const char *message, Error **errp) + void qmp_hello_world(const char *message, Error **errp) { - if (has_message) { + if (message) { if (strstr(message, "love")) { error_setg(errp, "the word 'love' is not allowed"); return; @@ -467,9 +467,9 @@ There are a number of things to be noticed: allocated by the regular g_malloc0() function. Note that we chose to initialize the memory to zero. This is recommended for all QAPI types, = as it helps avoiding bad surprises (specially with booleans) -4. Remember that "next_deadline" is optional? All optional members have a - 'has_TYPE_NAME' member that should be properly set by the implementatio= n, - as shown above +4. Remember that "next_deadline" is optional? Non-pointer optional + members have a 'has_TYPE_NAME' member that should be properly set + by the implementation, as shown above 5. Even static strings, such as "alarm_timer->name", should be dynamically allocated by the implementation. This is so because the QAPI also gener= ates a function to free its types and it cannot distinguish between dynamica= lly diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index cf68aaf0bf..79c5e5c3a9 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -64,7 +64,7 @@ def gen_call(name: str, elif arg_type: assert not arg_type.variants for memb in arg_type.members: - if memb.optional: + if memb.need_has(): argstr +=3D 'arg.has_%s, ' % c_name(memb.name) argstr +=3D 'arg.%s, ' % c_name(memb.name) =20 diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index e762d53d19..3cf01e96b6 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -60,7 +60,7 @@ def gen_param_var(typ: QAPISchemaObjectType) -> str: for memb in typ.members: ret +=3D sep sep =3D ', ' - if memb.optional: + if memb.need_has(): ret +=3D 'has_' + c_name(memb.name) + sep if memb.type.name =3D=3D 'str': # Cast away const added in build_params() diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 113b49134d..b5a8d03e8e 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -121,7 +121,7 @@ def build_params(arg_type: Optional[QAPISchemaObjectTyp= e], for memb in arg_type.members: ret +=3D sep sep =3D ', ' - if memb.optional: + if memb.need_has(): ret +=3D 'bool has_%s, ' % c_name(memb.name) ret +=3D '%s %s' % (memb.type.c_param_type(), c_name(memb.name)) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3728340c37..58b00982ea 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -253,6 +253,11 @@ def doc_type(self): return None return self.name =20 + def need_has_if_optional(self): + # When FOO is a pointer, has_FOO =3D=3D !!FOO, i.e. has_FOO is red= undant. + # Except for arrays; see QAPISchemaArrayType.need_has_if_optional(= ). + return not self.c_type().endswith(POINTER_SUFFIX) + def check(self, schema): QAPISchemaEntity.check(self, schema) for feat in self.features: @@ -352,6 +357,11 @@ def __init__(self, name, info, element_type): self._element_type_name =3D element_type self.element_type =3D None =20 + def need_has_if_optional(self): + # When FOO is an array, we still need has_FOO to distinguish + # absent (!has_FOO) from present and empty (has_FOO && !FOO). + return True + def check(self, schema): super().check(schema) self.element_type =3D schema.resolve_type( @@ -745,6 +755,44 @@ def __init__(self, name, info, typ, optional, ifcond= =3DNone, features=3DNone): self.optional =3D optional self.features =3D features or [] =20 + def need_has(self): + assert self.type + # Temporary hack to support dropping the has_FOO in reviewable chu= nks + opt_out =3D [ + 'qapi/acpi.json', + 'qapi/audio.json', + 'qapi/block-core.json', + 'qapi/block-export.json', + 'qapi/block.json', + 'qapi/char.json', + 'qapi/crypto.json', + 'qapi/dump.json', + 'qapi/introspect.json', + 'qapi/job.json', + 'qapi/machine.json', + 'qapi/machine-target.json', + 'qapi/migration.json', + 'qapi/misc.json', + 'qapi/net.json', + 'qapi/pci.json', + 'qapi/qdev.json', + 'qapi/qom.json', + 'qapi/replay.json', + 'qapi/rocker.json', + 'qapi/run-state.json', + 'qapi/stats.json', + 'qapi/tpm.json', + 'qapi/transaction.json', + 'qapi/ui.json', + 'qapi/virtio.json', + 'qga/qapi-schema.json', + 'tests/qapi-schema/qapi-schema-test.json'] + if self.info and any(self.info.fname.endswith(mod) + for mod in opt_out): + return self.optional + # End of temporary hack + return self.optional and self.type.need_has_if_optional() + def check(self, schema): assert self.defined_in self.type =3D schema.resolve_type(self._type_name, self.info, diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 477d027001..c39d054d2c 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -142,7 +142,7 @@ def gen_struct_members(members: List[QAPISchemaObjectTy= peMember]) -> str: ret =3D '' for memb in members: ret +=3D memb.ifcond.gen_if() - if memb.optional: + if memb.need_has(): ret +=3D mcgen(''' bool has_%(c_name)s; ''', diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 380fa197f5..26a584ee4c 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -71,6 +71,16 @@ def gen_visit_object_members(name: str, ''', c_name=3Dc_name(name)) =20 + sep =3D '' + for memb in members: + if memb.optional and not memb.need_has(): + ret +=3D mcgen(''' + bool has_%(c_name)s =3D !!obj->%(c_name)s; +''', + c_name=3Dc_name(memb.name)) + sep =3D '\n' + ret +=3D sep + if base: ret +=3D mcgen(''' if (!visit_type_%(c_type)s_members(v, (%(c_type)s *)obj, errp)) { @@ -82,10 +92,13 @@ def gen_visit_object_members(name: str, for memb in members: ret +=3D memb.ifcond.gen_if() if memb.optional: + has =3D 'has_' + c_name(memb.name) + if memb.need_has(): + has =3D 'obj->' + has ret +=3D mcgen(''' - if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) { + if (visit_optional(v, "%(name)s", &%(has)s)) { ''', - name=3Dmemb.name, c_name=3Dc_name(memb.name)) + name=3Dmemb.name, has=3Dhas) indent.increase() special_features =3D gen_special_features(memb.features) if special_features !=3D '0': --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077800; cv=none; d=zohomail.com; s=zohoarc; b=QlfRxMDrWVtnvk+z60Zw6yWWBaCuT9vqc6rHigYmJQCp5ZL4vgNlubUAcgsaAUFCbZXO/HGAoLLXIausgPZ7sTHJHQ7g7jIOXmwsIU79poFi19H9IqdhEiE6kQZJFJz7SbrzKRNFcIO51vIaWA7W9uZHxVeUuUtOkx8xZGP/wiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077800; 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=83H5PbBpPO6dJo2CBCxZpDKCoJmW/xziS1eO6xHEZWQ=; b=mDLsFsrQ5lmFLHudlMmB1uxKViLuIhQQWf92KaVB+bRXOnr8iHoeDZ6n0JAsl4/spFMGGHJYjN3pF16iisUXsaLk9ZSXcY7PO9INJWXflqlZLeLL1kgMrMK4wwTIEIG/nfnuQoO0TLtkjfdG06WyNKFWnZc+z2cM4ffAIzwpo2A= 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 16660778007478.327254284068317; Tue, 18 Oct 2022 00:23:20 -0700 (PDT) Received: from localhost ([::1]:41170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgwY-0000yt-D4 for importer@patchew.org; Tue, 18 Oct 2022 03:23:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6D-0005ga-2i for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg64-0001FO-JA for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:07 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-_oh3snNlMOGW3LYVuXdTNA-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C09AE858F17; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8143C492B0A; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 34B4821E6808; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074535; 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=83H5PbBpPO6dJo2CBCxZpDKCoJmW/xziS1eO6xHEZWQ=; b=dyh3N4j/nOKmGMdpo5/9gyJX2kvc/qb3y8hz7Ra7zOhjF4jxxjpk/lksYzThy9B7uVKz3t 06ZJUKYMtZHlYTko2D7SnI8id8pzNPwqo1oeg5KdbNx9pYaD8dLJTxwrF1GHxCUvW8uzi/ MlhUZddceEKYAgK1N/6MSAzdJrqsfHg= X-MC-Unique: _oh3snNlMOGW3LYVuXdTNA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 05/28] qapi tests: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:26 +0200 Message-Id: <20221018062849.3420573-6-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.10 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077802140100001 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 --- 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.2 From nobody Sun Feb 8 12:13:49 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=1666077623; cv=none; d=zohomail.com; s=zohoarc; b=VHapvDLo08OHdn6BOA9fNmj5Q7FPNJ+Wow0PlaNbYeuj0Ui6Hos+lYLGNtH6EXR+ph4Fs7rRatsvfCtzdgv5FJrtABXrAjnzigb9TKluvwAKId06dXlrPSV8s5w6FqxtlLeZ85SObCVBEASUr/ATy7QOql4NmtLnZoIPmu+AROc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077623; 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=J+82hJTCLfws/zGbH69DKhzOwlJu+Xk+1XNDmfUBw7A=; b=hQ1PXH2BR/h6MsyHxvCFuBZfX63rgyAv9vwqzhuH4XvAYyqgK9JIB+vaDu2a7jaPWDFzBr/iVQ/pag55wmDmCRHj3ei4RVt/N2QmFHjYEfe1WfQSaBY2JLh03eiyWtZ3G9Z+5WzHhcZjL4/QPpryvmDAsNVzsiKrBfS6xC9jRcM= 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 1666077623300526.5410280272641; Tue, 18 Oct 2022 00:20:23 -0700 (PDT) Received: from localhost ([::1]:59570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgtf-0005eR-Ca for importer@patchew.org; Tue, 18 Oct 2022 03:20:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6L-0005k1-Gd for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38225) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0001Ff-Sh for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:20 -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-650-Tr4fXflkM_erW6IXjy1LrA-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E359D3C0D18B; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81D754030C9; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 371E821E66FE; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074535; 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=J+82hJTCLfws/zGbH69DKhzOwlJu+Xk+1XNDmfUBw7A=; b=h1SfCHQTyqlnP3QwB5YJDXyy8HtOs82IQ3DVCTcsQv2EiD3SgapESsqlXpxbbpdchn+KAm 4qz4rPctWHCR/rAcD/+ru+t0WUOnav5tE4zYn1Pd7w490Kf3jjoVdE31USXMyrt+uqcnx9 AcCd2th0xa+dgxAaMuLU0KVNX/89ww8= X-MC-Unique: Tr4fXflkM_erW6IXjy1LrA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 06/28] qapi acpi: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:27 +0200 Message-Id: <20221018062849.3420573-7-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.9 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077624084100001 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 qapi/acpi.py. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Michael S. Tsirkin Cc: Igor Mammedov Cc: Ani Sinha Signed-off-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/acpi/core.c | 14 +++++++------- hw/acpi/cpu.c | 1 - hw/acpi/memory_hotplug.c | 1 - scripts/qapi/schema.py | 1 - 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 3e811bf03c..6da275c599 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -185,7 +185,7 @@ static void acpi_table_install(const char unsigned *blo= b, size_t bloblen, changed_fields =3D 0; ext_hdr->_length =3D cpu_to_le16(acpi_payload_size); =20 - if (hdrs->has_sig) { + if (hdrs->sig) { strncpy(ext_hdr->sig, hdrs->sig, sizeof ext_hdr->sig); ++changed_fields; } @@ -204,11 +204,11 @@ static void acpi_table_install(const char unsigned *b= lob, size_t bloblen, =20 ext_hdr->checksum =3D 0; =20 - if (hdrs->has_oem_id) { + if (hdrs->oem_id) { strncpy(ext_hdr->oem_id, hdrs->oem_id, sizeof ext_hdr->oem_id); ++changed_fields; } - if (hdrs->has_oem_table_id) { + if (hdrs->oem_table_id) { strncpy(ext_hdr->oem_table_id, hdrs->oem_table_id, sizeof ext_hdr->oem_table_id); ++changed_fields; @@ -217,7 +217,7 @@ static void acpi_table_install(const char unsigned *blo= b, size_t bloblen, ext_hdr->oem_revision =3D cpu_to_le32(hdrs->oem_rev); ++changed_fields; } - if (hdrs->has_asl_compiler_id) { + if (hdrs->asl_compiler_id) { strncpy(ext_hdr->asl_compiler_id, hdrs->asl_compiler_id, sizeof ext_hdr->asl_compiler_id); ++changed_fields; @@ -255,12 +255,12 @@ void acpi_table_add(const QemuOpts *opts, Error **err= p) if (!hdrs) { goto out; } - if (hdrs->has_file =3D=3D hdrs->has_data) { + if (!hdrs->file =3D=3D !hdrs->data) { error_setg(errp, "'-acpitable' requires one of 'data' or 'file'"); goto out; } =20 - pathnames =3D g_strsplit(hdrs->has_file ? hdrs->file : hdrs->data, ":"= , 0); + pathnames =3D g_strsplit(hdrs->file ?: hdrs->data, ":", 0); if (pathnames =3D=3D NULL || pathnames[0] =3D=3D NULL) { error_setg(errp, "'-acpitable' requires at least one pathname"); goto out; @@ -297,7 +297,7 @@ void acpi_table_add(const QemuOpts *opts, Error **errp) close(fd); } =20 - acpi_table_install(blob, bloblen, hdrs->has_file, hdrs, errp); + acpi_table_install(blob, bloblen, !!hdrs->file, hdrs, errp); =20 out: g_free(blob); diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 3646dbfe68..4e580959a2 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -35,7 +35,6 @@ static ACPIOSTInfo *acpi_cpu_device_status(int idx, AcpiC= puStatus *cdev) DeviceState *dev =3D DEVICE(cdev->cpu); if (dev->id) { info->device =3D g_strdup(dev->id); - info->has_device =3D true; } } return info; diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 0a7e89a13e..a7476330a8 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -44,7 +44,6 @@ static ACPIOSTInfo *acpi_memory_device_status(int slot, M= emStatus *mdev) DeviceState *dev =3D DEVICE(mdev->dimm); if (dev->id) { info->device =3D g_strdup(dev->id); - info->has_device =3D true; } } return info; diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index ae09c38103..ad7634de58 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/acpi.json', 'qapi/audio.json', 'qapi/block-core.json', 'qapi/block-export.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075859; cv=none; d=zohomail.com; s=zohoarc; b=TqvPnUCpU/tSh6gHj45mUcv0ALGqgTXfMKz6TJRqApOYbSkfE1Yy5BNOl/AITJNNUjcBPQz1R4gXR1SqETtMod1q716guxnGisb6GcpDFkNHWqBwUKErapjsLn21DuT4/hbzZFOizycI5RFVq8HY44hvwOgz8fRm5kSaFCZzxjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075859; 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=dnXPTYUm1WdWKlE9RWub2esdxtykbmTn01u8Ryf1mNQ=; b=gGn9qWehiNXGKxpQX6jLmACugcdaoeJQWmSk/lJKMoQkAVTjKhQ4vPvd+SqUf/HERGCG7e119J2dPk4KGTf/QAvvUZx9A7UoinDCV/6WSePmTc1janNUUVT9ZxDvxlmljeTvDP1gtTLcBwOIIUx4A7sYdkxnZbuI977c6b3uqkQ= 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 1666075859158872.0914274071768; Mon, 17 Oct 2022 23:50:59 -0700 (PDT) Received: from localhost ([::1]:37896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgRF-0008Dq-GO for importer@patchew.org; Tue, 18 Oct 2022 02:50:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6T-0005qr-G6 for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6C-0001FJ-KI for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:29 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-N4GBHzQbMIWTiPK_bslG4w-1; Tue, 18 Oct 2022 02:28:52 -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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id D23D5858282; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 837122027061; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 397C221E675C; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074535; 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=dnXPTYUm1WdWKlE9RWub2esdxtykbmTn01u8Ryf1mNQ=; b=PX+JkyFw6Y858H/h3MsvQ8/Sxk6LMOsUqQkIFZv0pnfY3V0gZTmx/8F/MZF89iD7J8f7/T n6jtBWeJVv9AcGAl7sW3y0wXoWv8k1wDIwtZmeOcHI2nfgF4TUIH3G385AHR2fs6Uo9Vrg SpSMLjMnCjNDZvtzmcfLp7XM9zJ3lzE= X-MC-Unique: N4GBHzQbMIWTiPK_bslG4w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Gerd Hoffmann , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 07/28] qapi audio: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:28 +0200 Message-Id: <20221018062849.3420573-8-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.4 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075859436100003 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 qapi/audio.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Additionally, helper get_str() loses its @has_dst parameter. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- audio/alsaaudio.c | 2 +- audio/audio.c | 6 ++---- audio/audio_legacy.c | 17 +++++++---------- audio/ossaudio.c | 8 +++----- audio/paaudio.c | 12 ++++++------ audio/wavaudio.c | 2 +- scripts/qapi/schema.py | 1 - 7 files changed, 20 insertions(+), 28 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 7a2a94cd42..714bfb6453 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -449,7 +449,7 @@ static int alsa_open(bool in, struct alsa_params_req *r= eq, snd_pcm_hw_params_t *hw_params; int err; unsigned int freq, nchannels; - const char *pcm_name =3D apdo->has_dev ? apdo->dev : "default"; + const char *pcm_name =3D apdo->dev ?: "default"; snd_pcm_uframes_t obt_buffer_size; const char *typ =3D in ? "ADC" : "DAC"; snd_pcm_format_t obtfmt; diff --git a/audio/audio.c b/audio/audio.c index cc664271eb..52326c74af 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2031,15 +2031,13 @@ void audio_create_pdos(Audiodev *dev) switch (dev->driver) { #define CASE(DRIVER, driver, pdo_name) \ case AUDIODEV_DRIVER_##DRIVER: \ - if (!dev->u.driver.has_in) { \ + if (!dev->u.driver.in) { \ dev->u.driver.in =3D g_malloc0( \ sizeof(Audiodev##pdo_name##PerDirectionOptions)); \ - dev->u.driver.has_in =3D true; \ } \ - if (!dev->u.driver.has_out) { \ + if (!dev->u.driver.out) { \ dev->u.driver.out =3D g_malloc0( \ sizeof(Audiodev##pdo_name##PerDirectionOptions)); \ - dev->u.driver.has_out =3D true; \ } \ break =20 diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 595949f52c..18a89ffffb 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -62,15 +62,12 @@ static void get_int(const char *env, uint32_t *dst, boo= l *has_dst) } } =20 -static void get_str(const char *env, char **dst, bool *has_dst) +static void get_str(const char *env, char **dst) { const char *val =3D getenv(env); if (val) { - if (*has_dst) { - g_free(*dst); - } + g_free(*dst); *dst =3D g_strdup(val); - *has_dst =3D true; } } =20 @@ -169,7 +166,7 @@ static void handle_alsa_per_direction( get_bool(buf, &apdo->try_poll, &apdo->has_try_poll); =20 strcpy(buf + len, "DEV"); - get_str(buf, &apdo->dev, &apdo->has_dev); + get_str(buf, &apdo->dev); =20 strcpy(buf + len, "SIZE_IN_USEC"); get_bool(buf, &size_in_usecs, &dummy); @@ -235,7 +232,7 @@ static void handle_oss_per_direction( const char *dev_env) { get_bool(try_poll_env, &opdo->try_poll, &opdo->has_try_poll); - get_str(dev_env, &opdo->dev, &opdo->has_dev); + get_str(dev_env, &opdo->dev); =20 get_bytes_to_usecs("QEMU_OSS_FRAGSIZE", &opdo->buffer_length, &opdo->has_buffer_length, @@ -261,7 +258,7 @@ static void handle_oss(Audiodev *dev) static void handle_pa_per_direction( AudiodevPaPerDirectionOptions *ppdo, const char *env) { - get_str(env, &ppdo->name, &ppdo->has_name); + get_str(env, &ppdo->name); } =20 static void handle_pa(Audiodev *dev) @@ -278,7 +275,7 @@ static void handle_pa(Audiodev *dev) &dev->u.pa.out->has_buffer_length, qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.out)); =20 - get_str("QEMU_PA_SERVER", &dev->u.pa.server, &dev->u.pa.has_server); + get_str("QEMU_PA_SERVER", &dev->u.pa.server); } =20 /* SDL */ @@ -299,7 +296,7 @@ static void handle_wav(Audiodev *dev) &dev->u.wav.out->has_format); get_int("QEMU_WAV_DAC_FIXED_CHANNELS", &dev->u.wav.out->channels, &dev->u.wav.out->has_channels); - get_str("QEMU_WAV_PATH", &dev->u.wav.path, &dev->u.wav.has_path); + get_str("QEMU_WAV_PATH", &dev->u.wav.path); } =20 /* general */ diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 8e075edb70..e8d732b612 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -252,7 +252,7 @@ static int oss_open(int in, struct oss_params *req, aud= settings *as, audio_buf_info abinfo; int fmt, freq, nchannels; int setfragment =3D 1; - const char *dspname =3D opdo->has_dev ? opdo->dev : "/dev/dsp"; + const char *dspname =3D opdo->dev ?: "/dev/dsp"; const char *typ =3D in ? "ADC" : "DAC"; #ifdef USE_DSP_POLICY int policy =3D oopts->has_dsp_policy ? oopts->dsp_policy : 5; @@ -745,10 +745,8 @@ static void *oss_audio_init(Audiodev *dev) oss_init_per_direction(oopts->in); oss_init_per_direction(oopts->out); =20 - if (access(oopts->in->has_dev ? oopts->in->dev : "/dev/dsp", - R_OK | W_OK) < 0 || - access(oopts->out->has_dev ? oopts->out->dev : "/dev/dsp", - R_OK | W_OK) < 0) { + if (access(oopts->in->dev ?: "/dev/dsp", R_OK | W_OK) < 0 || + access(oopts->out->dev ?: "/dev/dsp", R_OK | W_OK) < 0) { return NULL; } return dev; diff --git a/audio/paaudio.c b/audio/paaudio.c index e91116f239..529b39daac 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -536,9 +536,9 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, =20 pa->stream =3D qpa_simple_new ( c, - ppdo->has_stream_name ? ppdo->stream_name : g->dev->id, + ppdo->stream_name ?: g->dev->id, PA_STREAM_PLAYBACK, - ppdo->has_name ? ppdo->name : NULL, + ppdo->name, &ss, &ba, /* buffering attributes */ &error @@ -585,9 +585,9 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) =20 pa->stream =3D qpa_simple_new ( c, - ppdo->has_stream_name ? ppdo->stream_name : g->dev->id, + ppdo->stream_name ?: g->dev->id, PA_STREAM_RECORD, - ppdo->has_name ? ppdo->name : NULL, + ppdo->name, &ss, &ba, /* buffering attributes */ &error @@ -827,7 +827,7 @@ static void *qpa_audio_init(Audiodev *dev) =20 assert(dev->driver =3D=3D AUDIODEV_DRIVER_PA); =20 - if (!popts->has_server) { + if (!popts->server) { char pidfile[64]; char *runtime; struct stat st; @@ -850,7 +850,7 @@ static void *qpa_audio_init(Audiodev *dev) } =20 g =3D g_new0(paaudio, 1); - server =3D popts->has_server ? popts->server : NULL; + server =3D popts->server; =20 g->dev =3D dev; =20 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 3e1d84db83..6445a2cb90 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -78,7 +78,7 @@ static int wav_init_out(HWVoiceOut *hw, struct audsetting= s *as, Audiodev *dev =3D drv_opaque; AudiodevWavOptions *wopts =3D &dev->u.wav; struct audsettings wav_as =3D audiodev_to_audsettings(dev->u.wav.out); - const char *wav_path =3D wopts->has_path ? wopts->path : "qemu.wav"; + const char *wav_path =3D wopts->path ?: "qemu.wav"; =20 stereo =3D wav_as.nchannels =3D=3D 2; switch (wav_as.fmt) { diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index ad7634de58..8db1c2caef 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/audio.json', 'qapi/block-core.json', 'qapi/block-export.json', 'qapi/block.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077920; cv=none; d=zohomail.com; s=zohoarc; b=ZXwitqinOENzEXKGsqADB1DgLPOVsPE3ub+eCnaNXwH7LTsmPDzVzNEuKH/BPa8qny3S2u+Bn4L0x46ee674EVmWuJ0OTolBkmaQVtcXExEdW/Pe+Tc0Emv8deyOyIGpowcQlQ/ZmiEjJoAsuMcnf+74YFG/M4KvO4nfa0ra7BE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077920; 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=545NtGfar2C297UFNLSeyfOT/TwBAWg/X/q3zMGhUXA=; b=QXD/ogdeGtsn8MNxYC9GPWiajaNqiJKehDqbhbvIZSb9DymoJsw+DAspKcQiYjFBzvrJ60yYqCJN0uTNIeGl7vRFIdKfPINi2O6Y2zs8MRORxWBrkeW65ND9kmpdKVm4RL3jUECAoQUd2IX6U6zQMVGYdx4ML8EYDYtvzEXu160= 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 1666077919995889.8677200133707; Tue, 18 Oct 2022 00:25:19 -0700 (PDT) Received: from localhost ([::1]:46700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgyT-0002Cj-M5 for importer@patchew.org; Tue, 18 Oct 2022 03:25:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6L-0005jw-EW for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22464) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0001FY-Ey for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:20 -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-49-gLXF-6EGPcGg-XjT-GE8sw-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19F5B3C0D18D; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 846A41731B; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3C75C21E6680; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074535; 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=545NtGfar2C297UFNLSeyfOT/TwBAWg/X/q3zMGhUXA=; b=dFyVF6pFcPfY6hQsI6WyZPdmL0BBtxOfP3lmE6Vj0ohaABdLRvDXUpi1vu2mRMzDDGOZmP ++aidOYDT7JSCJXvlhdiyWuQ5uIQpBz7op0qGmmPvCpmC+WdVe3rgPPNOs3ueQqvkjnoLn LXYoFEROijXkdBRe1zIXv9o5I47wd4o= X-MC-Unique: gLXF-6EGPcGg-XjT-GE8sw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 08/28] qapi block: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:29 +0200 Message-Id: <20221018062849.3420573-9-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077921224100001 Content-Type: text/plain; charset="utf-8" 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 qapi/block*.json. Said commit explains the transformation in more detail. There is one instance of the Invariant violation mentioned there: qcow2_signal_corruption() passes false, "" when node_name is an empty string. Take care to pass NULL then. Additionally, helper bdrv_latency_histogram_stats() loses its output parameters and returns a value instead. Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster --- block/block-backend.c | 2 +- block/copy-before-write.c | 2 +- block/dirty-bitmap.c | 1 - block/export/export.c | 2 +- block/export/vduse-blk.c | 3 +- block/gluster.c | 3 - block/monitor/block-hmp-cmds.c | 48 ++++------ block/qapi-sysemu.c | 73 +++++--------- block/qapi.c | 62 +++++------- block/qcow.c | 10 +- block/qcow2.c | 18 ++-- block/qed.c | 2 +- block/quorum.c | 2 +- block/rbd.c | 15 +-- block/ssh.c | 2 +- blockdev-nbd.c | 9 +- blockdev.c | 170 +++++++++++++-------------------- blockjob.c | 2 - monitor/hmp-cmds.c | 3 +- nbd/server.c | 2 +- qemu-img.c | 13 ++- qemu-nbd.c | 2 - scripts/qapi/schema.py | 3 - 23 files changed, 170 insertions(+), 279 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index aa4adf06ae..b0ef2ea174 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1861,7 +1861,7 @@ static void send_qmp_error_event(BlockBackend *blk, BlockDriverState *bs =3D blk_bs(blk); =20 optype =3D is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE; - qapi_event_send_block_io_error(blk_name(blk), !!bs, + qapi_event_send_block_io_error(blk_name(blk), bs ? bdrv_get_node_name(bs) : NULL, opt= ype, action, blk_iostatus_is_enabled(blk), error =3D=3D ENOSPC, strerror(error)); diff --git a/block/copy-before-write.c b/block/copy-before-write.c index afbdd04489..330c812737 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -433,7 +433,7 @@ static int cbw_open(BlockDriverState *bs, QDict *option= s, int flags, return -EINVAL; } =20 - if (opts->has_bitmap) { + if (opts->bitmap) { bitmap =3D block_dirty_bitmap_lookup(opts->bitmap->node, opts->bitmap->name, NULL, errp); if (!bitmap) { diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index bf3dc0512a..9c39550698 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -541,7 +541,6 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDrive= rState *bs) =20 info->count =3D bdrv_get_dirty_count(bm); info->granularity =3D bdrv_dirty_bitmap_granularity(bm); - info->has_name =3D !!bm->name; info->name =3D g_strdup(bm->name); info->recording =3D bdrv_dirty_bitmap_recording(bm); info->busy =3D bdrv_dirty_bitmap_busy(bm); diff --git a/block/export/export.c b/block/export/export.c index 4744862915..da7480372c 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -114,7 +114,7 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Er= ror **errp) ctx =3D bdrv_get_aio_context(bs); aio_context_acquire(ctx); =20 - if (export->has_iothread) { + if (export->iothread) { IOThread *iothread; AioContext *new_ctx; Error **set_context_errp; diff --git a/block/export/vduse-blk.c b/block/export/vduse-blk.c index f101c24c3f..350d6fdaf0 100644 --- a/block/export/vduse-blk.c +++ b/block/export/vduse-blk.c @@ -265,8 +265,7 @@ static int vduse_blk_exp_create(BlockExport *exp, Block= ExportOptions *opts, } vblk_exp->num_queues =3D num_queues; vblk_exp->handler.blk =3D exp->blk; - vblk_exp->handler.serial =3D g_strdup(vblk_opts->has_serial ? - vblk_opts->serial : ""); + vblk_exp->handler.serial =3D g_strdup(vblk_opts->serial ?: ""); vblk_exp->handler.logical_block_size =3D logical_block_size; vblk_exp->handler.writable =3D opts->writable; =20 diff --git a/block/gluster.c b/block/gluster.c index bb1144cf6a..ee40eac28f 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -830,7 +830,6 @@ static int qemu_gluster_open(BlockDriverState *bs, QDi= ct *options, s->logfile =3D g_strdup(logfile ? logfile : GLUSTER_LOGFILE_DEFAULT); =20 gconf->logfile =3D g_strdup(s->logfile); - gconf->has_logfile =3D true; =20 s->glfs =3D qemu_gluster_init(gconf, filename, options, errp); if (!s->glfs) { @@ -917,7 +916,6 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState = *state, gconf->debug =3D s->debug; gconf->has_debug =3D true; gconf->logfile =3D g_strdup(s->logfile); - gconf->has_logfile =3D true; =20 /* * If 'state->bs->exact_filename' is empty, 'state->options' should co= ntain @@ -1162,7 +1160,6 @@ static int coroutine_fn qemu_gluster_co_create_opts(B= lockDriver *drv, if (!gconf->logfile) { gconf->logfile =3D g_strdup(GLUSTER_LOGFILE_DEFAULT); } - gconf->has_logfile =3D true; =20 ret =3D qemu_gluster_parse(gconf, filename, NULL, errp); if (ret < 0) { diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 939a520d17..ea9f28cf48 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -241,7 +241,6 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict) DriveMirror mirror =3D { .device =3D (char *)qdict_get_str(qdict, "device"), .target =3D (char *)filename, - .has_format =3D !!format, .format =3D (char *)format, .sync =3D full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, .has_mode =3D true, @@ -270,7 +269,6 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) DriveBackup backup =3D { .device =3D (char *)device, .target =3D (char *)filename, - .has_format =3D !!format, .format =3D (char *)format, .sync =3D full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, .has_mode =3D true, @@ -360,9 +358,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdi= ct) } =20 mode =3D reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PAT= HS; - qmp_blockdev_snapshot_sync(true, device, false, NULL, - filename, false, NULL, - !!format, format, + qmp_blockdev_snapshot_sync(device, NULL, filename, NULL, format, true, mode, &err); end: hmp_handle_error(mon, err); @@ -385,8 +381,7 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, = const QDict *qdict) const char *id =3D qdict_get_try_str(qdict, "id"); Error *err =3D NULL; =20 - qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id, - true, name, &err); + qmp_blockdev_snapshot_delete_internal_sync(device, id, name, &err); hmp_handle_error(mon, err); } =20 @@ -427,7 +422,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qd= ict) block_list =3D qmp_query_block(NULL); =20 for (info =3D block_list; info; info =3D info->next) { - if (!info->value->has_inserted) { + if (!info->value->inserted) { continue; } =20 @@ -460,7 +455,6 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdic= t) =20 NbdServerAddOptions export =3D { .device =3D (char *) device, - .has_name =3D !!name, .name =3D (char *) name, .has_writable =3D true, .writable =3D writable, @@ -495,7 +489,7 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict) int64_t size =3D qdict_get_int(qdict, "size"); Error *err =3D NULL; =20 - qmp_block_resize(true, device, false, NULL, size, &err); + qmp_block_resize(device, NULL, size, &err); hmp_handle_error(mon, err); } =20 @@ -506,11 +500,10 @@ void hmp_block_stream(Monitor *mon, const QDict *qdic= t) const char *base =3D qdict_get_try_str(qdict, "base"); int64_t speed =3D qdict_get_try_int(qdict, "speed", 0); =20 - qmp_block_stream(true, device, device, base !=3D NULL, base, false, NU= LL, - false, NULL, false, NULL, - qdict_haskey(qdict, "speed"), speed, true, - BLOCKDEV_ON_ERROR_REPORT, false, NULL, false, false, = false, - false, &error); + qmp_block_stream(device, device, base, NULL, NULL, NULL, + qdict_haskey(qdict, "speed"), speed, + true, BLOCKDEV_ON_ERROR_REPORT, NULL, + false, false, false, false, &error); =20 hmp_handle_error(mon, error); } @@ -534,10 +527,8 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDi= ct *qdict) * version has only one, so we must decide which one to pass. */ if (blk_by_name(device)) { - throttle.has_device =3D true; throttle.device =3D device; } else { - throttle.has_id =3D true; throttle.id =3D device; } =20 @@ -551,7 +542,7 @@ void hmp_eject(Monitor *mon, const QDict *qdict) const char *device =3D qdict_get_str(qdict, "device"); Error *err =3D NULL; =20 - qmp_eject(true, device, false, NULL, true, force, &err); + qmp_eject(device, NULL, true, force, &err); hmp_handle_error(mon, err); } =20 @@ -635,18 +626,18 @@ static void print_block_info(Monitor *mon, BlockInfo = *info, { ImageInfo *image_info; =20 - assert(!info || !info->has_inserted || info->inserted =3D=3D inserted); + assert(!info || !info->inserted || info->inserted =3D=3D inserted); =20 if (info && *info->device) { monitor_puts(mon, info->device); - if (inserted && inserted->has_node_name) { + if (inserted && inserted->node_name) { monitor_printf(mon, " (%s)", inserted->node_name); } } else { assert(info || inserted); monitor_puts(mon, - inserted && inserted->has_node_name ? inserted->node_= name - : info && info->has_qdev ? info->qdev + inserted && inserted->node_name ? inserted->node_name + : info && info->qdev ? info->qdev : ""); } =20 @@ -661,7 +652,7 @@ static void print_block_info(Monitor *mon, BlockInfo *i= nfo, } =20 if (info) { - if (info->has_qdev) { + if (info->qdev) { monitor_printf(mon, " Attached to: %s\n", info->qdev); } if (info->has_io_status && info->io_status !=3D BLOCK_DEVICE_IO_ST= ATUS_OK) { @@ -686,7 +677,7 @@ static void print_block_info(Monitor *mon, BlockInfo *i= nfo, inserted->cache->direct ? ", direct" : "", inserted->cache->no_flush ? ", ignore flushes" : ""); =20 - if (inserted->has_backing_file) { + if (inserted->backing_file) { monitor_printf(mon, " Backing file: %s " "(chain depth: %" PRId64 ")\n", @@ -735,7 +726,7 @@ static void print_block_info(Monitor *mon, BlockInfo *i= nfo, image_info =3D inserted->image; while (1) { bdrv_image_info_dump(image_info); - if (image_info->has_backing_image) { + if (image_info->backing_image) { image_info =3D image_info->backing_image; } else { break; @@ -769,8 +760,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) monitor_printf(mon, "\n"); } =20 - print_block_info(mon, info->value, info->value->has_inserted - ? info->value->inserted : NULL, + print_block_info(mon, info->value, info->value->inserted, verbose); printed =3D true; } @@ -784,7 +774,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) /* Print node information */ blockdev_list =3D qmp_query_named_block_nodes(false, false, NULL); for (blockdev =3D blockdev_list; blockdev; blockdev =3D blockdev->next= ) { - assert(blockdev->value->has_node_name); + assert(blockdev->value->node_name); if (device && strcmp(device, blockdev->value->node_name)) { continue; } @@ -805,7 +795,7 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdi= ct) stats_list =3D qmp_query_blockstats(false, false, NULL); =20 for (stats =3D stats_list; stats; stats =3D stats->next) { - if (!stats->value->has_device) { + if (!stats->value->device) { continue; } =20 diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c index 680c7ee342..0c7a1423de 100644 --- a/block/qapi-sysemu.c +++ b/block/qapi-sysemu.c @@ -116,8 +116,8 @@ static int do_open_tray(const char *blk_name, const cha= r *qdev_id, return 0; } =20 -void qmp_blockdev_open_tray(bool has_device, const char *device, - bool has_id, const char *id, +void qmp_blockdev_open_tray(const char *device, + const char *id, bool has_force, bool force, Error **errp) { @@ -127,9 +127,7 @@ void qmp_blockdev_open_tray(bool has_device, const char= *device, if (!has_force) { force =3D false; } - rc =3D do_open_tray(has_device ? device : NULL, - has_id ? id : NULL, - force, &local_err); + rc =3D do_open_tray(device, id, force, &local_err); if (rc && rc !=3D -ENOSYS && rc !=3D -EINPROGRESS) { error_propagate(errp, local_err); return; @@ -137,16 +135,13 @@ void qmp_blockdev_open_tray(bool has_device, const ch= ar *device, error_free(local_err); } =20 -void qmp_blockdev_close_tray(bool has_device, const char *device, - bool has_id, const char *id, +void qmp_blockdev_close_tray(const char *device, + const char *id, Error **errp) { BlockBackend *blk; Error *local_err =3D NULL; =20 - device =3D has_device ? device : NULL; - id =3D has_id ? id : NULL; - blk =3D qmp_get_blk(device, id, errp); if (!blk) { return; @@ -173,17 +168,14 @@ void qmp_blockdev_close_tray(bool has_device, const c= har *device, } } =20 -static void blockdev_remove_medium(bool has_device, const char *device, - bool has_id, const char *id, Error **er= rp) +static void blockdev_remove_medium(const char *device, const char *id, + Error **errp) { BlockBackend *blk; BlockDriverState *bs; AioContext *aio_context; bool has_attached_device; =20 - device =3D has_device ? device : NULL; - id =3D has_id ? id : NULL; - blk =3D qmp_get_blk(device, id, errp); if (!blk) { return; @@ -232,7 +224,7 @@ out: =20 void qmp_blockdev_remove_medium(const char *id, Error **errp) { - blockdev_remove_medium(false, NULL, true, id, errp); + blockdev_remove_medium(NULL, id, errp); } =20 static void qmp_blockdev_insert_anon_medium(BlockBackend *blk, @@ -280,16 +272,13 @@ static void qmp_blockdev_insert_anon_medium(BlockBack= end *blk, } } =20 -static void blockdev_insert_medium(bool has_device, const char *device, - bool has_id, const char *id, +static void blockdev_insert_medium(const char *device, const char *id, const char *node_name, Error **errp) { BlockBackend *blk; BlockDriverState *bs; =20 - blk =3D qmp_get_blk(has_device ? device : NULL, - has_id ? id : NULL, - errp); + blk =3D qmp_get_blk(device, id, errp); if (!blk) { return; } @@ -311,13 +300,13 @@ static void blockdev_insert_medium(bool has_device, c= onst char *device, void qmp_blockdev_insert_medium(const char *id, const char *node_name, Error **errp) { - blockdev_insert_medium(false, NULL, true, id, node_name, errp); + blockdev_insert_medium(NULL, id, node_name, errp); } =20 -void qmp_blockdev_change_medium(bool has_device, const char *device, - bool has_id, const char *id, +void qmp_blockdev_change_medium(const char *device, + const char *id, const char *filename, - bool has_format, const char *format, + const char *format, bool has_force, bool force, bool has_read_only, BlockdevChangeReadOnlyMode read_only, @@ -331,9 +320,7 @@ void qmp_blockdev_change_medium(bool has_device, const = char *device, QDict *options =3D NULL; Error *err =3D NULL; =20 - blk =3D qmp_get_blk(has_device ? device : NULL, - has_id ? id : NULL, - errp); + blk =3D qmp_get_blk(device, id, errp); if (!blk) { goto fail; } @@ -370,7 +357,7 @@ void qmp_blockdev_change_medium(bool has_device, const = char *device, detect_zeroes =3D blk_get_detect_zeroes_from_root_state(blk); qdict_put_str(options, "detect-zeroes", detect_zeroes ? "on" : "off"); =20 - if (has_format) { + if (format) { qdict_put_str(options, "driver", format); } =20 @@ -379,9 +366,7 @@ void qmp_blockdev_change_medium(bool has_device, const = char *device, goto fail; } =20 - rc =3D do_open_tray(has_device ? device : NULL, - has_id ? id : NULL, - force, &err); + rc =3D do_open_tray(device, id, force, &err); if (rc && rc !=3D -ENOSYS) { error_propagate(errp, err); goto fail; @@ -389,7 +374,7 @@ void qmp_blockdev_change_medium(bool has_device, const = char *device, error_free(err); err =3D NULL; =20 - blockdev_remove_medium(has_device, device, has_id, id, &err); + blockdev_remove_medium(device, id, &err); if (err) { error_propagate(errp, err); goto fail; @@ -401,7 +386,7 @@ void qmp_blockdev_change_medium(bool has_device, const = char *device, goto fail; } =20 - qmp_blockdev_close_tray(has_device, device, has_id, id, errp); + qmp_blockdev_close_tray(device, id, errp); =20 fail: /* If the medium has been inserted, the device has its own reference, = so @@ -410,8 +395,7 @@ fail: bdrv_unref(medium_bs); } =20 -void qmp_eject(bool has_device, const char *device, - bool has_id, const char *id, +void qmp_eject(const char *device, const char *id, bool has_force, bool force, Error **errp) { Error *local_err =3D NULL; @@ -421,16 +405,14 @@ void qmp_eject(bool has_device, const char *device, force =3D false; } =20 - rc =3D do_open_tray(has_device ? device : NULL, - has_id ? id : NULL, - force, &local_err); + rc =3D do_open_tray(device, id, force, &local_err); if (rc && rc !=3D -ENOSYS) { error_propagate(errp, local_err); return; } error_free(local_err); =20 - blockdev_remove_medium(has_device, device, has_id, id, errp); + blockdev_remove_medium(device, id, errp); } =20 /* throttling disk I/O limits */ @@ -441,9 +423,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Er= ror **errp) BlockBackend *blk; AioContext *aio_context; =20 - blk =3D qmp_get_blk(arg->has_device ? arg->device : NULL, - arg->has_id ? arg->id : NULL, - errp); + blk =3D qmp_get_blk(arg->device, arg->id, errp); if (!blk) { return; } @@ -516,11 +496,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, E= rror **errp) /* Enable I/O limits if they're not enabled yet, otherwise * just update the throttling group. */ if (!blk_get_public(blk)->throttle_group_member.throttle_state) { - blk_io_limits_enable(blk, - arg->has_group ? arg->group : - arg->has_device ? arg->device : - arg->id); - } else if (arg->has_group) { + blk_io_limits_enable(blk, arg->group ?: arg->device ?: arg->id= ); + } else if (arg->group) { blk_io_limits_update_group(blk, arg->group); } /* Set the new throttling configuration */ diff --git a/block/qapi.c b/block/qapi.c index cf557e3aea..fea808425b 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -71,13 +71,11 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *b= lk, }; =20 if (bs->node_name[0]) { - info->has_node_name =3D true; info->node_name =3D g_strdup(bs->node_name); } =20 backing =3D bdrv_cow_bs(bs); if (backing) { - info->has_backing_file =3D true; info->backing_file =3D g_strdup(backing->filename); } =20 @@ -139,7 +137,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *b= lk, info->has_iops_size =3D cfg.op_size; info->iops_size =3D cfg.op_size; =20 - info->has_group =3D true; info->group =3D g_strdup(throttle_group_get_name(&blkp->throttle_group_member)= ); } @@ -170,7 +167,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *b= lk, */ info->backing_file_depth++; bs0 =3D bdrv_filter_or_cow_bs(bs0); - (*p_image_info)->has_backing_image =3D true; p_image_info =3D &((*p_image_info)->backing_image); } else { break; @@ -301,26 +297,21 @@ void bdrv_query_image_info(BlockDriverState *bs, qapi_free_ImageInfo(info); goto out; } - info->has_format_specific =3D info->format_specific !=3D NULL; - backing_filename =3D bs->backing_file; if (backing_filename[0] !=3D '\0') { char *backing_filename2; =20 info->backing_filename =3D g_strdup(backing_filename); - info->has_backing_filename =3D true; backing_filename2 =3D bdrv_get_full_backing_filename(bs, NULL); =20 /* Always report the full_backing_filename if present, even if it'= s the * same as backing_filename. That they are same is useful info. */ if (backing_filename2) { info->full_backing_filename =3D g_strdup(backing_filename2); - info->has_full_backing_filename =3D true; } =20 if (bs->backing_format[0]) { info->backing_filename_format =3D g_strdup(bs->backing_format); - info->has_backing_filename_format =3D true; } g_free(backing_filename2); } @@ -367,7 +358,6 @@ static void bdrv_query_info(BlockBackend *blk, BlockInf= o **p_info, =20 qdev =3D blk_get_attached_dev_id(blk); if (qdev && *qdev) { - info->has_qdev =3D true; info->qdev =3D qdev; } else { g_free(qdev); @@ -384,7 +374,6 @@ static void bdrv_query_info(BlockBackend *blk, BlockInf= o **p_info, } =20 if (bs && bs->drv) { - info->has_inserted =3D true; info->inserted =3D bdrv_block_device_info(blk, bs, false, errp); if (info->inserted =3D=3D NULL) { goto err; @@ -411,23 +400,26 @@ static uint64List *uint64_list(uint64_t *list, int si= ze) return out_list; } =20 -static void bdrv_latency_histogram_stats(BlockLatencyHistogram *hist, - bool *not_null, - BlockLatencyHistogramInfo **info) +static BlockLatencyHistogramInfo * +bdrv_latency_histogram_stats(BlockLatencyHistogram *hist) { - *not_null =3D hist->bins !=3D NULL; - if (*not_null) { - *info =3D g_new0(BlockLatencyHistogramInfo, 1); + BlockLatencyHistogramInfo *info; =20 - (*info)->boundaries =3D uint64_list(hist->boundaries, hist->nbins = - 1); - (*info)->bins =3D uint64_list(hist->bins, hist->nbins); + if (!hist->bins) { + return NULL; } + + info =3D g_new0(BlockLatencyHistogramInfo, 1); + info->boundaries =3D uint64_list(hist->boundaries, hist->nbins - 1); + info->bins =3D uint64_list(hist->bins, hist->nbins); + return info; } =20 static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) { BlockAcctStats *stats =3D blk_get_stats(blk); BlockAcctTimedStats *ts =3D NULL; + BlockLatencyHistogram *hgram; =20 ds->rd_bytes =3D stats->nr_bytes[BLOCK_ACCT_READ]; ds->wr_bytes =3D stats->nr_bytes[BLOCK_ACCT_WRITE]; @@ -493,15 +485,13 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds= , BlockBackend *blk) QAPI_LIST_PREPEND(ds->timed_stats, dev_stats); } =20 - bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_READ= ], - &ds->has_rd_latency_histogram, - &ds->rd_latency_histogram); - bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_WRIT= E], - &ds->has_wr_latency_histogram, - &ds->wr_latency_histogram); - bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_FLUS= H], - &ds->has_flush_latency_histogram, - &ds->flush_latency_histogram); + hgram =3D stats->latency_histogram; + ds->rd_latency_histogram + =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_READ]); + ds->wr_latency_histogram + =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_WRITE]); + ds->flush_latency_histogram + =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_FLUSH]); } =20 static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, @@ -526,16 +516,12 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverSt= ate *bs, } =20 if (bdrv_get_node_name(bs)[0]) { - s->has_node_name =3D true; s->node_name =3D g_strdup(bdrv_get_node_name(bs)); } =20 s->stats->wr_highest_offset =3D stat64_get(&bs->wr_highest_offset); =20 s->driver_specific =3D bdrv_get_specific_stats(bs); - if (s->driver_specific) { - s->has_driver_specific =3D true; - } =20 parent_child =3D bdrv_primary_child(bs); if (!parent_child || @@ -564,7 +550,6 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverStat= e *bs, } } if (parent_child) { - s->has_parent =3D true; s->parent =3D bdrv_query_bds_stats(parent_child->bs, blk_level); } =20 @@ -575,7 +560,6 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverStat= e *bs, * compatibility to when we put bs0->backing here, which might * be either) */ - s->has_backing =3D true; s->backing =3D bdrv_query_bds_stats(filter_or_cow_bs, blk_level); } =20 @@ -640,12 +624,10 @@ BlockStatsList *qmp_query_blockstats(bool has_query_n= odes, =20 aio_context_acquire(ctx); s =3D bdrv_query_bds_stats(blk_bs(blk), true); - s->has_device =3D true; s->device =3D g_strdup(blk_name(blk)); =20 qdev =3D blk_get_attached_dev_id(blk); if (qdev && *qdev) { - s->has_qdev =3D true; s->qdev =3D qdev; } else { g_free(qdev); @@ -822,16 +804,16 @@ void bdrv_image_info_dump(ImageInfo *info) qemu_printf("cleanly shut down: no\n"); } =20 - if (info->has_backing_filename) { + if (info->backing_filename) { qemu_printf("backing file: %s", info->backing_filename); - if (!info->has_full_backing_filename) { + if (!info->full_backing_filename) { qemu_printf(" (cannot determine actual path)"); } else if (strcmp(info->backing_filename, info->full_backing_filename) !=3D 0) { qemu_printf(" (actual path: %s)", info->full_backing_filename); } qemu_printf("\n"); - if (info->has_backing_filename_format) { + if (info->backing_filename_format) { qemu_printf("backing file format: %s\n", info->backing_filename_format); } @@ -865,7 +847,7 @@ void bdrv_image_info_dump(ImageInfo *info) } } =20 - if (info->has_format_specific) { + if (info->format_specific) { qemu_printf("Format specific information:\n"); bdrv_image_info_specific_dump(info->format_specific); } diff --git a/block/qcow.c b/block/qcow.c index 311aaa8705..6374380e77 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -825,7 +825,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, return -EINVAL; } =20 - if (qcow_opts->has_encrypt && + if (qcow_opts->encrypt && qcow_opts->encrypt->format !=3D Q_CRYPTO_BLOCK_FORMAT_QCOW) { error_setg(errp, "Unsupported encryption format"); @@ -853,7 +853,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, header.size =3D cpu_to_be64(total_size); header_size =3D sizeof(header); backing_filename_len =3D 0; - if (qcow_opts->has_backing_file) { + if (qcow_opts->backing_file) { if (strcmp(qcow_opts->backing_file, "fat:")) { header.backing_file_offset =3D cpu_to_be64(header_size); backing_filename_len =3D strlen(qcow_opts->backing_file); @@ -861,7 +861,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, header_size +=3D backing_filename_len; } else { /* special backing file for vvfat */ - qcow_opts->has_backing_file =3D false; + qcow_opts->backing_file =3D NULL; } header.cluster_bits =3D 9; /* 512 byte cluster to avoid copying unmodified sectors */ @@ -876,7 +876,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, =20 header.l1_table_offset =3D cpu_to_be64(header_size); =20 - if (qcow_opts->has_encrypt) { + if (qcow_opts->encrypt) { header.crypt_method =3D cpu_to_be32(QCOW_CRYPT_AES); =20 crypto =3D qcrypto_block_create(qcow_opts->encrypt, "encrypt.", @@ -895,7 +895,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, goto exit; } =20 - if (qcow_opts->has_backing_file) { + if (qcow_opts->backing_file) { ret =3D blk_pwrite(qcow_blk, sizeof(header), backing_filename_len, qcow_opts->backing_file, 0); if (ret < 0) { diff --git a/block/qcow2.c b/block/qcow2.c index b57f7cc8ee..2ee3aa12d2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3508,7 +3508,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) if (!qcow2_opts->has_preallocation) { qcow2_opts->preallocation =3D PREALLOC_MODE_OFF; } - if (qcow2_opts->has_backing_file && + if (qcow2_opts->backing_file && qcow2_opts->preallocation !=3D PREALLOC_MODE_OFF && !qcow2_opts->extended_l2) { @@ -3517,7 +3517,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) ret =3D -EINVAL; goto out; } - if (qcow2_opts->has_backing_fmt && !qcow2_opts->has_backing_file) { + if (qcow2_opts->has_backing_fmt && !qcow2_opts->backing_file) { error_setg(errp, "Backing format cannot be used without backing fi= le"); ret =3D -EINVAL; goto out; @@ -3558,7 +3558,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) ret =3D -EINVAL; goto out; } - if (qcow2_opts->data_file_raw && qcow2_opts->has_backing_file) { + if (qcow2_opts->data_file_raw && qcow2_opts->backing_file) { error_setg(errp, "Backing file and data-file-raw cannot be used at= " "the same time"); ret =3D -EINVAL; @@ -3584,7 +3584,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) * backing file when specifying data_file_raw is an error * anyway. */ - assert(!qcow2_opts->has_backing_file); + assert(!qcow2_opts->backing_file); } =20 if (qcow2_opts->data_file) { @@ -3752,7 +3752,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) } =20 /* Want a backing file? There you go. */ - if (qcow2_opts->has_backing_file) { + if (qcow2_opts->backing_file) { const char *backing_format =3D NULL; =20 if (qcow2_opts->has_backing_fmt) { @@ -3770,7 +3770,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) } =20 /* Want encryption? There you go. */ - if (qcow2_opts->has_encrypt) { + if (qcow2_opts->encrypt) { ret =3D qcow2_set_up_encryption(blk_bs(blk), qcow2_opts->encrypt, = errp); if (ret < 0) { goto out; @@ -5195,7 +5195,6 @@ static ImageInfoSpecific *qcow2_get_specific_info(Blo= ckDriverState *bs, .refcount_bits =3D s->refcount_bits, .has_bitmaps =3D !!bitmaps, .bitmaps =3D bitmaps, - .has_data_file =3D !!s->image_data_file, .data_file =3D g_strdup(s->image_data_file), .has_data_file_raw =3D has_data_file(bs), .data_file_raw =3D data_file_is_raw(bs), @@ -5226,7 +5225,6 @@ static ImageInfoSpecific *qcow2_get_specific_info(Blo= ckDriverState *bs, memset(&encrypt_info->u, 0, sizeof(encrypt_info->u)); qapi_free_QCryptoBlockInfo(encrypt_info); =20 - spec_info->u.qcow2.data->has_encrypt =3D true; spec_info->u.qcow2.data->encrypt =3D qencrypt; } =20 @@ -5846,7 +5844,7 @@ static int coroutine_fn qcow2_co_amend(BlockDriverSta= te *bs, BDRVQcow2State *s =3D bs->opaque; int ret =3D 0; =20 - if (qopts->has_encrypt) { + if (qopts->encrypt) { if (!s->crypto) { error_setg(errp, "image is not encrypted, can't amend"); return -EOPNOTSUPP; @@ -5911,7 +5909,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bo= ol fatal, int64_t offset, =20 node_name =3D bdrv_get_node_name(bs); qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs), - *node_name !=3D '\0', node_name, + *node_name ? node_name : NULL, message, offset >=3D 0, offset, size >=3D 0, size, fatal); diff --git a/block/qed.c b/block/qed.c index bda00e6257..ccbafa154a 100644 --- a/block/qed.c +++ b/block/qed.c @@ -698,7 +698,7 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCrea= teOptions *opts, goto out; } =20 - if (qed_opts->has_backing_file) { + if (qed_opts->backing_file) { header.features |=3D QED_F_BACKING_FILE; header.backing_filename_offset =3D sizeof(le_header); header.backing_filename_size =3D strlen(qed_opts->backing_file); diff --git a/block/quorum.c b/block/quorum.c index f9e6539ceb..7f21c03f1f 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -202,7 +202,7 @@ static void quorum_report_bad(QuorumOpType type, uint64= _t offset, msg =3D strerror(-ret); } =20 - qapi_event_send_quorum_report_bad(type, !!msg, msg, node_name, start_s= ector, + qapi_event_send_quorum_report_bad(type, msg, node_name, start_sector, end_sector - start_sector); } =20 diff --git a/block/rbd.c b/block/rbd.c index f826410f40..d809b8e0a3 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -536,7 +536,7 @@ static int qemu_rbd_do_create(BlockdevCreateOptions *op= tions, int ret; =20 assert(options->driver =3D=3D BLOCKDEV_DRIVER_RBD); - if (opts->location->has_snapshot) { + if (opts->location->snapshot) { error_setg(errp, "Can't use snapshot name for image creation"); return -EINVAL; } @@ -574,7 +574,7 @@ static int qemu_rbd_do_create(BlockdevCreateOptions *op= tions, } =20 #ifdef LIBRBD_SUPPORTS_ENCRYPTION - if (opts->has_encrypt) { + if (opts->encrypt) { rbd_image_t image; =20 ret =3D rbd_open(io_ctx, opts->location->image, &image, NULL); @@ -686,7 +686,6 @@ static int coroutine_fn qemu_rbd_co_create_opts(BlockDr= iver *drv, goto exit; } rbd_opts->encrypt =3D encrypt; - rbd_opts->has_encrypt =3D !!encrypt; =20 /* * Caution: while qdict_get_try_str() is fine, getting non-string @@ -697,11 +696,8 @@ static int coroutine_fn qemu_rbd_co_create_opts(BlockD= river *drv, loc =3D rbd_opts->location; loc->pool =3D g_strdup(qdict_get_try_str(options, "pool")); loc->conf =3D g_strdup(qdict_get_try_str(options, "conf")); - loc->has_conf =3D !!loc->conf; loc->user =3D g_strdup(qdict_get_try_str(options, "user")); - loc->has_user =3D !!loc->user; loc->q_namespace =3D g_strdup(qdict_get_try_str(options, "namespace")); - loc->has_q_namespace =3D !!loc->q_namespace; loc->image =3D g_strdup(qdict_get_try_str(options, "image")); keypairs =3D qdict_get_try_str(options, "=3Dkeyvalue-pairs"); =20 @@ -767,7 +763,6 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioc= tx_t *io_ctx, return -EINVAL; } opts->key_secret =3D g_strdup(secretid); - opts->has_key_secret =3D true; } =20 mon_host =3D qemu_rbd_mon_host(opts, &local_err); @@ -785,7 +780,7 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioc= tx_t *io_ctx, =20 /* try default location when conf=3DNULL, but ignore failure */ r =3D rados_conf_read_file(*cluster, opts->conf); - if (opts->has_conf && r < 0) { + if (opts->conf && r < 0) { error_setg_errno(errp, -r, "error reading conf file %s", opts->con= f); goto failed_shutdown; } @@ -833,7 +828,7 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioc= tx_t *io_ctx, } =20 #ifdef HAVE_RBD_NAMESPACE_EXISTS - if (opts->has_q_namespace && strlen(opts->q_namespace) > 0) { + if (opts->q_namespace && strlen(opts->q_namespace) > 0) { bool exists; =20 r =3D rbd_namespace_exists(*io_ctx, opts->q_namespace, &exists); @@ -991,7 +986,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, goto failed_open; } =20 - if (opts->has_encrypt) { + if (opts->encrypt) { #ifdef LIBRBD_SUPPORTS_ENCRYPTION r =3D qemu_rbd_encryption_load(s->image, opts->encrypt, errp); if (r < 0) { diff --git a/block/ssh.c b/block/ssh.c index a2dc646536..2d2dac5f88 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -643,7 +643,7 @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOpti= onsSsh *opts, unsigned int port =3D 0; int new_sock =3D -1; =20 - if (opts->has_user) { + if (opts->user) { s->user =3D g_strdup(opts->user); } else { s->user =3D g_strdup(g_get_user_name()); diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 012256bb02..213012435f 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -173,8 +173,8 @@ void nbd_server_start_options(NbdServerOptions *arg, Er= ror **errp) } =20 void qmp_nbd_server_start(SocketAddressLegacy *addr, - bool has_tls_creds, const char *tls_creds, - bool has_tls_authz, const char *tls_authz, + const char *tls_creds, + const char *tls_authz, bool has_max_connections, uint32_t max_connectio= ns, Error **errp) { @@ -200,8 +200,7 @@ void qmp_nbd_server_add(NbdServerAddOptions *arg, Error= **errp) * block-export-add would default to the node-name, but we may have to= use * the device name as a default here for compatibility. */ - if (!arg->has_name) { - arg->has_name =3D true; + if (!arg->name) { arg->name =3D g_strdup(arg->device); } =20 @@ -215,7 +214,7 @@ void qmp_nbd_server_add(NbdServerAddOptions *arg, Error= **errp) }; QAPI_CLONE_MEMBERS(BlockExportOptionsNbdBase, &export_opts->u.nbd, qapi_NbdServerAddOptions_base(arg)); - if (arg->has_bitmap) { + if (arg->bitmap) { BlockDirtyBitmapOrStr *el =3D g_new(BlockDirtyBitmapOrStr, 1); =20 *el =3D (BlockDirtyBitmapOrStr) { diff --git a/blockdev.c b/blockdev.c index a32bafc07a..6a3b8cdbc6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1051,23 +1051,17 @@ static void blockdev_do_action(TransactionAction *a= ction, Error **errp) qmp_transaction(&list, false, NULL, errp); } =20 -void qmp_blockdev_snapshot_sync(bool has_device, const char *device, - bool has_node_name, const char *node_name, +void qmp_blockdev_snapshot_sync(const char *device, const char *node_name, const char *snapshot_file, - bool has_snapshot_node_name, const char *snapshot_node_name, - bool has_format, const char *format, + const char *format, bool has_mode, NewImageMode mode, Error **= errp) { BlockdevSnapshotSync snapshot =3D { - .has_device =3D has_device, .device =3D (char *) device, - .has_node_name =3D has_node_name, .node_name =3D (char *) node_name, .snapshot_file =3D (char *) snapshot_file, - .has_snapshot_node_name =3D has_snapshot_node_name, .snapshot_node_name =3D (char *) snapshot_node_name, - .has_format =3D has_format, .format =3D (char *) format, .has_mode =3D has_mode, .mode =3D mode, @@ -1109,9 +1103,7 @@ void qmp_blockdev_snapshot_internal_sync(const char *= device, } =20 SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *devic= e, - bool has_id, const char *id, - bool has_name, const char *name, Error **errp) { @@ -1129,14 +1121,6 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_= sync(const char *device, aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 - if (!has_id) { - id =3D NULL; - } - - if (!has_name) { - name =3D NULL; - } - if (!id && !name) { error_setg(errp, "Name or id must be provided"); goto out_aio_context; @@ -1450,8 +1434,8 @@ static void external_snapshot_prepare(BlkActionState = *common, case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC: { BlockdevSnapshotSync *s =3D action->u.blockdev_snapshot_sync.d= ata; - device =3D s->has_device ? s->device : NULL; - node_name =3D s->has_node_name ? s->node_name : NULL; + device =3D s->device; + node_name =3D s->node_name; new_image_file =3D s->snapshot_file; snapshot_ref =3D NULL; } @@ -1495,10 +1479,9 @@ static void external_snapshot_prepare(BlkActionState= *common, =20 if (action->type =3D=3D TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC= ) { BlockdevSnapshotSync *s =3D action->u.blockdev_snapshot_sync.data; - const char *format =3D s->has_format ? s->format : "qcow2"; + const char *format =3D s->format ?: "qcow2"; enum NewImageMode mode; - const char *snapshot_node_name =3D - s->has_snapshot_node_name ? s->snapshot_node_name : NULL; + const char *snapshot_node_name =3D s->snapshot_node_name; =20 if (node_name && !snapshot_node_name) { error_setg(errp, "New overlay node-name missing"); @@ -1717,7 +1700,7 @@ static void drive_backup_prepare(BlkActionState *comm= on, Error **errp) /* Paired with .clean() */ bdrv_drained_begin(bs); =20 - if (!backup->has_format) { + if (!backup->format) { backup->format =3D backup->mode =3D=3D NEW_IMAGE_MODE_EXISTING ? NULL : (char *) bs->drv->format_name; } @@ -2380,9 +2363,7 @@ exit: } g_free(state); } - if (!has_props) { - qapi_free_TransactionProperties(props); - } + qapi_free_TransactionProperties(props); job_txn_unref(block_job_txn); } =20 @@ -2411,8 +2392,7 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitma= p_sha256(const char *node, return ret; } =20 -void coroutine_fn qmp_block_resize(bool has_device, const char *device, - bool has_node_name, const char *node_na= me, +void coroutine_fn qmp_block_resize(const char *device, const char *node_na= me, int64_t size, Error **errp) { Error *local_err =3D NULL; @@ -2420,9 +2400,7 @@ void coroutine_fn qmp_block_resize(bool has_device, c= onst char *device, BlockDriverState *bs; AioContext *old_ctx; =20 - bs =3D bdrv_lookup_bs(has_device ? device : NULL, - has_node_name ? node_name : NULL, - &local_err); + bs =3D bdrv_lookup_bs(device, node_name, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -2457,14 +2435,14 @@ void coroutine_fn qmp_block_resize(bool has_device,= const char *device, bdrv_co_unlock(bs); } =20 -void qmp_block_stream(bool has_job_id, const char *job_id, const char *dev= ice, - bool has_base, const char *base, - bool has_base_node, const char *base_node, - bool has_backing_file, const char *backing_file, - bool has_bottom, const char *bottom, +void qmp_block_stream(const char *job_id, const char *device, + const char *base, + const char *base_node, + const char *backing_file, + const char *bottom, bool has_speed, int64_t speed, bool has_on_error, BlockdevOnError on_error, - bool has_filter_node_name, const char *filter_node_n= ame, + const char *filter_node_name, bool has_auto_finalize, bool auto_finalize, bool has_auto_dismiss, bool auto_dismiss, Error **errp) @@ -2476,19 +2454,19 @@ void qmp_block_stream(bool has_job_id, const char *= job_id, const char *device, Error *local_err =3D NULL; int job_flags =3D JOB_DEFAULT; =20 - if (has_base && has_base_node) { + if (base && base_node) { error_setg(errp, "'base' and 'base-node' cannot be specified " "at the same time"); return; } =20 - if (has_base && has_bottom) { + if (base && bottom) { error_setg(errp, "'base' and 'bottom' cannot be specified " "at the same time"); return; } =20 - if (has_bottom && has_base_node) { + if (bottom && base_node) { error_setg(errp, "'bottom' and 'base-node' cannot be specified " "at the same time"); return; @@ -2506,7 +2484,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 - if (has_base) { + if (base) { base_bs =3D bdrv_find_backing_image(bs, base); if (base_bs =3D=3D NULL) { error_setg(errp, "Can't find '%s' in the backing chain", base); @@ -2515,7 +2493,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, assert(bdrv_get_aio_context(base_bs) =3D=3D aio_context); } =20 - if (has_base_node) { + if (base_node) { base_bs =3D bdrv_lookup_bs(NULL, base_node, errp); if (!base_bs) { goto out; @@ -2529,7 +2507,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, bdrv_refresh_filename(base_bs); } =20 - if (has_bottom) { + if (bottom) { bottom_bs =3D bdrv_lookup_bs(NULL, bottom, errp); if (!bottom_bs) { goto out; @@ -2554,7 +2532,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, /* * Check for op blockers in the whole chain between bs and base (or bo= ttom) */ - iter_end =3D has_bottom ? bdrv_filter_or_cow_bs(bottom_bs) : base_bs; + iter_end =3D bottom ? bdrv_filter_or_cow_bs(bottom_bs) : base_bs; for (iter =3D bs; iter && iter !=3D iter_end; iter =3D bdrv_filter_or_cow_bs(iter)) { @@ -2565,7 +2543,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, =20 /* if we are streaming the entire chain, the result will have no backi= ng * file, and specifying one is therefore an error */ - if (base_bs =3D=3D NULL && has_backing_file) { + if (!base_bs && backing_file) { error_setg(errp, "backing file specified, but streaming the " "entire chain"); goto out; @@ -2578,7 +2556,7 @@ void qmp_block_stream(bool has_job_id, const char *jo= b_id, const char *device, job_flags |=3D JOB_MANUAL_DISMISS; } =20 - stream_start(has_job_id ? job_id : NULL, bs, base_bs, backing_file, + stream_start(job_id, bs, base_bs, backing_file, bottom_bs, job_flags, has_speed ? speed : 0, on_error, filter_node_name, &local_err); if (local_err) { @@ -2592,15 +2570,15 @@ out: aio_context_release(aio_context); } =20 -void qmp_block_commit(bool has_job_id, const char *job_id, const char *dev= ice, - bool has_base_node, const char *base_node, - bool has_base, const char *base, - bool has_top_node, const char *top_node, - bool has_top, const char *top, - bool has_backing_file, const char *backing_file, +void qmp_block_commit(const char *job_id, const char *device, + const char *base_node, + const char *base, + const char *top_node, + const char *top, + const char *backing_file, bool has_speed, int64_t speed, bool has_on_error, BlockdevOnError on_error, - bool has_filter_node_name, const char *filter_node_n= ame, + const char *filter_node_name, bool has_auto_finalize, bool auto_finalize, bool has_auto_dismiss, bool auto_dismiss, Error **errp) @@ -2619,9 +2597,6 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, if (!has_on_error) { on_error =3D BLOCKDEV_ON_ERROR_REPORT; } - if (!has_filter_node_name) { - filter_node_name =3D NULL; - } if (has_auto_finalize && !auto_finalize) { job_flags |=3D JOB_MANUAL_FINALIZE; } @@ -2657,10 +2632,10 @@ void qmp_block_commit(bool has_job_id, const char *= job_id, const char *device, /* default top_bs is the active layer */ top_bs =3D bs; =20 - if (has_top_node && has_top) { + if (top_node && top) { error_setg(errp, "'top-node' and 'top' are mutually exclusive"); goto out; - } else if (has_top_node) { + } else if (top_node) { top_bs =3D bdrv_lookup_bs(NULL, top_node, errp); if (top_bs =3D=3D NULL) { goto out; @@ -2670,7 +2645,7 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, top_node); goto out; } - } else if (has_top && top) { + } else if (top) { /* This strcmp() is just a shortcut, there is no need to * refresh @bs's filename. If it mismatches, * bdrv_find_backing_image() will do the refresh and may still @@ -2687,10 +2662,10 @@ void qmp_block_commit(bool has_job_id, const char *= job_id, const char *device, =20 assert(bdrv_get_aio_context(top_bs) =3D=3D aio_context); =20 - if (has_base_node && has_base) { + if (base_node && base) { error_setg(errp, "'base-node' and 'base' are mutually exclusive"); goto out; - } else if (has_base_node) { + } else if (base_node) { base_bs =3D bdrv_lookup_bs(NULL, base_node, errp); if (base_bs =3D=3D NULL) { goto out; @@ -2700,7 +2675,7 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, base_node); goto out; } - } else if (has_base && base) { + } else if (base) { base_bs =3D bdrv_find_backing_image(top_bs, base); if (base_bs =3D=3D NULL) { error_setg(errp, "Can't find '%s' in the backing chain", base); @@ -2742,7 +2717,7 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, if (top_perm & BLK_PERM_WRITE || bdrv_skip_filters(top_bs) =3D=3D bdrv_skip_filters(bs)) { - if (has_backing_file) { + if (backing_file) { if (bdrv_skip_filters(top_bs) =3D=3D bdrv_skip_filters(bs)) { error_setg(errp, "'backing-file' specified," " but 'top' is the active layer"); @@ -2752,7 +2727,7 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, } goto out; } - if (!has_job_id) { + if (!job_id) { /* * Emulate here what block_job_create() does, because it * is possible that @bs !=3D @top_bs (the block job should @@ -2768,8 +2743,8 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, if (bdrv_op_is_blocked(overlay_bs, BLOCK_OP_TYPE_COMMIT_TARGET, er= rp)) { goto out; } - commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, job_= flags, - speed, on_error, has_backing_file ? backing_file : NU= LL, + commit_start(job_id, bs, base_bs, top_bs, job_flags, + speed, on_error, backing_file, filter_node_name, &local_err); } if (local_err !=3D NULL) { @@ -2802,9 +2777,6 @@ static BlockJob *do_backup_common(BackupCommon *backu= p, if (!backup->has_on_target_error) { backup->on_target_error =3D BLOCKDEV_ON_ERROR_REPORT; } - if (!backup->has_job_id) { - backup->job_id =3D NULL; - } if (!backup->has_auto_finalize) { backup->auto_finalize =3D true; } @@ -2830,7 +2802,7 @@ static BlockJob *do_backup_common(BackupCommon *backu= p, if ((backup->sync =3D=3D MIRROR_SYNC_MODE_BITMAP) || (backup->sync =3D=3D MIRROR_SYNC_MODE_INCREMENTAL)) { /* done before desugaring 'incremental' to print the right message= */ - if (!backup->has_bitmap) { + if (!backup->bitmap) { error_setg(errp, "must provide a valid bitmap name for " "'%s' sync mode", MirrorSyncMode_str(backup->sync)); return NULL; @@ -2851,7 +2823,7 @@ static BlockJob *do_backup_common(BackupCommon *backu= p, backup->bitmap_mode =3D BITMAP_SYNC_MODE_ON_SUCCESS; } =20 - if (backup->has_bitmap) { + if (backup->bitmap) { bmap =3D bdrv_find_dirty_bitmap(bs, backup->bitmap); if (!bmap) { error_setg(errp, "Bitmap '%s' could not be found", backup->bit= map); @@ -2884,7 +2856,7 @@ static BlockJob *do_backup_common(BackupCommon *backu= p, } } =20 - if (!backup->has_bitmap && backup->has_bitmap_mode) { + if (!backup->bitmap && backup->has_bitmap_mode) { error_setg(errp, "Cannot specify bitmap sync mode without a bitmap= "); return NULL; } @@ -2944,7 +2916,7 @@ void qmp_blockdev_backup(BlockdevBackup *backup, Erro= r **errp) **/ static void blockdev_mirror_common(const char *job_id, BlockDriverState *b= s, BlockDriverState *target, - bool has_replaces, const char *replaces, + const char *replaces, enum MirrorSyncMode sync, BlockMirrorBackingMode backing_mode, bool zero_target, @@ -2956,7 +2928,6 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, bool has_on_target_error, BlockdevOnError on_target_error, bool has_unmap, bool unmap, - bool has_filter_node_name, const char *filter_node_name, bool has_copy_mode, MirrorCopyMode copy= _mode, bool has_auto_finalize, bool auto_final= ize, @@ -2984,9 +2955,6 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, if (!has_unmap) { unmap =3D true; } - if (!has_filter_node_name) { - filter_node_name =3D NULL; - } if (!has_copy_mode) { copy_mode =3D MIRROR_COPY_MODE_BACKGROUND; } @@ -3019,16 +2987,15 @@ static void blockdev_mirror_common(const char *job_= id, BlockDriverState *bs, sync =3D MIRROR_SYNC_MODE_FULL; } =20 - if (!has_replaces) { + if (!replaces) { /* We want to mirror from @bs, but keep implicit filters on top */ unfiltered_bs =3D bdrv_skip_implicit_filters(bs); if (unfiltered_bs !=3D bs) { replaces =3D unfiltered_bs->node_name; - has_replaces =3D true; } } =20 - if (has_replaces) { + if (replaces) { BlockDriverState *to_replace_bs; AioContext *replace_aio_context; int64_t bs_size, replace_size; @@ -3065,7 +3032,7 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, * and will allow to check whether the node still exist at mirror comp= letion */ mirror_start(job_id, bs, target, - has_replaces ? replaces : NULL, job_flags, + replaces, job_flags, speed, granularity, buf_size, sync, backing_mode, zero_ta= rget, on_source_error, on_target_error, unmap, filter_node_name, copy_mode, errp); @@ -3103,7 +3070,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) arg->mode =3D NEW_IMAGE_MODE_ABSOLUTE_PATHS; } =20 - if (!arg->has_format) { + if (!arg->format) { format =3D (arg->mode =3D=3D NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name); } @@ -3123,8 +3090,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) goto out; } =20 - if (arg->has_replaces) { - if (!arg->has_node_name) { + if (arg->replaces) { + if (!arg->node_name) { error_setg(errp, "a node-name must be provided when replacing = a" " named node of the graph"); goto out; @@ -3174,7 +3141,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) } =20 options =3D qdict_new(); - if (arg->has_node_name) { + if (arg->node_name) { qdict_put_str(options, "node-name", arg->node_name); } if (format) { @@ -3209,8 +3176,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) aio_context_release(old_context); aio_context_acquire(aio_context); =20 - blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, targe= t_bs, - arg->has_replaces, arg->replaces, arg->sync, + blockdev_mirror_common(arg->job_id, bs, target_bs, + arg->replaces, arg->sync, backing_mode, zero_target, arg->has_speed, arg->speed, arg->has_granularity, arg->granularity, @@ -3218,7 +3185,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) arg->has_on_source_error, arg->on_source_error, arg->has_on_target_error, arg->on_target_error, arg->has_unmap, arg->unmap, - false, NULL, + NULL, arg->has_copy_mode, arg->copy_mode, arg->has_auto_finalize, arg->auto_finalize, arg->has_auto_dismiss, arg->auto_dismiss, @@ -3228,9 +3195,9 @@ out: aio_context_release(aio_context); } =20 -void qmp_blockdev_mirror(bool has_job_id, const char *job_id, +void qmp_blockdev_mirror(const char *job_id, const char *device, const char *target, - bool has_replaces, const char *replaces, + const char *replaces, MirrorSyncMode sync, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, @@ -3239,7 +3206,6 @@ void qmp_blockdev_mirror(bool has_job_id, const char = *job_id, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, - bool has_filter_node_name, const char *filter_node_name, bool has_copy_mode, MirrorCopyMode copy_mode, bool has_auto_finalize, bool auto_finalize, @@ -3280,15 +3246,14 @@ void qmp_blockdev_mirror(bool has_job_id, const cha= r *job_id, goto out; } =20 - blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs, - has_replaces, replaces, sync, backing_mode, + blockdev_mirror_common(job_id, bs, target_bs, + replaces, sync, backing_mode, zero_target, has_speed, speed, has_granularity, granularity, has_buf_size, buf_size, has_on_source_error, on_source_error, has_on_target_error, on_target_error, - true, true, - has_filter_node_name, filter_node_name, + true, true, filter_node_name, has_copy_mode, copy_mode, has_auto_finalize, auto_finalize, has_auto_dismiss, auto_dismiss, @@ -3560,7 +3525,7 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_= list, Error **errp) QDict *qdict; =20 /* Check for the selected node name */ - if (!options->has_node_name) { + if (!options->node_name) { error_setg(errp, "node-name not specified"); goto fail; } @@ -3665,8 +3630,7 @@ static BdrvChild *bdrv_find_child(BlockDriverState *p= arent_bs, return NULL; } =20 -void qmp_x_blockdev_change(const char *parent, bool has_child, - const char *child, bool has_node, +void qmp_x_blockdev_change(const char *parent, const char *child, const char *node, Error **errp) { BlockDriverState *parent_bs, *new_bs =3D NULL; @@ -3677,8 +3641,8 @@ void qmp_x_blockdev_change(const char *parent, bool h= as_child, return; } =20 - if (has_child =3D=3D has_node) { - if (has_child) { + if (!child =3D=3D !node) { + if (child) { error_setg(errp, "The parameters child and node are in conflic= t"); } else { error_setg(errp, "Either child or node must be specified"); @@ -3686,7 +3650,7 @@ void qmp_x_blockdev_change(const char *parent, bool h= as_child, return; } =20 - if (has_child) { + if (child) { p_child =3D bdrv_find_child(parent_bs, child); if (!p_child) { error_setg(errp, "Node '%s' does not have child '%s'", @@ -3696,7 +3660,7 @@ void qmp_x_blockdev_change(const char *parent, bool h= as_child, bdrv_del_child(parent_bs, p_child, errp); } =20 - if (has_node) { + if (node) { new_bs =3D bdrv_find_node(node); if (!new_bs) { error_setg(errp, "Node '%s' not found", node); diff --git a/blockjob.c b/blockjob.c index bdf20a0e35..a5766da220 100644 --- a/blockjob.c +++ b/blockjob.c @@ -343,7 +343,6 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Err= or **errp) info->auto_finalize =3D job->job.auto_finalize; info->auto_dismiss =3D job->job.auto_dismiss; if (job->job.ret) { - info->has_error =3D true; info->error =3D job->job.err ? g_strdup(error_get_pretty(job->job.err)) : g_strdup(strerror(-job->job.ret)); @@ -403,7 +402,6 @@ static void block_job_event_completed_locked(Notifier *= n, void *opaque) progress_total, progress_current, job->speed, - !!msg, msg); } =20 diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index bab86c5537..cdfb804925 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1517,8 +1517,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) } } =20 - qmp_blockdev_change_medium(true, device, false, NULL, target, - !!arg, arg, true, force, + qmp_blockdev_change_medium(device, NULL, target, arg, true, force, !!read_only, read_only_mode, &err); } diff --git a/nbd/server.c b/nbd/server.c index ada16089f3..f25b3032fd 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1653,7 +1653,7 @@ static int nbd_export_create(BlockExport *blk_exp, Bl= ockExportOptions *exp_args, return -EINVAL; } =20 - if (!arg->has_name) { + if (!arg->name) { arg->name =3D exp_args->node_name; } =20 diff --git a/qemu-img.c b/qemu-img.c index ace3adf8ae..92e326ba5c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2915,15 +2915,15 @@ static ImageInfoList *collect_image_info_list(bool = image_opts, image_opts =3D false; =20 if (chain) { - if (info->has_full_backing_filename) { + if (info->full_backing_filename) { filename =3D info->full_backing_filename; - } else if (info->has_backing_filename) { + } else if (info->backing_filename) { error_report("Could not determine absolute backing filenam= e," " but backing filename '%s' present", info->backing_filename); goto err; } - if (info->has_backing_filename_format) { + if (info->backing_filename_format) { fmt =3D info->backing_filename_format; } } @@ -3046,7 +3046,7 @@ static int dump_map_entry(OutputFormat output_format,= MapEntry *e, printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n", e->start, e->length, e->has_offset ? e->offset : 0, - e->has_filename ? e->filename : ""); + e->filename ?: ""); } /* This format ignores the distinction between 0, ZERO and ZERO|DA= TA. * Modify the flags here to allow more coalescing. @@ -3127,7 +3127,6 @@ static int get_block_status(BlockDriverState *bs, int= 64_t offset, .has_offset =3D has_offset, .depth =3D depth, .present =3D !!(ret & BDRV_BLOCK_ALLOCATED), - .has_filename =3D filename, .filename =3D filename, }; =20 @@ -3143,11 +3142,11 @@ static inline bool entry_mergeable(const MapEntry *= curr, const MapEntry *next) curr->data !=3D next->data || curr->depth !=3D next->depth || curr->present !=3D next->present || - curr->has_filename !=3D next->has_filename || + !curr->filename !=3D !next->filename || curr->has_offset !=3D next->has_offset) { return false; } - if (curr->has_filename && strcmp(curr->filename, next->filename)) { + if (curr->filename && strcmp(curr->filename, next->filename)) { return false; } if (curr->has_offset && curr->offset + curr->length !=3D next->offset)= { diff --git a/qemu-nbd.c b/qemu-nbd.c index 0cd5aa6f02..6ff45308a9 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -1107,9 +1107,7 @@ int main(int argc, char **argv) .has_writable =3D true, .writable =3D !readonly, .u.nbd =3D { - .has_name =3D true, .name =3D g_strdup(export_name), - .has_description =3D !!export_description, .description =3D g_strdup(export_description), .has_bitmaps =3D !!bitmaps, .bitmaps =3D bitmaps, diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 8db1c2caef..a205aae1e3 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,9 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/block-core.json', - 'qapi/block-export.json', - 'qapi/block.json', 'qapi/char.json', 'qapi/crypto.json', 'qapi/dump.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075799; cv=none; d=zohomail.com; s=zohoarc; b=KAyKDyNapuMbkq2ZgnJ3IKFTsDEyd1Vp384OEbXOweq2YPIDzsxVGjqjAJsPBJNqO7moBYsJ/7tJ9Hf7wGTFsuvSYm83uoOV2gMAFrnMioz/9XC2uYTQt7oEYZ+aJ/2Sl7VLxwP7smU+MxLAfHn/9sHVESC7LKSGGvcUHxzEY7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075799; 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=L/rJj++W7XOWNYyNZwlaE93QY+K/VjDBIW5R2a2FnuQ=; b=nD2tE1y5edm26AXEwtRMNxyWEFaNGZoJlUVWW3aDiu7VxdkwXNTo5KSfuBRtZBCX+yipDqtqkfvrHapRIXVHj/tMrjcoln6x2xH6r+IA2+ad4uuVywYnScoR3CWLVMRKy9PnWams/kFk1LG6ZAvD6Yzauhk2bKds6rOI2oBlUNw= 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 1666075799267336.15381463158167; Mon, 17 Oct 2022 23:49:59 -0700 (PDT) Received: from localhost ([::1]:56852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQG-0006sN-PY for importer@patchew.org; Tue, 18 Oct 2022 02:49:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6D-0005gX-1U for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg65-0001EX-Iu for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:10 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-fbbzQuDOPMOWFJwPtNcRqQ-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEF3A811E87; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86D762166B41; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3EA5E21E6685; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074533; 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=L/rJj++W7XOWNYyNZwlaE93QY+K/VjDBIW5R2a2FnuQ=; b=S/H6d2/rE9ByrRyc7PpzC0VO+em+wEqdvZz/+RvfNK+Wtm3QXsVXOD/kNC6637XMdZiNH4 lOsvtPrC0FB05qpVcrJy6KT/L5isD/GeyomtggdV/48sWlzuoWRm0Pd5WvQ1MkH1zKTY54 7LpSyE5yHHBLRUtk5r6IhNLSY+WjEFM= X-MC-Unique: fbbzQuDOPMOWFJwPtNcRqQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 09/28] qapi char: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:30 +0200 Message-Id: <20221018062849.3420573-10-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.6 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075801053100002 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 qapi/char.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Marc-Andr=C3=A9 Lureau Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-file.c | 4 ++-- chardev/char-socket.c | 10 ++++------ chardev/char-udp.c | 1 - chardev/char.c | 6 +----- tests/unit/test-char.c | 1 - scripts/qapi/schema.py | 1 - 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/chardev/char-file.c b/chardev/char-file.c index 2fd80707e5..3a7b9caf6f 100644 --- a/chardev/char-file.c +++ b/chardev/char-file.c @@ -45,7 +45,7 @@ static void qmp_chardev_open_file(Chardev *chr, DWORD accessmode; DWORD flags; =20 - if (file->has_in) { + if (file->in) { error_setg(errp, "input file not supported"); return; } @@ -83,7 +83,7 @@ static void qmp_chardev_open_file(Chardev *chr, return; } =20 - if (file->has_in) { + if (file->in) { flags =3D O_RDONLY; in =3D qmp_chardev_open_file_source(file->in, flags, errp); if (in < 0) { diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 879564aa8a..29ffe5075e 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1251,7 +1251,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket= *sock, "'fd' address type"); return false; } - if (sock->has_tls_creds && + if (sock->tls_creds && !(sock->has_server && sock->server)) { error_setg(errp, "'tls_creds' option is incompatible with " @@ -1261,7 +1261,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket= *sock, break; =20 case SOCKET_ADDRESS_TYPE_UNIX: - if (sock->has_tls_creds) { + if (sock->tls_creds) { error_setg(errp, "'tls_creds' option is incompatible with " "'unix' address type"); @@ -1273,7 +1273,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket= *sock, break; =20 case SOCKET_ADDRESS_TYPE_VSOCK: - if (sock->has_tls_creds) { + if (sock->tls_creds) { error_setg(errp, "'tls_creds' option is incompatible with " "'vsock' address type"); @@ -1284,7 +1284,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket= *sock, break; } =20 - if (sock->has_tls_authz && !sock->has_tls_creds) { + if (sock->tls_authz && !sock->tls_creds) { error_setg(errp, "'tls_authz' option requires 'tls_creds' option"); return false; } @@ -1465,9 +1465,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, sock->wait =3D qemu_opt_get_bool(opts, "wait", true); sock->has_reconnect =3D qemu_opt_find(opts, "reconnect"); sock->reconnect =3D qemu_opt_get_number(opts, "reconnect", 0); - sock->has_tls_creds =3D qemu_opt_get(opts, "tls-creds"); sock->tls_creds =3D g_strdup(qemu_opt_get(opts, "tls-creds")); - sock->has_tls_authz =3D qemu_opt_get(opts, "tls-authz"); sock->tls_authz =3D g_strdup(qemu_opt_get(opts, "tls-authz")); =20 addr =3D g_new0(SocketAddressLegacy, 1); diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 6756e69924..3d9a2d5e77 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -178,7 +178,6 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevB= ackend *backend, udp->remote =3D addr; =20 if (has_local) { - udp->has_local =3D true; addr =3D g_new0(SocketAddressLegacy, 1); addr->type =3D SOCKET_ADDRESS_TYPE_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); diff --git a/chardev/char.c b/chardev/char.c index b005df3ccf..4c5de16402 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -240,7 +240,7 @@ static void qemu_char_open(Chardev *chr, ChardevBackend= *backend, /* Any ChardevCommon member would work */ ChardevCommon *common =3D backend ? backend->u.null.data : NULL; =20 - if (common && common->has_logfile) { + if (common && common->logfile) { int flags =3D O_WRONLY; if (common->has_logappend && common->logappend) { @@ -496,9 +496,7 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommo= n *backend) { const char *logfile =3D qemu_opt_get(opts, "logfile"); =20 - backend->has_logfile =3D logfile !=3D NULL; backend->logfile =3D g_strdup(logfile); - backend->has_logappend =3D true; backend->logappend =3D qemu_opt_get_bool(opts, "logappend", false); } @@ -1057,7 +1055,6 @@ ChardevReturn *qmp_chardev_add(const char *id, Charde= vBackend *backend, ret =3D g_new0(ChardevReturn, 1); if (CHARDEV_IS_PTY(chr)) { ret->pty =3D g_strdup(chr->filename + 4); - ret->has_pty =3D true; } =20 return ret; @@ -1160,7 +1157,6 @@ ChardevReturn *qmp_chardev_change(const char *id, Cha= rdevBackend *backend, ret =3D g_new0(ChardevReturn, 1); if (CHARDEV_IS_PTY(chr_new)) { ret->pty =3D g_strdup(chr_new->filename + 4); - ret->has_pty =3D true; } =20 return ret; diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c index 5b3b48ebac..649fdf64e1 100644 --- a/tests/unit/test-char.c +++ b/tests/unit/test-char.c @@ -1212,7 +1212,6 @@ static void char_file_fifo_test(void) char *fifo =3D g_build_filename(tmp_path, "fifo", NULL); char *out =3D g_build_filename(tmp_path, "out", NULL); ChardevFile file =3D { .in =3D fifo, - .has_in =3D true, .out =3D out }; ChardevBackend backend =3D { .type =3D CHARDEV_BACKEND_KIND_FILE, .u.file.data =3D &file }; diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a205aae1e3..707c671133 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/char.json', 'qapi/crypto.json', 'qapi/dump.json', 'qapi/job.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075812; cv=none; d=zohomail.com; s=zohoarc; b=DLWQc2LltIpaBd3nNMUVXyVMZF2i8P9QzRO4fRpmaGmlkcgwyq52xx1bEkdVIOpXvmKrWFyokB73xsA81hg3e1dapj3ExHov20hYNWp/I8sCHp879ge0cLcI3UI0zjtcR7CiNatHIpf11SWx3WPdwJEChaAzBG7Q5uTIFjblRGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075812; 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=oMtVftS2fo3OZSvNZd5ws830B1BwQXfiNs87FTXENQU=; b=EndahdLPlZn8DC+KIBKw8KFfXFio95IJyTnFllL7y8PV3gXjQzmUV3AxiSJ96cCXEnV72wY6WaTquEKJIi05eImgKVT7HbKA5kXI+PqYfs6hi3YZtRBJV5SDt2/5V6vjG9wGKsHHyzHbmyi0FaL+F4T8QSH5ZtWfalPiLUzWPNE= 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 1666075812058270.8301411382747; Mon, 17 Oct 2022 23:50:12 -0700 (PDT) Received: from localhost ([::1]:49226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQU-0007bP-Hh for importer@patchew.org; Tue, 18 Oct 2022 02:50:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6D-0005gY-3V for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg64-0001FN-JE for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:09 -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-657-i7thtupgNT-iSWfc_ao4Cg-1; Tue, 18 Oct 2022 02:28:52 -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 C96801C0879F; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A0054081B92; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 40D4121E668A; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074535; 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=oMtVftS2fo3OZSvNZd5ws830B1BwQXfiNs87FTXENQU=; b=hKVwyoRG4TssSOC6KJPV4/0hN8amDJd/Wdg8iiEfJf17lyXSvhCGRqf1gTD9LyTNBl/DW/ 1VLS1vWIlsMrOI5YQMTG6rZiGZAmlYZ7T1hCmn3eqSo9WZofeIXo6hOnn30w0zEConpbZa xCf8wScaPCEwZv6i0osSOCF3LjWaP18= X-MC-Unique: i7thtupgNT-iSWfc_ao4Cg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 10/28] qapi crypto: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:31 +0200 Message-Id: <20221018062849.3420573-11-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075813141100001 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 qapi/crypto.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Daniel P. Berrang=C3=A9" Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- crypto/block-luks.c | 16 ++++++++-------- tests/unit/test-crypto-block.c | 6 ------ scripts/qapi/schema.py | 1 - 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/crypto/block-luks.c b/crypto/block-luks.c index f62be6836b..4205bc491e 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -1629,13 +1629,13 @@ qcrypto_block_luks_amend_add_keyslot(QCryptoBlock *= block, g_autofree char *new_password =3D NULL; g_autofree uint8_t *master_key =3D NULL; =20 - char *secret =3D opts_luks->has_secret ? opts_luks->secret : luks->sec= ret; + char *secret =3D opts_luks->secret ?: luks->secret; =20 - if (!opts_luks->has_new_secret) { + if (!opts_luks->new_secret) { error_setg(errp, "'new-secret' is required to activate a keyslot"); return -1; } - if (opts_luks->has_old_secret) { + if (opts_luks->old_secret) { error_setg(errp, "'old-secret' must not be given when activating keyslot= s"); return -1; @@ -1709,7 +1709,7 @@ qcrypto_block_luks_amend_erase_keyslots(QCryptoBlock = *block, g_autofree uint8_t *tmpkey =3D NULL; g_autofree char *old_password =3D NULL; =20 - if (opts_luks->has_new_secret) { + if (opts_luks->new_secret) { error_setg(errp, "'new-secret' must not be given when erasing keyslots"); return -1; @@ -1719,14 +1719,14 @@ qcrypto_block_luks_amend_erase_keyslots(QCryptoBloc= k *block, "'iter-time' must not be given when erasing keyslots"); return -1; } - if (opts_luks->has_secret) { + if (opts_luks->secret) { error_setg(errp, "'secret' must not be given when erasing keyslots"); return -1; } =20 /* Load the old password if given */ - if (opts_luks->has_old_secret) { + if (opts_luks->old_secret) { old_password =3D qcrypto_secret_lookup_as_utf8(opts_luks->old_secr= et, errp); if (!old_password) { @@ -1751,7 +1751,7 @@ qcrypto_block_luks_amend_erase_keyslots(QCryptoBlock = *block, return -1; } =20 - if (opts_luks->has_old_secret) { + if (opts_luks->old_secret) { int rv =3D qcrypto_block_luks_load_key(block, keyslot, old_password, @@ -1793,7 +1793,7 @@ qcrypto_block_luks_amend_erase_keyslots(QCryptoBlock = *block, } =20 /* Erase all keyslots that match the given old password */ - } else if (opts_luks->has_old_secret) { + } else if (opts_luks->old_secret) { =20 unsigned long slots_to_erase_bitmap =3D 0; size_t i; diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 3417b67be5..6bef471afb 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -39,7 +39,6 @@ static QCryptoBlockCreateOptions qcow_create_opts =3D { .format =3D Q_CRYPTO_BLOCK_FORMAT_QCOW, .u.qcow =3D { - .has_key_secret =3D true, .key_secret =3D (char *)"sec0", }, }; @@ -47,7 +46,6 @@ static QCryptoBlockCreateOptions qcow_create_opts =3D { static QCryptoBlockOpenOptions qcow_open_opts =3D { .format =3D Q_CRYPTO_BLOCK_FORMAT_QCOW, .u.qcow =3D { - .has_key_secret =3D true, .key_secret =3D (char *)"sec0", }, }; @@ -57,7 +55,6 @@ static QCryptoBlockOpenOptions qcow_open_opts =3D { static QCryptoBlockOpenOptions luks_open_opts =3D { .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { - .has_key_secret =3D true, .key_secret =3D (char *)"sec0", }, }; @@ -67,7 +64,6 @@ static QCryptoBlockOpenOptions luks_open_opts =3D { static QCryptoBlockCreateOptions luks_create_opts_default =3D { .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { - .has_key_secret =3D true, .key_secret =3D (char *)"sec0", }, }; @@ -77,7 +73,6 @@ static QCryptoBlockCreateOptions luks_create_opts_default= =3D { static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 =3D { .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { - .has_key_secret =3D true, .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, @@ -92,7 +87,6 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv =3D { .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { - .has_key_secret =3D true, .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 707c671133..21d0b28790 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/crypto.json', 'qapi/dump.json', 'qapi/job.json', 'qapi/machine.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077985; cv=none; d=zohomail.com; s=zohoarc; b=XdsUIqH9vvrkHEgyzslyaOWDF/Ku5RgqxH0mpVK04gUt9oVzw+4KiAmOBQ10f6GtjUuRpHXtnfd0mlCtTEveKDdizCCkkZbw13Pm8PspTiCZLfcPb4Kn0WbplkKigv4lttPd2sNctzERsaRc5O0vg4hBOAJueLAN7TZwiazxaGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077985; 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=0E5hr9rhYA7n1mvGi0I1IN6V3RIF46oyr7ifz0WlrP8=; b=BY5sK61wQaTeWGqM9vsYuskYwKfAqBzwXccaOpti7H8d6sN4VWdaW+Jb12x1semrk0r8k1wJNcGlS7JwIcrLv/sZlPgcImCJfBsaMTAS31LREc2662x9msKJFyuJjCytX4v73+skPVCwOli8Ogr8QRbvhV4e/9te7yp8SK6lXYs= 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 1666077985944872.3079723268454; Tue, 18 Oct 2022 00:26:25 -0700 (PDT) Received: from localhost ([::1]:50172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgzY-0004Ga-FG for importer@patchew.org; Tue, 18 Oct 2022 03:26:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okgBw-0005iZ-HZ for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:35:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okgBs-00024F-Nr for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:35:07 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-rMvjEPqfPKS9okTkngD95Q-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C518F800186; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CACF1468208; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 42F4921E669D; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074902; 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=0E5hr9rhYA7n1mvGi0I1IN6V3RIF46oyr7ifz0WlrP8=; b=WpIN4hmKMDEl/F3oolJ0KeLZdYTk8jJZWTicEEoaqOtuUPfnsm3VpsPUqMHkv8198xkHz8 h6CDmcRac/6VVzYQGzTlB5offdLMEggqO8PhLarv+fhyzBpieHpLn5Z2U8DHJ4KxUAPuTz SN19Dzr0JwNpPphHFhgGF+VQIOfz0ao= X-MC-Unique: rMvjEPqfPKS9okTkngD95Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 11/28] qapi dump: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:32 +0200 Message-Id: <20221018062849.3420573-12-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.7 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077986275100001 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 qapi/dump.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Markus Armbruster --- dump/dump.c | 4 ++-- scripts/qapi/schema.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 236559b03a..3baf625967 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -1884,8 +1884,8 @@ static void dump_process(DumpState *s, Error **errp) result =3D qmp_query_dump(NULL); /* should never fail */ assert(result); - qapi_event_send_dump_completed(result, !!*errp, (*errp ? - error_get_pretty(*err= p) : NULL)); + qapi_event_send_dump_completed(result, + *errp ? error_get_pretty(*errp) : NULL); qapi_free_DumpQueryResult(result); =20 dump_cleanup(s); diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 21d0b28790..07e2a0f263 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/dump.json', 'qapi/job.json', 'qapi/machine.json', 'qapi/machine-target.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075856; cv=none; d=zohomail.com; s=zohoarc; b=Tu7iKJzUJjbO6/pjqFcQZK1EMVdp+yRiL88gedtEYdZfNvvPsWnUFb8qmDwQlwGEZOSvwyeN+oe+PAtADGWwedZegvr3xTmD0tYSFXxegLciOgewUv0HhNFCyawd8eHh2I1p8CJE8egMrEfNOa/jb+x2qtSOL6jZXWeTQb8/RCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075856; 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=ahYzZHNGM8Cvohvllup/AO20TUJYHk6tF4byX5Qn49U=; b=JgVpzpwaM3ncvHCPV0ehFclSFl8nBbj7GjUEQs9ZSgI5kIMn1HsOfwU4jJOV20o2E3PTYOX7AsN7OR9mF8L6wiyAZULCRHFy97xE5aJo+ghse4P3vwUa1lIo64uVQ/HWnsZP7mbkRV0//YKyGt4aXG0eke3pCleWU+AdD6+Ob3o= 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 1666075856433892.8210338027021; Mon, 17 Oct 2022 23:50:56 -0700 (PDT) Received: from localhost ([::1]:49292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQi-0007me-1I for importer@patchew.org; Tue, 18 Oct 2022 02:50:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6L-0005k0-G9 for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0001FF-FC for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:20 -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-657-WGsg4Jw6N9C3_8cGfd0xUQ-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B92E1C087A1; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DC71492B0E; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4520121E66A0; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074535; 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=ahYzZHNGM8Cvohvllup/AO20TUJYHk6tF4byX5Qn49U=; b=a3agFyA7O0XxtXHZSKkluh8caBq4d0+q9yXvjBfl+d6Cmp3zkfjWEyWXIxcqYKnm82ruU7 uDqv5FWb0dX9U1fN20RHngXScRE4GagwNRoZuOUh/Y1OlR7ybShRpGyN8N8OUSz+VkBbpF rCxg+w80Qa5YjKKV9Le/CCu15M6u2r8= X-MC-Unique: WGsg4Jw6N9C3_8cGfd0xUQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org Subject: [PATCH v2 12/28] qapi job: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:33 +0200 Message-Id: <20221018062849.3420573-13-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075857878100001 Content-Type: text/plain; charset="utf-8" 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 qapi/job.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: John Snow Cc: Vladimir Sementsov-Ogievskiy Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- job-qmp.c | 3 +-- scripts/qapi/schema.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/job-qmp.c b/job-qmp.c index d498fc89c0..9e26fa899f 100644 --- a/job-qmp.c +++ b/job-qmp.c @@ -156,8 +156,7 @@ static JobInfo *job_query_single_locked(Job *job, Error= **errp) .status =3D job->status, .current_progress =3D progress_current, .total_progress =3D progress_total, - .has_error =3D !!job->err, - .error =3D job->err ? \ + .error =3D job->err ? g_strdup(error_get_pretty(job->err)) : NULL, }; =20 diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 07e2a0f263..ff73fdb0b3 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/job.json', 'qapi/machine.json', 'qapi/machine-target.json', 'qapi/migration.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075811; cv=none; d=zohomail.com; s=zohoarc; b=RoPyQnuQFB+/p+INkIWkXgp2fm5YvfxRL69hWWjGpFJfXLL1Ms8xLXIcttV6raXJFRNs7SP67tLACBirJHMP/uvCXAeK2VNEn4lRnThvX4GsrT/l9GbiV4g+9u0WRA4dT7ONVZSYw1q45MmOv1TmjhMiFWOaAbkyxuiLwme+WSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075811; 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=7XY5yGnycfFARtP2NgY4P+Am2k1FCIZDx8uqYADORbo=; b=VYKpXflI4MGpEXMKmseV79Dd1DW3SgfsWh8b5qj2EYo2ezWoyc8A3va4x/CDWGbUR5/Lc/0nDWDGg62jgXPLRSLLSf94giscbuTuYgKIwaYiVz22QbcEd0Jev7TIbaSKct3uIe3UHtVmng7aYGt3TLfJMo8AJR28vmi2KNbnsbE= 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 1666075811500616.6839070381548; Mon, 17 Oct 2022 23:50:11 -0700 (PDT) Received: from localhost ([::1]:49260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQT-0007gr-GB for importer@patchew.org; Tue, 18 Oct 2022 02:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6D-0005gg-93 for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg65-0001FV-IT for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:12 -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-480-7IoA_ruANjK6FQkpkiVlOg-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA04F29AB45F; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F37240C206B; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 478C121E660E; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074535; 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=7XY5yGnycfFARtP2NgY4P+Am2k1FCIZDx8uqYADORbo=; b=e0m8fr9QoSvJV1aYbsgVgM/4WBsK6RfHKSW73JB6Droax4ybUQfKLJiWiiqdiXifIAI0qe gj0SI5y/32PC69cPdnQD0tswG7fApemM2bj0cDQ4otHi+jAd/qQfAuvaZwjhFnPuv6Uwwr Ya0oNGWpQnlMxTA8gcB3MS7KMTEDF7I= X-MC-Unique: 7IoA_ruANjK6FQkpkiVlOg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang Subject: [PATCH v2 13/28] qapi machine: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:34 +0200 Message-Id: <20221018062849.3420573-14-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.1 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075813246100005 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 qapi/machine*.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Philippe Mathieu-Daud=C3=A9 Cc: Yanan Wang Signed-off-by: Markus Armbruster --- hw/core/machine-hmp-cmds.c | 2 +- hw/core/machine-qmp-cmds.c | 9 ++------- hw/core/machine.c | 10 ++++------ hw/core/numa.c | 8 ++++---- hw/mem/pc-dimm.c | 1 - hw/nvram/fw_cfg.c | 2 +- hw/virtio/virtio-mem-pci.c | 4 +--- hw/virtio/virtio-pmem-pci.c | 1 - target/arm/monitor.c | 1 - target/i386/cpu-sysemu.c | 7 ++----- target/i386/cpu.c | 1 - target/s390x/cpu_models_sysemu.c | 1 - scripts/qapi/schema.py | 2 -- 13 files changed, 15 insertions(+), 34 deletions(-) diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index 5cb5eecbfc..a1a51e9778 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -62,7 +62,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdi= ct) monitor_printf(mon, " type: \"%s\"\n", l->value->type); monitor_printf(mon, " vcpus_count: \"%" PRIu64 "\"\n", l->value->vcpus_count); - if (l->value->has_qom_path) { + if (l->value->qom_path) { monitor_printf(mon, " qom_path: \"%s\"\n", l->value->qom_path= ); } =20 diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 4f4ab30f8c..80d5e59651 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -55,8 +55,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); value->thread_id =3D cpu->thread_id; =20 - value->has_props =3D !!mc->cpu_index_to_instance_props; - if (value->has_props) { + if (mc->cpu_index_to_instance_props) { CpuInstanceProperties *props; props =3D g_malloc0(sizeof(*props)); *props =3D mc->cpu_index_to_instance_props(ms, cpu->cpu_index); @@ -90,7 +89,6 @@ MachineInfoList *qmp_query_machines(Error **errp) } =20 if (mc->alias) { - info->has_alias =3D true; info->alias =3D g_strdup(mc->alias); } =20 @@ -101,11 +99,9 @@ MachineInfoList *qmp_query_machines(Error **errp) info->deprecated =3D !!mc->deprecation_reason; if (mc->default_cpu_type) { info->default_cpu_type =3D g_strdup(mc->default_cpu_type); - info->has_default_cpu_type =3D true; } if (mc->default_ram_id) { info->default_ram_id =3D g_strdup(mc->default_ram_id); - info->has_default_ram_id =3D true; } =20 QAPI_LIST_PREPEND(mach_list, info); @@ -168,7 +164,6 @@ static int query_memdev(Object *obj, void *opaque) m =3D g_malloc0(sizeof(*m)); =20 m->id =3D g_strdup(object_get_canonical_path_component(obj)); - m->has_id =3D !!m->id; =20 m->size =3D object_property_get_uint(obj, "size", &error_abort); m->merge =3D object_property_get_bool(obj, "merge", &error_abort); @@ -227,7 +222,7 @@ HumanReadableText *qmp_x_query_numa(Error **errp) for (i =3D 0; i < nb_numa_nodes; i++) { g_string_append_printf(buf, "node %d cpus:", i); for (cpu =3D cpu_list; cpu; cpu =3D cpu->next) { - if (cpu->value->has_props && cpu->value->props->has_node_id && + if (cpu->value->props && cpu->value->props->has_node_id && cpu->value->props->node_id =3D=3D i) { g_string_append_printf(buf, " %" PRIi64, cpu->value->cpu_i= ndex); } diff --git a/hw/core/machine.c b/hw/core/machine.c index aa520e74a8..cf9407d4aa 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -682,7 +682,6 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(Ma= chineState *machine) =20 cpu =3D machine->possible_cpus->cpus[i].cpu; if (cpu) { - cpu_item->has_qom_path =3D true; cpu_item->qom_path =3D object_get_canonical_path(cpu); } QAPI_LIST_PREPEND(head, cpu_item); @@ -871,8 +870,7 @@ static void machine_copy_boot_config(MachineState *ms, = BootConfiguration *config =20 machine_free_boot_config(ms); ms->boot_config =3D *config; - if (!config->has_order) { - ms->boot_config.has_order =3D true; + if (!config->order) { ms->boot_config.order =3D g_strdup(machine_class->default_boot_ord= er); } } @@ -887,13 +885,13 @@ static void machine_set_boot(Object *obj, Visitor *v,= const char *name, if (!visit_type_BootConfiguration(v, name, &config, errp)) { return; } - if (config->has_order) { + if (config->order) { validate_bootdevices(config->order, errp); if (*errp) { goto out_free; } } - if (config->has_once) { + if (config->once) { validate_bootdevices(config->once, errp); if (*errp) { goto out_free; @@ -1424,7 +1422,7 @@ void qdev_machine_creation_done(void) { cpu_synchronize_all_post_init(); =20 - if (current_machine->boot_config.has_once) { + if (current_machine->boot_config.once) { qemu_boot_set(current_machine->boot_config.once, &error_fatal); qemu_register_reset(restore_boot_order, g_strdup(current_machine->= boot_config.order)); } diff --git a/hw/core/numa.c b/hw/core/numa.c index 26d8e5f616..f06328ccbb 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -130,9 +130,9 @@ static void parse_numa_node(MachineState *ms, NumaNodeO= ptions *node, } } =20 - have_memdevs =3D have_memdevs ? : node->has_memdev; - have_mem =3D have_mem ? : node->has_mem; - if ((node->has_mem && have_memdevs) || (node->has_memdev && have_mem))= { + have_memdevs =3D have_memdevs || node->memdev; + have_mem =3D have_mem || node->has_mem; + if ((node->has_mem && have_memdevs) || (node->memdev && have_mem)) { error_setg(errp, "numa configuration should use either mem=3D or m= emdev=3D," "mixing both is not allowed"); return; @@ -152,7 +152,7 @@ static void parse_numa_node(MachineState *ms, NumaNodeO= ptions *node, " use -numa node,memdev instead"); } } - if (node->has_memdev) { + if (node->memdev) { Object *o; o =3D object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, = NULL); if (!o) { diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index f27e1a11ba..50ef83215c 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -252,7 +252,6 @@ static void pc_dimm_md_fill_device_info(const MemoryDev= iceState *md, const DeviceState *dev =3D DEVICE(md); =20 if (dev->id) { - di->has_id =3D true; di->id =3D g_strdup(dev->id); } di->hotplugged =3D dev->hotplugged; diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 6edf5ea3e9..a00881bc64 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -201,7 +201,7 @@ static void fw_cfg_bootsplash(FWCfgState *s) } =20 /* insert splash file if user configurated */ - if (current_machine->boot_config.has_splash) { + if (current_machine->boot_config.splash) { const char *boot_splash_filename =3D current_machine->boot_config.= splash; filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filen= ame); if (filename =3D=3D NULL) { diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index 5c5c1e3ae3..e8c338c5d9 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -65,7 +65,6 @@ static void virtio_mem_pci_fill_device_info(const MemoryD= eviceState *md, DeviceState *dev =3D DEVICE(md); =20 if (dev->id) { - vi->has_id =3D true; vi->id =3D g_strdup(dev->id); } =20 @@ -90,8 +89,7 @@ static void virtio_mem_pci_size_change_notify(Notifier *n= otifier, void *data) char *qom_path =3D object_get_canonical_path(OBJECT(dev)); const uint64_t * const size_p =3D data; =20 - qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p, - qom_path); + qapi_event_send_memory_device_size_change(dev->id, *size_p, qom_path); g_free(qom_path); } =20 diff --git a/hw/virtio/virtio-pmem-pci.c b/hw/virtio/virtio-pmem-pci.c index 7d9f4ec189..1b89ade9d1 100644 --- a/hw/virtio/virtio-pmem-pci.c +++ b/hw/virtio/virtio-pmem-pci.c @@ -70,7 +70,6 @@ static void virtio_pmem_pci_fill_device_info(const Memory= DeviceState *md, DeviceState *dev =3D DEVICE(md); =20 if (dev->id) { - vi->has_id =3D true; vi->id =3D g_strdup(dev->id); } =20 diff --git a/target/arm/monitor.c b/target/arm/monitor.c index 80c64fa355..ecdd5ee817 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -221,7 +221,6 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(Cp= uModelExpansionType type, qobject_unref(qdict_out); } else { expansion_info->model->props =3D QOBJECT(qdict_out); - expansion_info->model->has_props =3D true; } =20 object_unref(obj); diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c index a6f47b7d11..fc97213a73 100644 --- a/target/i386/cpu-sysemu.c +++ b/target/i386/cpu-sysemu.c @@ -187,10 +187,8 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType ty= pe, QDict *props =3D NULL; const char *base_name; =20 - xc =3D x86_cpu_from_model(model->name, - model->has_props ? - qobject_to(QDict, model->props) : - NULL, &err); + xc =3D x86_cpu_from_model(model->name, qobject_to(QDict, model->props), + &err); if (err) { goto out; } @@ -198,7 +196,6 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType typ= e, props =3D qdict_new(); ret->model =3D g_new0(CpuModelInfo, 1); ret->model->props =3D QOBJECT(props); - ret->model->has_props =3D true; =20 switch (type) { case CPU_MODEL_EXPANSION_TYPE_STATIC: diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 8a11470507..a5975d9992 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4901,7 +4901,6 @@ static void x86_cpu_definition_entry(gpointer data, g= pointer user_data) */ if (default_cpu_version !=3D CPU_VERSION_LEGACY) { info->alias_of =3D x86_cpu_class_get_alias_of(cc); - info->has_alias_of =3D !!info->alias_of; } =20 QAPI_LIST_PREPEND(*cpu_list, info); diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sys= emu.c index d8a141a023..63981bf36b 100644 --- a/target/s390x/cpu_models_sysemu.c +++ b/target/s390x/cpu_models_sysemu.c @@ -210,7 +210,6 @@ static void cpu_info_from_model(CpuModelInfo *info, con= st S390CPUModel *model, qobject_unref(qdict); } else { info->props =3D QOBJECT(qdict); - info->has_props =3D true; } } =20 diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index ff73fdb0b3..9d729468b5 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,8 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/machine.json', - 'qapi/machine-target.json', 'qapi/migration.json', 'qapi/misc.json', 'qapi/net.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075800; cv=none; d=zohomail.com; s=zohoarc; b=e2+lA/h2UcvcF/U1IHWZTujCCcfPHJHauYQqc5DOfhKlFFNz9qIgSOlQO1Sy2tKvmRZ2WdXAUQfR4kBfsguW/6iJT0Wdd60booLkybDaWjFaMmRV+7sSEPxcWRd7KO70vHV6E1CEVYe8fo1AtkCjj/1z3JjekgjK/wHegyE37CI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075800; 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=HecHKwM1KVV0Ncbec0gGJUx2Q7/jUxLusYA5/WFDJHc=; b=b7CWS3uk8Am/v2QGWNN8oVArE1YHo1H47zbnrT/f5yp3MQE8K5Qc91hWbLxhXMhP3iBKyHCy9gcjMxppnBuV+5g3tci+JVPPDZc1HgUjHw3V+7BEg3sbRmdHXpHunWOrB09NaD+9awLvLXUOdc3XWnDvJKya86ZBWE9XFHxvnEk= 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 1666075800266832.8455593246282; Mon, 17 Oct 2022 23:50:00 -0700 (PDT) Received: from localhost ([::1]:58878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQI-0006wF-L3 for importer@patchew.org; Tue, 18 Oct 2022 02:49:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6D-0005gc-94 for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg64-0001Ed-JS for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:08 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-256-i6kDdsDJNiaP1ypugPJTiQ-1; Tue, 18 Oct 2022 02:28:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6789810BDD; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2290111DCE3; Tue, 18 Oct 2022 06:28:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 49F5E21E660F; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=HecHKwM1KVV0Ncbec0gGJUx2Q7/jUxLusYA5/WFDJHc=; b=iuxahXXrpffF8EGNAyymsx0oG7fxJVErdP+UpcJsMExHtlyCxuOR6b1+f48cc8bT4u9Bpz LaU3nUYD/3C0S3sR+DhfKEquPgBlj4g3hq2DQYJOwJZinVcu17lM0QzMknCTBP33nMg/an oNpJ8W3pnQDTosbvG3twrPeHw6JujaA= X-MC-Unique: i6kDdsDJNiaP1ypugPJTiQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Juan Quintela , "Dr . David Alan Gilbert" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 14/28] qapi migration: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:35 +0200 Message-Id: <20221018062849.3420573-15-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.3 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075801082100004 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 qapi/migration.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Juan Quintela Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/block-dirty-bitmap.c | 4 ++-- migration/colo.c | 1 - migration/migration.c | 27 ++++++++------------------- monitor/hmp-cmds.c | 26 +++++++++++--------------- monitor/misc.c | 2 +- scripts/qapi/schema.py | 1 - 6 files changed, 22 insertions(+), 39 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 9aba7d9c22..283017d7d3 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -551,7 +551,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, } =20 bitmap_alias =3D bmap_inner->alias; - if (bmap_inner->has_transform) { + if (bmap_inner->transform) { bitmap_transform =3D bmap_inner->transform; } } else { @@ -821,7 +821,7 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoad= State *s) } =20 if (s->bmap_inner && - s->bmap_inner->has_transform && + s->bmap_inner->transform && s->bmap_inner->transform->has_persistent) { persistent =3D s->bmap_inner->transform->persistent; } else { diff --git a/migration/colo.c b/migration/colo.c index 2b71722fd6..232c8d44b1 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -250,7 +250,6 @@ ReplicationStatus *qmp_query_xen_replication_status(Err= or **errp) replication_get_error_all(&err); if (err) { s->error =3D true; - s->has_desc =3D true; s->desc =3D g_strdup(error_get_pretty(err)); } else { s->error =3D false; diff --git a/migration/migration.c b/migration/migration.c index 739bb683f3..4c8a0403ae 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -918,11 +918,8 @@ MigrationParameters *qmp_query_migrate_parameters(Erro= r **errp) params->cpu_throttle_increment =3D s->parameters.cpu_throttle_incremen= t; params->has_cpu_throttle_tailslow =3D true; params->cpu_throttle_tailslow =3D s->parameters.cpu_throttle_tailslow; - params->has_tls_creds =3D true; params->tls_creds =3D g_strdup(s->parameters.tls_creds); - params->has_tls_hostname =3D true; params->tls_hostname =3D g_strdup(s->parameters.tls_hostname); - params->has_tls_authz =3D true; params->tls_authz =3D g_strdup(s->parameters.tls_authz ? s->parameters.tls_authz : ""); params->has_max_bandwidth =3D true; @@ -1047,7 +1044,6 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) { size_t page_size =3D qemu_target_page_size(); =20 - info->has_ram =3D true; info->ram =3D g_malloc0(sizeof(*info->ram)); info->ram->transferred =3D ram_counters.transferred; info->ram->total =3D ram_bytes_total(); @@ -1069,7 +1065,6 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram->postcopy_bytes =3D ram_counters.postcopy_bytes; =20 if (migrate_use_xbzrle()) { - info->has_xbzrle_cache =3D true; info->xbzrle_cache =3D g_malloc0(sizeof(*info->xbzrle_cache)); info->xbzrle_cache->cache_size =3D migrate_xbzrle_cache_size(); info->xbzrle_cache->bytes =3D xbzrle_counters.bytes; @@ -1081,7 +1076,6 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) } =20 if (migrate_use_compression()) { - info->has_compression =3D true; info->compression =3D g_malloc0(sizeof(*info->compression)); info->compression->pages =3D compression_counters.pages; info->compression->busy =3D compression_counters.busy; @@ -1106,7 +1100,6 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) static void populate_disk_info(MigrationInfo *info) { if (blk_mig_active()) { - info->has_disk =3D true; info->disk =3D g_malloc0(sizeof(*info->disk)); info->disk->transferred =3D blk_mig_bytes_transferred(); info->disk->remaining =3D blk_mig_bytes_remaining(); @@ -1171,7 +1164,6 @@ static void fill_source_migration_info(MigrationInfo = *info) case MIGRATION_STATUS_FAILED: info->has_status =3D true; if (s->error) { - info->has_error_desc =3D true; info->error_desc =3D g_strdup(error_get_pretty(s->error)); } break; @@ -1557,7 +1549,7 @@ static bool migrate_params_check(MigrationParameters = *params, Error **errp) #ifdef CONFIG_LINUX if (migrate_use_zero_copy_send() && ((params->has_multifd_compression && params->multifd_compression) = || - (params->has_tls_creds && params->tls_creds && *params->tls_creds= ))) { + (params->tls_creds && *params->tls_creds))) { error_setg(errp, "Zero copy only available for non-compressed non-TLS mu= ltifd migration"); return false; @@ -1606,12 +1598,12 @@ static void migrate_params_test_apply(MigrateSetPar= ameters *params, dest->cpu_throttle_tailslow =3D params->cpu_throttle_tailslow; } =20 - if (params->has_tls_creds) { + if (params->tls_creds) { assert(params->tls_creds->type =3D=3D QTYPE_QSTRING); dest->tls_creds =3D params->tls_creds->u.s; } =20 - if (params->has_tls_hostname) { + if (params->tls_hostname) { assert(params->tls_hostname->type =3D=3D QTYPE_QSTRING); dest->tls_hostname =3D params->tls_hostname->u.s; } @@ -1703,19 +1695,19 @@ static void migrate_params_apply(MigrateSetParamete= rs *params, Error **errp) s->parameters.cpu_throttle_tailslow =3D params->cpu_throttle_tails= low; } =20 - if (params->has_tls_creds) { + if (params->tls_creds) { g_free(s->parameters.tls_creds); assert(params->tls_creds->type =3D=3D QTYPE_QSTRING); s->parameters.tls_creds =3D g_strdup(params->tls_creds->u.s); } =20 - if (params->has_tls_hostname) { + if (params->tls_hostname) { g_free(s->parameters.tls_hostname); assert(params->tls_hostname->type =3D=3D QTYPE_QSTRING); s->parameters.tls_hostname =3D g_strdup(params->tls_hostname->u.s); } =20 - if (params->has_tls_authz) { + if (params->tls_authz) { g_free(s->parameters.tls_authz); assert(params->tls_authz->type =3D=3D QTYPE_QSTRING); s->parameters.tls_authz =3D g_strdup(params->tls_authz->u.s); @@ -1792,14 +1784,14 @@ void qmp_migrate_set_parameters(MigrateSetParameter= s *params, Error **errp) MigrationParameters tmp; =20 /* TODO Rewrite "" to null instead */ - if (params->has_tls_creds + if (params->tls_creds && params->tls_creds->type =3D=3D QTYPE_QNULL) { qobject_unref(params->tls_creds->u.n); params->tls_creds->type =3D QTYPE_QSTRING; params->tls_creds->u.s =3D strdup(""); } /* TODO Rewrite "" to null instead */ - if (params->has_tls_hostname + if (params->tls_hostname && params->tls_hostname->type =3D=3D QTYPE_QNULL) { qobject_unref(params->tls_hostname->u.n); params->tls_hostname->type =3D QTYPE_QSTRING; @@ -4474,9 +4466,6 @@ static void migration_instance_init(Object *obj) params->has_announce_max =3D true; params->has_announce_rounds =3D true; params->has_announce_step =3D true; - params->has_tls_creds =3D true; - params->has_tls_hostname =3D true; - params->has_tls_authz =3D true; =20 qemu_sem_init(&ms->postcopy_pause_sem, 0); qemu_sem_init(&ms->postcopy_pause_rp_sem, 0); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index cdfb804925..8077ed82c9 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -240,8 +240,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) if (info->has_status) { monitor_printf(mon, "Migration status: %s", MigrationStatus_str(info->status)); - if (info->status =3D=3D MIGRATION_STATUS_FAILED && - info->has_error_desc) { + if (info->status =3D=3D MIGRATION_STATUS_FAILED && info->error_des= c) { monitor_printf(mon, " (%s)\n", info->error_desc); } else { monitor_printf(mon, "\n"); @@ -263,7 +262,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) } } =20 - if (info->has_ram) { + if (info->ram) { monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", info->ram->transferred >> 10); monitor_printf(mon, "throughput: %0.2f mbps\n", @@ -316,7 +315,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) } } =20 - if (info->has_disk) { + if (info->disk) { monitor_printf(mon, "transferred disk: %" PRIu64 " kbytes\n", info->disk->transferred >> 10); monitor_printf(mon, "remaining disk: %" PRIu64 " kbytes\n", @@ -325,7 +324,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->disk->total >> 10); } =20 - if (info->has_xbzrle_cache) { + if (info->xbzrle_cache) { monitor_printf(mon, "cache size: %" PRIu64 " bytes\n", info->xbzrle_cache->cache_size); monitor_printf(mon, "xbzrle transferred: %" PRIu64 " kbytes\n", @@ -342,7 +341,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->xbzrle_cache->overflow); } =20 - if (info->has_compression) { + if (info->compression) { monitor_printf(mon, "compression pages: %" PRIu64 " pages\n", info->compression->pages); monitor_printf(mon, "compression busy: %" PRIu64 "\n", @@ -389,7 +388,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) monitor_printf(mon, "]\n"); } =20 - if (info->has_vfio) { + if (info->vfio) { monitor_printf(mon, "vfio device transferred: %" PRIu64 " kbytes\n= ", info->vfio->transferred >> 10); } @@ -469,11 +468,11 @@ void hmp_info_migrate_parameters(Monitor *mon, const = QDict *qdict) monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE), params->max_cpu_throttle); - assert(params->has_tls_creds); + assert(params->tls_creds); monitor_printf(mon, "%s: '%s'\n", MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS), params->tls_creds); - assert(params->has_tls_hostname); + assert(params->tls_hostname); monitor_printf(mon, "%s: '%s'\n", MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME), params->tls_hostname); @@ -1258,19 +1257,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const = QDict *qdict) visit_type_uint8(v, param, &p->max_cpu_throttle, &err); break; case MIGRATION_PARAMETER_TLS_CREDS: - p->has_tls_creds =3D true; p->tls_creds =3D g_new0(StrOrNull, 1); p->tls_creds->type =3D QTYPE_QSTRING; visit_type_str(v, param, &p->tls_creds->u.s, &err); break; case MIGRATION_PARAMETER_TLS_HOSTNAME: - p->has_tls_hostname =3D true; p->tls_hostname =3D g_new0(StrOrNull, 1); p->tls_hostname->type =3D QTYPE_QSTRING; visit_type_str(v, param, &p->tls_hostname->u.s, &err); break; case MIGRATION_PARAMETER_TLS_AUTHZ: - p->has_tls_authz =3D true; p->tls_authz =3D g_new0(StrOrNull, 1); p->tls_authz->type =3D QTYPE_QSTRING; visit_type_str(v, param, &p->tls_authz->u.s, &err); @@ -1382,7 +1378,7 @@ void hmp_client_migrate_info(Monitor *mon, const QDic= t *qdict) =20 qmp_client_migrate_info(protocol, hostname, has_port, port, has_tls_port, tls_port, - !!cert_subject, cert_subject, &err); + cert_subject, &err); hmp_handle_error(mon, err); } =20 @@ -1540,7 +1536,7 @@ static void hmp_migrate_status_cb(void *opaque) info =3D qmp_query_migrate(NULL); if (!info->has_status || info->status =3D=3D MIGRATION_STATUS_ACTIVE || info->status =3D=3D MIGRATION_STATUS_SETUP) { - if (info->has_disk) { + if (info->disk) { int progress; =20 if (info->disk->remaining) { @@ -1558,7 +1554,7 @@ static void hmp_migrate_status_cb(void *opaque) if (status->is_block_migration) { monitor_printf(status->mon, "\n"); } - if (info->has_error_desc) { + if (info->error_desc) { error_report("%s", info->error_desc); } monitor_resume(status->mon); diff --git a/monitor/misc.c b/monitor/misc.c index 6436a8786b..a51f0996cb 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -397,7 +397,7 @@ static void hmp_info_trace_events(Monitor *mon, const Q= Dict *qdict) void qmp_client_migrate_info(const char *protocol, const char *hostname, bool has_port, int64_t port, bool has_tls_port, int64_t tls_port, - bool has_cert_subject, const char *cert_subje= ct, + const char *cert_subject, Error **errp) { if (strcmp(protocol, "spice") =3D=3D 0) { diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 9d729468b5..ad5b665212 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/migration.json', 'qapi/misc.json', 'qapi/net.json', 'qapi/pci.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075804; cv=none; d=zohomail.com; s=zohoarc; b=KUjeSyzZ6eIuQMoVJjwkvimZyAtZ03RKz3OMJjsmaj9eOANpYlV0fK+zCdEqzlj0YswTa4jVu8PrvYaerpDDTExH36wYEwsyOo+JjYq4MfO1fskNxxq9JMCONWb7pofduNyWU6a/4XabcjWdtk/qc+6O9j3lnQyv0EerQM6X3lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075804; 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=EGmqyWJ2Dtvzz9QRbAxVYqJ7oD7IR1AdCJy4OZd7Tuk=; b=HI/WQKpW4JrRo3IN725EsF3uQEU/g2vvs4KbrFamsvSWr9pv5KMtoe7IDA+K7YrxrAm8DDgHCNhm+BPqwLzEwvV8VMhsnH0rV2W/U3Pdl6P0QRCwuxbSpLJzeI/2j5gITQYivMM7nugFqfNRVkv1081V1rNdeln+P8SUkttWEtQ= 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 1666075804425374.395266095426; Mon, 17 Oct 2022 23:50:04 -0700 (PDT) Received: from localhost ([::1]:49232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQK-0007d3-Oy for importer@patchew.org; Tue, 18 Oct 2022 02:50:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0005g7-MI for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34995) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg62-0001F5-Kp for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:06 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-XKKmJ8DmPVGNe6MFB1P1wg-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F12EA185A792; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1C05111DCE3; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4C2BB21E6613; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=EGmqyWJ2Dtvzz9QRbAxVYqJ7oD7IR1AdCJy4OZd7Tuk=; b=grnNnazTkYnM43L74sKMrMkoBHKYSWn4QcQct+033g0J06ginbu4FNyTgRXV9SPg5uJFGr wcgcFWW9ccVswg6uHWwViaJarjhVavsytron2QId6NcLfuKxiIucAzpo55lWy/NLXD0b/7 VI1iVk7M6KUyIxc4I7bU7nq8h5t2YEc= X-MC-Unique: XKKmJ8DmPVGNe6MFB1P1wg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, "Dr . David Alan Gilbert" Subject: [PATCH v2 15/28] qapi misc: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:36 +0200 Message-Id: <20221018062849.3420573-16-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075804979100011 Content-Type: text/plain; charset="utf-8" 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 qapi/misc.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- include/monitor/monitor.h | 3 +-- monitor/hmp-cmds.c | 2 +- monitor/misc.c | 19 +++++-------------- monitor/qmp-cmds.c | 1 - softmmu/vl.c | 2 +- util/qemu-config.c | 17 +++++------------ scripts/qapi/schema.py | 1 - 7 files changed, 13 insertions(+), 32 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 737e750670..1e6f4c9bd7 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -46,8 +46,7 @@ int monitor_read_password(MonitorHMP *mon, ReadLineFunc *= readline_func, void *opaque); =20 AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_i= d, - bool has_opaque, const char *opaque, - Error **errp); + const char *opaque, Error **errp); int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags); void monitor_fdset_dup_fd_remove(int dup_fd); int64_t monitor_fdset_dup_fd_find(int dup_fd); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8077ed82c9..63baf3f8c6 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -104,7 +104,7 @@ void hmp_info_name(Monitor *mon, const QDict *qdict) NameInfo *info; =20 info =3D qmp_query_name(NULL); - if (info->has_name) { + if (info->name) { monitor_printf(mon, "%s\n", info->name); } qapi_free_NameInfo(info); diff --git a/monitor/misc.c b/monitor/misc.c index a51f0996cb..2663007dbc 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1131,7 +1131,7 @@ void monitor_fdsets_cleanup(void) } } =20 -AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque, +AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, const char *opaque, Error **errp) { int fd; @@ -1144,8 +1144,7 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdse= t_id, bool has_opaque, goto error; } =20 - fdinfo =3D monitor_fdset_add_fd(fd, has_fdset_id, fdset_id, - has_opaque, opaque, errp); + fdinfo =3D monitor_fdset_add_fd(fd, has_fdset_id, fdset_id, opaque, er= rp); if (fdinfo) { return fdinfo; } @@ -1213,12 +1212,7 @@ FdsetInfoList *qmp_query_fdsets(Error **errp) =20 fdsetfd_info =3D g_malloc0(sizeof(*fdsetfd_info)); fdsetfd_info->fd =3D mon_fdset_fd->fd; - if (mon_fdset_fd->opaque) { - fdsetfd_info->has_opaque =3D true; - fdsetfd_info->opaque =3D g_strdup(mon_fdset_fd->opaque); - } else { - fdsetfd_info->has_opaque =3D false; - } + fdsetfd_info->opaque =3D g_strdup(mon_fdset_fd->opaque); =20 QAPI_LIST_PREPEND(fdset_info->fds, fdsetfd_info); } @@ -1230,8 +1224,7 @@ FdsetInfoList *qmp_query_fdsets(Error **errp) } =20 AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_i= d, - bool has_opaque, const char *opaque, - Error **errp) + const char *opaque, Error **errp) { MonFdset *mon_fdset =3D NULL; MonFdsetFd *mon_fdset_fd; @@ -1299,9 +1292,7 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdse= t_id, int64_t fdset_id, mon_fdset_fd =3D g_malloc0(sizeof(*mon_fdset_fd)); mon_fdset_fd->fd =3D fd; mon_fdset_fd->removed =3D false; - if (has_opaque) { - mon_fdset_fd->opaque =3D g_strdup(opaque); - } + mon_fdset_fd->opaque =3D g_strdup(opaque); QLIST_INSERT_HEAD(&mon_fdset->fds, mon_fdset_fd, next); =20 fdinfo =3D g_malloc0(sizeof(*fdinfo)); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 81c8fdadf8..2a0c919472 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -51,7 +51,6 @@ NameInfo *qmp_query_name(Error **errp) NameInfo *info =3D g_malloc0(sizeof(*info)); =20 if (qemu_name) { - info->has_name =3D true; info->name =3D g_strdup(qemu_name); } =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index b464da25bc..e044979dfc 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -611,7 +611,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, E= rror **errp) } =20 /* add the duplicate fd, and optionally the opaque string, to the fd s= et */ - fdinfo =3D monitor_fdset_add_fd(dupfd, true, fdset_id, !!fd_opaque, fd= _opaque, + fdinfo =3D monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque, &error_abort); g_free(fdinfo); =20 diff --git a/util/qemu-config.c b/util/qemu-config.c index 5325f6bf80..95f61fc883 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -80,14 +80,8 @@ static CommandLineParameterInfoList *query_option_descs(= const QemuOptDesc *desc) break; } =20 - if (desc[i].help) { - info->has_help =3D true; - info->help =3D g_strdup(desc[i].help); - } - if (desc[i].def_value_str) { - info->has_q_default =3D true; - info->q_default =3D g_strdup(desc[i].def_value_str); - } + info->help =3D g_strdup(desc[i].help); + info->q_default =3D g_strdup(desc[i].def_value_str); =20 QAPI_LIST_PREPEND(param_list, info); } @@ -245,8 +239,7 @@ static QemuOptsList machine_opts =3D { } }; =20 -CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, - const char *opti= on, +CommandLineOptionInfoList *qmp_query_command_line_options(const char *opti= on, Error **errp) { CommandLineOptionInfoList *conf_list =3D NULL; @@ -254,7 +247,7 @@ CommandLineOptionInfoList *qmp_query_command_line_optio= ns(bool has_option, int i; =20 for (i =3D 0; vm_config_groups[i] !=3D NULL; i++) { - if (!has_option || !strcmp(option, vm_config_groups[i]->name)) { + if (!option || !strcmp(option, vm_config_groups[i]->name)) { info =3D g_malloc0(sizeof(*info)); info->option =3D g_strdup(vm_config_groups[i]->name); if (!strcmp("drive", vm_config_groups[i]->name)) { @@ -267,7 +260,7 @@ CommandLineOptionInfoList *qmp_query_command_line_optio= ns(bool has_option, } } =20 - if (!has_option || !strcmp(option, "machine")) { + if (!option || !strcmp(option, "machine")) { info =3D g_malloc0(sizeof(*info)); info->option =3D g_strdup("machine"); info->parameters =3D query_option_descs(machine_opts.desc); diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index ad5b665212..a34e25fdd7 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/misc.json', 'qapi/net.json', 'qapi/pci.json', 'qapi/qdev.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075800; cv=none; d=zohomail.com; s=zohoarc; b=Z60K1uI8OGJc55YafVKopxNZfhq9PAGyNNWEYhAJ1QeZyz+ee98n18cOOg4T3rViKCjILecbv01paXu353QiFwOidAYn38wdqac1YTJfzA4yuaGfNOTUTlOrDecPiOFr6nk3g1PM04wH0fLAbDHXBpsXpzQ+Pfd2DvpLoW7BdUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075800; 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=PIs1hVTZtp5uEzo0ZrIEkj75OGi+AtPidvToEYMUiVI=; b=VSfEOF+bdBPa/aLUmSG9oNp8c9buLlMgt58C/WEBJ7AGhbIUC7iROavPB2ussxJs7MHMrZNt/HUauuCWe/OU8qKXO6vS6hE9gRJsvzzbfDIAGxhSelR5Uz5eJ1oeQKEINERq0R0fGzRwz2DtXbDxve8//vIzSufKuCK/PvLNLwU= 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 1666075800961338.6195226226811; Mon, 17 Oct 2022 23:50:00 -0700 (PDT) Received: from localhost ([::1]:49210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQI-0007L8-DE for importer@patchew.org; Tue, 18 Oct 2022 02:49:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6L-0005jy-Es for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0001Fw-QT for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-BVWikJn4NjGQEiPzpPMsjA-1; Tue, 18 Oct 2022 02:28:53 -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 1D09D8582B9; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4F574081B92; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4E78321E6614; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074536; 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=PIs1hVTZtp5uEzo0ZrIEkj75OGi+AtPidvToEYMUiVI=; b=Nd8huCwotCazJ7IU0h/CfqifPIDnzgW8n/tkW3oJ4PWS8cjIplhjk1GQLZ47XVqYQolq9j ydVrTjCkMTQucYQw3CLvlnYaVgFrrgjnKSZ5JItC+fAvdLJaP0uVuf5uFNdPa+Rgp13UXl Kdq49thUTOQP+dxDdJ0IAqremSkJAm8= X-MC-Unique: BVWikJn4NjGQEiPzpPMsjA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Jason Wang Subject: [PATCH v2 16/28] qapi net: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:37 +0200 Message-Id: <20221018062849.3420573-17-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075803111100009 Content-Type: text/plain; charset="utf-8" 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 qapi/net.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Jason Wang Signed-off-by: Markus Armbruster --- hw/net/virtio-net.c | 3 +-- monitor/hmp-cmds.c | 1 - net/announce.c | 8 +++---- net/hub.c | 2 +- net/l2tpv3.c | 2 +- net/net.c | 25 ++++++++++----------- net/slirp.c | 4 ++-- net/socket.c | 18 +++++++-------- net/tap-win32.c | 2 +- net/tap.c | 51 +++++++++++++++++++++--------------------- scripts/qapi/schema.py | 1 - 11 files changed, 56 insertions(+), 61 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index e9f696b4cf..02f4f18e5a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -447,8 +447,7 @@ static void rxfilter_notify(NetClientState *nc) =20 if (nc->rxfilter_notify_enabled) { char *path =3D object_get_canonical_path(OBJECT(n->qdev)); - qapi_event_send_nic_rx_filter_changed(!!n->netclient_name, - n->netclient_name, path); + qapi_event_send_nic_rx_filter_changed(n->netclient_name, path); g_free(path); =20 /* disable event notification to avoid events flooding */ diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 63baf3f8c6..fc9a0617fe 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1125,7 +1125,6 @@ void hmp_announce_self(Monitor *mon, const QDict *qdi= ct) params->interfaces =3D strList_from_comma_list(interfaces_str); params->has_interfaces =3D params->interfaces !=3D NULL; params->id =3D g_strdup(id); - params->has_id =3D !!params->id; qmp_announce_self(params, NULL); qapi_free_AnnounceParameters(params); } diff --git a/net/announce.c b/net/announce.c index 62c60192a3..9e99044422 100644 --- a/net/announce.c +++ b/net/announce.c @@ -46,7 +46,7 @@ void qemu_announce_timer_del(AnnounceTimer *timer, bool f= ree_named) } qapi_free_strList(timer->params.interfaces); timer->params.interfaces =3D NULL; - if (free_named && timer->params.has_id) { + if (free_named && timer->params.id) { AnnounceTimer *list_timer; /* * Sanity check: There should only be one timer on the list with @@ -157,7 +157,7 @@ static void qemu_announce_self_iter(NICState *nic, void= *opaque) skip =3D false; } =20 - trace_qemu_announce_self_iter(timer->params.has_id ? timer->params.id = : "_", + trace_qemu_announce_self_iter(timer->params.id ?: "_", nic->ncs->name, qemu_ether_ntoa(&nic->conf->macaddr), sk= ip); =20 @@ -199,9 +199,9 @@ void qemu_announce_self(AnnounceTimer *timer, AnnounceP= arameters *params) void qmp_announce_self(AnnounceParameters *params, Error **errp) { AnnounceTimer *named_timer; - if (!params->has_id) { + + if (!params->id) { params->id =3D g_strdup(""); - params->has_id =3D true; } =20 named_timer =3D g_datalist_get_data(&named_timers, params->id); diff --git a/net/hub.c b/net/hub.c index 1375738bf1..e142573b6d 100644 --- a/net/hub.c +++ b/net/hub.c @@ -274,7 +274,7 @@ int net_init_hubport(const Netdev *netdev, const char *= name, assert(!peer); hubport =3D &netdev->u.hubport; =20 - if (hubport->has_netdev) { + if (hubport->netdev) { hubpeer =3D qemu_find_netdev(hubport->netdev); if (!hubpeer) { error_setg(errp, "netdev '%s' not found", hubport->netdev); diff --git a/net/l2tpv3.c b/net/l2tpv3.c index af373e5c30..32a4da80e3 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -578,7 +578,7 @@ int net_init_l2tpv3(const Netdev *netdev, =20 if (l2tpv3->has_udp && l2tpv3->udp) { s->udp =3D true; - if (!(l2tpv3->has_srcport && l2tpv3->has_dstport)) { + if (!(l2tpv3->srcport && l2tpv3->dstport)) { error_setg(errp, "need both src and dst port for udp"); goto outerr; } else { diff --git a/net/net.c b/net/net.c index 2db160e063..8b58c3979f 100644 --- a/net/net.c +++ b/net/net.c @@ -943,7 +943,7 @@ static int net_init_nic(const Netdev *netdev, const cha= r *name, =20 memset(nd, 0, sizeof(*nd)); =20 - if (nic->has_netdev) { + if (nic->netdev) { nd->netdev =3D qemu_find_netdev(nic->netdev); if (!nd->netdev) { error_setg(errp, "netdev '%s' not found", nic->netdev); @@ -954,19 +954,19 @@ static int net_init_nic(const Netdev *netdev, const c= har *name, nd->netdev =3D peer; } nd->name =3D g_strdup(name); - if (nic->has_model) { + if (nic->model) { nd->model =3D g_strdup(nic->model); } - if (nic->has_addr) { + if (nic->addr) { nd->devaddr =3D g_strdup(nic->addr); } =20 - if (nic->has_macaddr && + if (nic->macaddr && net_parse_macaddr(nd->macaddr.a, nic->macaddr) < 0) { error_setg(errp, "invalid syntax for ethernet address"); return -1; } - if (nic->has_macaddr && + if (nic->macaddr && is_multicast_ether_addr(nd->macaddr.a)) { error_setg(errp, "NIC cannot have multicast MAC address (odd 1st byte)"); @@ -1054,7 +1054,7 @@ static int net_client_init1(const Netdev *netdev, boo= l is_netdev, Error **errp) =20 /* Do not add to a hub if it's a nic with a netdev=3D parameter. */ if (netdev->type !=3D NET_CLIENT_DRIVER_NIC || - !netdev->u.nic.has_netdev) { + !netdev->u.nic.netdev) { peer =3D net_hub_add_port(0, NULL, NULL); } } @@ -1266,8 +1266,7 @@ void print_net_client(Monitor *mon, NetClientState *n= c) } } =20 -RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, - Error **errp) +RxFilterInfoList *qmp_query_rx_filter(const char *name, Error **errp) { NetClientState *nc; RxFilterInfoList *filter_list =3D NULL, **tail =3D &filter_list; @@ -1275,13 +1274,13 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name= , const char *name, QTAILQ_FOREACH(nc, &net_clients, next) { RxFilterInfo *info; =20 - if (has_name && strcmp(nc->name, name) !=3D 0) { + if (name && strcmp(nc->name, name) !=3D 0) { continue; } =20 /* only query rx-filter information of NIC */ if (nc->info->type !=3D NET_CLIENT_DRIVER_NIC) { - if (has_name) { + if (name) { error_setg(errp, "net client(%s) isn't a NIC", name); assert(!filter_list); return NULL; @@ -1298,19 +1297,19 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name= , const char *name, if (nc->info->query_rx_filter) { info =3D nc->info->query_rx_filter(nc); QAPI_LIST_APPEND(tail, info); - } else if (has_name) { + } else if (name) { error_setg(errp, "net client(%s) doesn't support" " rx-filter querying", name); assert(!filter_list); return NULL; } =20 - if (has_name) { + if (name) { break; } } =20 - if (filter_list =3D=3D NULL && has_name) { + if (filter_list =3D=3D NULL && name) { error_setg(errp, "invalid net client name: %s", name); } =20 diff --git a/net/slirp.c b/net/slirp.c index 8679be6444..1d26f4ce3d 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -1154,8 +1154,8 @@ int net_init_slirp(const Netdev *netdev, const char *= name, ipv6 =3D 0; } =20 - vnet =3D user->has_net ? g_strdup(user->net) : - user->has_ip ? g_strdup_printf("%s/24", user->ip) : + vnet =3D user->net ? g_strdup(user->net) : + user->ip ? g_strdup_printf("%s/24", user->ip) : NULL; =20 dnssearch =3D slirp_dnssearch(user->dnssearch); diff --git a/net/socket.c b/net/socket.c index bfd8596250..8de544ae8e 100644 --- a/net/socket.c +++ b/net/socket.c @@ -711,19 +711,19 @@ int net_init_socket(const Netdev *netdev, const char = *name, assert(netdev->type =3D=3D NET_CLIENT_DRIVER_SOCKET); sock =3D &netdev->u.socket; =20 - if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mc= ast + - sock->has_udp !=3D 1) { + if (!!sock->fd + !!sock->listen + !!sock->connect + !!sock->mcast + + !!sock->udp !=3D 1) { error_setg(errp, "exactly one of listen=3D, connect=3D, mcast=3D o= r udp=3D" " is required"); return -1; } =20 - if (sock->has_localaddr && !sock->has_mcast && !sock->has_udp) { + if (sock->localaddr && !sock->mcast && !sock->udp) { error_setg(errp, "localaddr=3D is only valid with mcast=3D or udp= =3D"); return -1; } =20 - if (sock->has_fd) { + if (sock->fd) { int fd, ret; =20 fd =3D monitor_fd_param(monitor_cur(), sock->fd, errp); @@ -743,7 +743,7 @@ int net_init_socket(const Netdev *netdev, const char *n= ame, return 0; } =20 - if (sock->has_listen) { + if (sock->listen) { if (net_socket_listen_init(peer, "socket", name, sock->listen, err= p) < 0) { return -1; @@ -751,7 +751,7 @@ int net_init_socket(const Netdev *netdev, const char *n= ame, return 0; } =20 - if (sock->has_connect) { + if (sock->connect) { if (net_socket_connect_init(peer, "socket", name, sock->connect, e= rrp) < 0) { return -1; @@ -759,7 +759,7 @@ int net_init_socket(const Netdev *netdev, const char *n= ame, return 0; } =20 - if (sock->has_mcast) { + if (sock->mcast) { /* if sock->localaddr is missing, it has been initialized to "all = bits * zero" */ if (net_socket_mcast_init(peer, "socket", name, sock->mcast, @@ -769,8 +769,8 @@ int net_init_socket(const Netdev *netdev, const char *n= ame, return 0; } =20 - assert(sock->has_udp); - if (!sock->has_localaddr) { + assert(sock->udp); + if (!sock->localaddr) { error_setg(errp, "localaddr=3D is mandatory with udp=3D"); return -1; } diff --git a/net/tap-win32.c b/net/tap-win32.c index 7466f22e77..6ad7626784 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -808,7 +808,7 @@ int net_init_tap(const Netdev *netdev, const char *name, assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; =20 - if (!tap->has_ifname) { + if (!tap->ifname) { error_report("tap: no interface name"); return -1; } diff --git a/net/tap.c b/net/tap.c index e203d07a12..1968e7593d 100644 --- a/net/tap.c +++ b/net/tap.c @@ -611,8 +611,8 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE); bridge =3D &netdev->u.bridge; - helper =3D bridge->has_helper ? bridge->helper : NULL; - br =3D bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTERF= ACE; + helper =3D bridge->helper; + br =3D bridge->br ?: DEFAULT_BRIDGE_INTERFACE; =20 fd =3D net_bridge_run_helper(helper, br, errp); if (fd =3D=3D -1) { @@ -689,9 +689,9 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, goto failed; } =20 - if (tap->has_fd || tap->has_fds) { + if (tap->fd || tap->fds) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=3D%d", fd); - } else if (tap->has_helper) { + } else if (tap->helper) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=3D%s", tap->helper); } else { @@ -815,21 +815,21 @@ int net_init_tap(const Netdev *netdev, const char *na= me, assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; queues =3D tap->has_queues ? tap->queues : 1; - vhostfdname =3D tap->has_vhostfd ? tap->vhostfd : NULL; - script =3D tap->has_script ? tap->script : NULL; - downscript =3D tap->has_downscript ? tap->downscript : NULL; + vhostfdname =3D tap->vhostfd; + script =3D tap->script; + downscript =3D tap->downscript; =20 /* QEMU hubs do not support multiqueue tap, in this case peer is set. * For -netdev, peer is always NULL. */ - if (peer && (tap->has_queues || tap->has_fds || tap->has_vhostfds)) { + if (peer && (tap->has_queues || tap->fds || tap->vhostfds)) { error_setg(errp, "Multiqueue tap cannot be used with hubs"); return -1; } =20 - if (tap->has_fd) { - if (tap->has_ifname || tap->has_script || tap->has_downscript || - tap->has_vnet_hdr || tap->has_helper || tap->has_queues || - tap->has_fds || tap->has_vhostfds) { + if (tap->fd) { + if (tap->ifname || tap->script || tap->downscript || + tap->has_vnet_hdr || tap->helper || tap->has_queues || + tap->fds || tap->vhostfds) { error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " "helper=3D, queues=3D, fds=3D, and vhostfds=3D " "are invalid with fd=3D"); @@ -862,14 +862,14 @@ int net_init_tap(const Netdev *netdev, const char *na= me, close(fd); return -1; } - } else if (tap->has_fds) { + } else if (tap->fds) { char **fds; char **vhost_fds; int nfds =3D 0, nvhosts =3D 0; =20 - if (tap->has_ifname || tap->has_script || tap->has_downscript || - tap->has_vnet_hdr || tap->has_helper || tap->has_queues || - tap->has_vhostfd) { + if (tap->ifname || tap->script || tap->downscript || + tap->has_vnet_hdr || tap->helper || tap->has_queues || + tap->vhostfd) { error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " "helper=3D, queues=3D, and vhostfd=3D " "are invalid with fds=3D"); @@ -880,7 +880,7 @@ int net_init_tap(const Netdev *netdev, const char *name, vhost_fds =3D g_new0(char *, MAX_TAP_QUEUES); =20 nfds =3D get_fds(tap->fds, fds, MAX_TAP_QUEUES); - if (tap->has_vhostfds) { + if (tap->vhostfds) { nvhosts =3D get_fds(tap->vhostfds, vhost_fds, MAX_TAP_QUEUES); if (nfds !=3D nvhosts) { error_setg(errp, "The number of fds passed does not match " @@ -919,7 +919,7 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 net_init_tap_one(tap, peer, "tap", name, ifname, script, downscript, - tap->has_vhostfds ? vhost_fds[i] : NULL, + tap->vhostfds ? vhost_fds[i] : NULL, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); @@ -938,17 +938,16 @@ free_fail: g_free(fds); g_free(vhost_fds); return ret; - } else if (tap->has_helper) { - if (tap->has_ifname || tap->has_script || tap->has_downscript || - tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) { + } else if (tap->helper) { + if (tap->ifname || tap->script || tap->downscript || + tap->has_vnet_hdr || tap->has_queues || tap->vhostfds) { error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " "queues=3D, and vhostfds=3D are invalid with helper= =3D"); return -1; } =20 fd =3D net_bridge_run_helper(tap->helper, - tap->has_br ? - tap->br : DEFAULT_BRIDGE_INTERFACE, + tap->br ?: DEFAULT_BRIDGE_INTERFACE, errp); if (fd =3D=3D -1) { return -1; @@ -975,7 +974,7 @@ free_fail: } else { g_autofree char *default_script =3D NULL; g_autofree char *default_downscript =3D NULL; - if (tap->has_vhostfds) { + if (tap->vhostfds) { error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't spec= ified"); return -1; } @@ -988,7 +987,7 @@ free_fail: get_relocated_path(DEFAULT_NETWORK_DOWN_S= CRIPT); } =20 - if (tap->has_ifname) { + if (tap->ifname) { pstrcpy(ifname, sizeof ifname, tap->ifname); } else { ifname[0] =3D '\0'; @@ -1001,7 +1000,7 @@ free_fail: return -1; } =20 - if (queues > 1 && i =3D=3D 0 && !tap->has_ifname) { + if (queues > 1 && i =3D=3D 0 && !tap->ifname) { if (tap_fd_get_ifname(fd, ifname)) { error_setg(errp, "Fail to get ifname"); close(fd); diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a34e25fdd7..930dffd780 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/net.json', 'qapi/pci.json', 'qapi/qdev.json', 'qapi/qom.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077772; cv=none; d=zohomail.com; s=zohoarc; b=mu+pWKuydi5UEMpV1+Ehp1QtI/TlHoEqS64pFtira5lwK3siIaQ1Qmi5AZ/SElNmjzkGBkIGQJU0dFoUvcyEdp9n1Af9zK9D+iyl/5WqqcfjPBOVhlozot2sbKlYMViLtixCimj1z/JlKE+u1ZrJRmqifr9WDP8Cx1TfVhsO2a4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077772; 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=YwLsM2ycbPhHaP+a5V0lZrusyFX/Mpb43ZYseUM0fnI=; b=VFxoBlJmN3ms4PSkT21xDw1ypVQvJqMcKLSmcm0Wczp8BFJQrDfUJtkYF6bw3YqJrZEpK92cauERZWofllIfDODjVCCAM1hCjA97IOgdL6hGpddgiqVktarE6gdu7huvhk49NhFk/ViT5zF75wzXoR8YnLwm26PTRvxdZ1nqE7U= 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 1666077772316874.3368007724357; Tue, 18 Oct 2022 00:22:52 -0700 (PDT) Received: from localhost ([::1]:39478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgw6-0000pL-Jw for importer@patchew.org; Tue, 18 Oct 2022 03:22:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6C-0005gW-VA for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg65-0001Ey-Hw for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-503-cggg7yaoMJWUnlLPwNaPmQ-1; Tue, 18 Oct 2022 02:28:53 -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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id E410985A5B6; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6A7D2024CCA; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 50F3F21E6617; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=YwLsM2ycbPhHaP+a5V0lZrusyFX/Mpb43ZYseUM0fnI=; b=N1n/wldeIsb+9p30UDA7n+b2+EvNEGzeOtsyT8Eoimihphk22qtiTc9lClE6NuYRyEMfYd cPwQesVX5DJDZMfSz3F+7CndL3szPFvPDiCj7RlqJMKv7mZjQODvslHYD6wvd64qqGZNOL 9HFhMfK6I+zvy+lJ2sq1g6xIBR9wdGY= X-MC-Unique: cggg7yaoMJWUnlLPwNaPmQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, "Michael S . Tsirkin" , Marcel Apfelbaum Subject: [PATCH v2 17/28] qapi pci: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:38 +0200 Message-Id: <20221018062849.3420573-18-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077773972100001 Content-Type: text/plain; charset="utf-8" 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 qapi/pci.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Michael S. Tsirkin Cc: Marcel Apfelbaum Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/pci/pci.c | 2 -- monitor/hmp-cmds.c | 6 +++--- scripts/qapi/schema.py | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2f450f6a72..e6292d8060 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1879,7 +1879,6 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice = *dev, PCIBus *bus, info->class_info->q_class =3D class; desc =3D get_class_desc(class); if (desc->desc) { - info->class_info->has_desc =3D true; info->class_info->desc =3D g_strdup(desc->desc); } =20 @@ -1897,7 +1896,6 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice = *dev, PCIBus *bus, =20 type =3D dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTIO= N; if (type =3D=3D PCI_HEADER_TYPE_BRIDGE) { - info->has_pci_bridge =3D true; info->pci_bridge =3D qmp_query_pci_bridge(dev, bus, bus_num); } else if (type =3D=3D PCI_HEADER_TYPE_NORMAL) { info->id->has_subsystem =3D info->id->has_subsystem_vendor =3D tru= e; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index fc9a0617fe..b180c6fc6b 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -730,7 +730,7 @@ static void hmp_info_pci_device(Monitor *mon, const Pci= DeviceInfo *dev) dev->slot, dev->function); monitor_printf(mon, " "); =20 - if (dev->class_info->has_desc) { + if (dev->class_info->desc) { monitor_puts(mon, dev->class_info->desc); } else { monitor_printf(mon, "Class %04" PRId64, dev->class_info->q_class); @@ -748,7 +748,7 @@ static void hmp_info_pci_device(Monitor *mon, const Pci= DeviceInfo *dev) dev->irq, (char)('A' + dev->irq_pin - 1)); } =20 - if (dev->has_pci_bridge) { + if (dev->pci_bridge) { monitor_printf(mon, " BUS %" PRId64 ".\n", dev->pci_bridge->bus->number); monitor_printf(mon, " secondary bus %" PRId64 ".\n", @@ -794,7 +794,7 @@ static void hmp_info_pci_device(Monitor *mon, const Pci= DeviceInfo *dev) =20 monitor_printf(mon, " id \"%s\"\n", dev->qdev_id); =20 - if (dev->has_pci_bridge) { + if (dev->pci_bridge) { if (dev->pci_bridge->has_devices) { PciDeviceInfoList *cdev; for (cdev =3D dev->pci_bridge->devices; cdev; cdev =3D cdev->n= ext) { diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 930dffd780..388b90812b 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/pci.json', 'qapi/qdev.json', 'qapi/qom.json', 'qapi/replay.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666079097; cv=none; d=zohomail.com; s=zohoarc; b=e36Z4p+PAjCMOhPc45GOWDCz48IvrDO/ct5hoBOhgUax8/p+SyDp5EystL0I78glv0caxK2YUpVWmi8CW6U5AUn09JT4UWu833Ule5/6HqXZjFUofB/iiC/9r1DwwaQN1akN1VJuhSRDOYuRxxVrQbSyCdNqCiHPX+Ci2PA03bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666079097; 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=ak4yiySyoZfYCxQ6Qxaug3LOxxiZUQqqDuTIajGg7aE=; b=PgLQxtx56xEpem1uugPz3LqJw05y/QaqVQADhw2TqE/pSkKeT91XP+LO9JoWqYzp60h5WVZBtoHlEGYVTI7xIIU7vEHGaXa1QAulddKxcQqCPOGEwGXlpimXsQ9sqzrS+cTjQ8acd8hdYr6fLwfPMToASuc11VALNJro9FqEBmw= 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 166607909754633.67689362222427; Tue, 18 Oct 2022 00:44:57 -0700 (PDT) Received: from localhost ([::1]:56446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okhHU-0004Lc-96 for importer@patchew.org; Tue, 18 Oct 2022 03:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6U-0005qs-CA for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6C-0001GI-SH for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:30 -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-294-8Jr4R4J9PHSr8VOa57jRkQ-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0546F3C0D18E; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B91FA40C206B; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5326F21E661A; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074540; 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=ak4yiySyoZfYCxQ6Qxaug3LOxxiZUQqqDuTIajGg7aE=; b=AVKjcaMPfliHbD4IzGFgE4BRgowpXBW2VGxUpqpPgtAzRcmbSBVOVYnp4M2a4/oFfcCp8U +pdXr/XmNZ8uW5j0gkxLGi0jztqOAYaO6VgJZFAtTMVanvBqtlDcBp9085hWKh3UtX3cDR NAguao6of2iu3FpFbqUSnNM+O07ALjY= X-MC-Unique: 8Jr4R4J9PHSr8VOa57jRkQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Paolo Bonzini , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost Subject: [PATCH v2 18/28] qapi qdev qom: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:39 +0200 Message-Id: <20221018062849.3420573-19-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.1 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666079098100100001 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 qapi/qdev.json and qapi/qom.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Paolo Bonzini Cc: Daniel P. Berrang=C3=A9 Cc: Eduardo Habkost Signed-off-by: Markus Armbruster --- hw/acpi/memory_hotplug.c | 2 +- hw/core/qdev.c | 2 +- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_drc.c | 3 +-- qom/qom-qmp-cmds.c | 7 +------ tests/qtest/fuzz/qos_fuzz.c | 3 +-- scripts/qapi/schema.py | 2 -- 7 files changed, 6 insertions(+), 15 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index a7476330a8..d926f4f77d 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -185,7 +185,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwa= ddr addr, uint64_t data, */ qapi_event_send_mem_unplug_error(dev->id ? : "", error_get_pretty(local_er= r)); - qapi_event_send_device_unplug_guest_error(!!dev->id, dev->= id, + qapi_event_send_device_unplug_guest_error(dev->id, dev->canonical_p= ath); error_free(local_err); break; diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 0806d8fcaa..459266aceb 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -744,7 +744,7 @@ static void device_finalize(Object *obj) if (dev->pending_deleted_event) { g_assert(dev->canonical_path); =20 - qapi_event_send_device_deleted(!!dev->id, dev->id, dev->canonical_= path); + qapi_event_send_device_deleted(dev->id, dev->canonical_path); g_free(dev->canonical_path); dev->canonical_path =3D NULL; } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8bbaf4f8a4..4ecf378e55 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3725,7 +3725,7 @@ void spapr_memory_unplug_rollback(SpaprMachineState *= spapr, DeviceState *dev) =20 qapi_event_send_mem_unplug_error(dev->id ? : "", qapi_error); =20 - qapi_event_send_device_unplug_guest_error(!!dev->id, dev->id, + qapi_event_send_device_unplug_guest_error(dev->id, dev->canonical_path); } =20 diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 76bc5d42a0..4923435a8b 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -175,8 +175,7 @@ static uint32_t drc_unisolate_logical(SpaprDrc *drc) "for device %s", drc->dev->id); } =20 - qapi_event_send_device_unplug_guest_error(!!drc->dev->id, - drc->dev->id, + qapi_event_send_device_unplug_guest_error(drc->dev->id, drc->dev->canonical_= path); } =20 diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index 2e63a4c184..7c087299de 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -99,15 +99,13 @@ static void qom_list_types_tramp(ObjectClass *klass, vo= id *data) info->name =3D g_strdup(object_class_get_name(klass)); info->has_abstract =3D info->abstract =3D object_class_is_abstract(kla= ss); if (parent) { - info->has_parent =3D true; info->parent =3D g_strdup(object_class_get_name(parent)); } =20 QAPI_LIST_PREPEND(*pret, info); } =20 -ObjectTypeInfoList *qmp_qom_list_types(bool has_implements, - const char *implements, +ObjectTypeInfoList *qmp_qom_list_types(const char *implements, bool has_abstract, bool abstract, Error **errp) @@ -168,10 +166,8 @@ ObjectPropertyInfoList *qmp_device_list_properties(con= st char *typename, info =3D g_new0(ObjectPropertyInfo, 1); info->name =3D g_strdup(prop->name); info->type =3D g_strdup(prop->type); - info->has_description =3D !!prop->description; info->description =3D g_strdup(prop->description); info->default_value =3D qobject_ref(prop->defval); - info->has_default_value =3D !!info->default_value; =20 QAPI_LIST_PREPEND(prop_list, info); } @@ -215,7 +211,6 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const c= har *typename, info =3D g_malloc0(sizeof(*info)); info->name =3D g_strdup(prop->name); info->type =3D g_strdup(prop->type); - info->has_description =3D !!prop->description; info->description =3D g_strdup(prop->description); =20 QAPI_LIST_PREPEND(prop_list, info); diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c index 3a3d9c16dd..e403d373a0 100644 --- a/tests/qtest/fuzz/qos_fuzz.c +++ b/tests/qtest/fuzz/qos_fuzz.c @@ -50,8 +50,7 @@ static void qos_set_machines_devices_available(void) machines_apply_to_node(mach_info); qapi_free_MachineInfoList(mach_info); =20 - type_info =3D qmp_qom_list_types(true, "device", true, true, - &error_abort); + type_info =3D qmp_qom_list_types("device", true, true, &error_abort); types_apply_to_node(type_info); qapi_free_ObjectTypeInfoList(type_info); } diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 388b90812b..c74c26bda3 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,8 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/qdev.json', - 'qapi/qom.json', 'qapi/replay.json', 'qapi/rocker.json', 'qapi/run-state.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077913; cv=none; d=zohomail.com; s=zohoarc; b=fFJz7Wq0/ZvFv4FvcBai/C31A/1d8Qd/beLSDdG4wDVqb7CgB0vkv0uAk9M00TOY+hScnHbWz0Wt4OZSiimFdObEcOs8jn73yMCeSJzI2NUJqmdXLk+/N2tEFeXw7pK6xeBXXNuGOWuesXWA3254+L8WpzFz6dO2NfsVAote4i4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077913; 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=esTensj2EfWOvBk+soz4g5CQOaEC4qRBlI4XgAcVRcM=; b=gJgRLGegn5o1uT+wnG84335y24Ad3nVLqrtpi3JFx4XyK/Toxj8oJuDquCn6zd5XBmA9YUJJkc/0SSDW7wQKeHhnsGSxbMOxARTVPk4Zvf6jNjjikjoCXfYKwYBShKmn6jmQuDcVrwxMrTn5GUOApgBFU28mFyKh47+0vja2sEo= 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 1666077913507286.53764273782747; Tue, 18 Oct 2022 00:25:13 -0700 (PDT) Received: from localhost ([::1]:57444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgyN-0002H4-Q2 for importer@patchew.org; Tue, 18 Oct 2022 03:25:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg85-0008DA-R0 for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:31:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg83-0001kP-S0 for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:31:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-0AIXzOTXNI6Smv6pOhAI6g-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46F1080D08F; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB12D111DCE4; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 554A921E661C; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074667; 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=esTensj2EfWOvBk+soz4g5CQOaEC4qRBlI4XgAcVRcM=; b=HUeUFmAEslQhwSDDFzDJf00MnAXXXLUbA5dcZlRQhuRqPsB2BRj8wbHhiT4WIVM0QpwOVY tFLdla0dAv18zjRNc77zRHwIJ0xMbW2ew0BrFu+BNaOl5imwomCu7KyeZ56jAorIT0P1eX bMPWb3IicMzE945pwgYjIM/rBvLDcP4= X-MC-Unique: 0AIXzOTXNI6Smv6pOhAI6g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Pavel Dovgalyuk , Paolo Bonzini Subject: [PATCH v2 19/28] qapi replay: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:40 +0200 Message-Id: <20221018062849.3420573-20-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077915352100003 Content-Type: text/plain; charset="utf-8" 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 qapi/replay.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Pavel Dovgalyuk Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- replay/replay-debugging.c | 1 - scripts/qapi/schema.py | 1 - 2 files changed, 2 deletions(-) diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c index 1cde50e9f3..3e60549a4a 100644 --- a/replay/replay-debugging.c +++ b/replay/replay-debugging.c @@ -50,7 +50,6 @@ ReplayInfo *qmp_query_replay(Error **errp) retval->mode =3D replay_mode; if (replay_get_filename()) { retval->filename =3D g_strdup(replay_get_filename()); - retval->has_filename =3D true; } retval->icount =3D replay_get_current_icount(); return retval; diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index c74c26bda3..2b6644f1c3 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/replay.json', 'qapi/rocker.json', 'qapi/run-state.json', 'qapi/stats.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075814; cv=none; d=zohomail.com; s=zohoarc; b=jhNe2elxMjI6NetgT28L/ytZk0AEoiQt1Aanz7OwE3WX2TXq7Xx/VB0gqLQyOeLPK1iRQIv7JmA0O0Ga01mGhazDmxpab9u43PMkZhd+I3jXiiagB6x8n532x9C1qCUS9UbLKeEhA1AsKJgJ3WE2ZFZkKd0utJcJSKp5dZjqo/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075814; 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=L9h6uU7jBzqj8l1b+pvK01aJ1qrw0/YZ5sBmKxaIDAk=; b=J5MFI8/NB8ZqzFeyHbKbcY/CHtVAXMVzTqUnLIXlQRbYEj7YgPz/pj3MHy/7K/97LGZkOJQQ1lvjt6d6t1BvVbOYhgx81o4D0DNBO1gUryq+5UH0GRuaLGGUTJMp/DdZNlI9gBr7GXQ1DngP5nc3VWql32BPr965BY9Cgxg7X1s= 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 1666075814770978.8114385832966; Mon, 17 Oct 2022 23:50:14 -0700 (PDT) Received: from localhost ([::1]:37906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQX-0008Eu-8j for importer@patchew.org; Tue, 18 Oct 2022 02:50:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6X-0005sx-Ez for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52581) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6C-0001GC-Ks for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:33 -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-196-K6ou7ciCNtiXS8kMbn-q6g-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 507513C0D192; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1E974030C9; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5777821E661F; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074537; 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=L9h6uU7jBzqj8l1b+pvK01aJ1qrw0/YZ5sBmKxaIDAk=; b=J3MYR6W8deEzcoWtbwP5ADRyX+jcdG9yvEfW5wgz+NBG+6d8cXGKjbbArXyuf852cZpTGz iIJyswlwtIZUQ8QoU1KwE1tF78GYi2thihAaKpACJ2AlrBk2EIDbOJqoDpebI1fK0Wqb5G H4kmQN523QSNGx1ILgGZixsLHlRd+OE= X-MC-Unique: K6ou7ciCNtiXS8kMbn-q6g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Jiri Pirko Subject: [PATCH v2 20/28] qapi rocker: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:41 +0200 Message-Id: <20221018062849.3420573-21-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075815221100007 Content-Type: text/plain; charset="utf-8" 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 qapi/rocker.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Jiri Pirko Signed-off-by: Markus Armbruster --- hw/net/rocker/rocker_of_dpa.c | 13 ++----------- monitor/hmp-cmds.c | 22 +++++++++++----------- scripts/qapi/schema.py | 1 - 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c index b3b8c5bb6d..dfe4754469 100644 --- a/hw/net/rocker/rocker_of_dpa.c +++ b/hw/net/rocker/rocker_of_dpa.c @@ -2348,23 +2348,19 @@ static void of_dpa_flow_fill(void *cookie, void *va= lue, void *user_data) =20 if (memcmp(key->eth.src.a, zero_mac.a, ETH_ALEN) || memcmp(mask->eth.src.a, zero_mac.a, ETH_ALEN)) { - nkey->has_eth_src =3D true; nkey->eth_src =3D qemu_mac_strdup_printf(key->eth.src.a); } =20 - if (nkey->has_eth_src && memcmp(mask->eth.src.a, ff_mac.a, ETH_ALEN)) { - nmask->has_eth_src =3D true; + if (nkey->eth_src && memcmp(mask->eth.src.a, ff_mac.a, ETH_ALEN)) { nmask->eth_src =3D qemu_mac_strdup_printf(mask->eth.src.a); } =20 if (memcmp(key->eth.dst.a, zero_mac.a, ETH_ALEN) || memcmp(mask->eth.dst.a, zero_mac.a, ETH_ALEN)) { - nkey->has_eth_dst =3D true; nkey->eth_dst =3D qemu_mac_strdup_printf(key->eth.dst.a); } =20 - if (nkey->has_eth_dst && memcmp(mask->eth.dst.a, ff_mac.a, ETH_ALEN)) { - nmask->has_eth_dst =3D true; + if (nkey->eth_dst && memcmp(mask->eth.dst.a, ff_mac.a, ETH_ALEN)) { nmask->eth_dst =3D qemu_mac_strdup_printf(mask->eth.dst.a); } =20 @@ -2400,7 +2396,6 @@ static void of_dpa_flow_fill(void *cookie, void *valu= e, void *user_data) if (key->ipv4.addr.dst || mask->ipv4.addr.dst) { char *dst =3D inet_ntoa(*(struct in_addr *)&key->ipv4.addr= .dst); int dst_len =3D of_dpa_mask2prefix(mask->ipv4.addr.dst); - nkey->has_ip_dst =3D true; nkey->ip_dst =3D g_strdup_printf("%s/%d", dst, dst_len); } break; @@ -2501,12 +2496,10 @@ static void of_dpa_group_fill(void *key, void *valu= e, void *user_data) ngroup->set_vlan_id =3D ntohs(group->l2_rewrite.vlan_id); } if (memcmp(group->l2_rewrite.src_mac.a, zero_mac.a, ETH_ALEN)) { - ngroup->has_set_eth_src =3D true; ngroup->set_eth_src =3D qemu_mac_strdup_printf(group->l2_rewrite.src_mac.a); } if (memcmp(group->l2_rewrite.dst_mac.a, zero_mac.a, ETH_ALEN)) { - ngroup->has_set_eth_dst =3D true; ngroup->set_eth_dst =3D qemu_mac_strdup_printf(group->l2_rewrite.dst_mac.a); } @@ -2532,12 +2525,10 @@ static void of_dpa_group_fill(void *key, void *valu= e, void *user_data) ngroup->set_vlan_id =3D ntohs(group->l3_unicast.vlan_id); } if (memcmp(group->l3_unicast.src_mac.a, zero_mac.a, ETH_ALEN)) { - ngroup->has_set_eth_src =3D true; ngroup->set_eth_src =3D qemu_mac_strdup_printf(group->l3_unicast.src_mac.a); } if (memcmp(group->l3_unicast.dst_mac.a, zero_mac.a, ETH_ALEN)) { - ngroup->has_set_eth_dst =3D true; ngroup->set_eth_dst =3D qemu_mac_strdup_printf(group->l3_unicast.dst_mac.a); } diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index b180c6fc6b..8f8bd93df1 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2031,35 +2031,35 @@ void hmp_rocker_of_dpa_flows(Monitor *mon, const QD= ict *qdict) } } =20 - if (key->has_eth_src) { + if (key->eth_src) { if ((strcmp(key->eth_src, "01:00:00:00:00:00") =3D=3D 0) && - (mask->has_eth_src) && + mask->eth_src && (strcmp(mask->eth_src, "01:00:00:00:00:00") =3D=3D 0)) { monitor_printf(mon, " src "); } else if ((strcmp(key->eth_src, "00:00:00:00:00:00") =3D=3D 0= ) && - (mask->has_eth_src) && + mask->eth_src && (strcmp(mask->eth_src, "01:00:00:00:00:00") =3D=3D 0)) { monitor_printf(mon, " src "); } else { monitor_printf(mon, " src %s", key->eth_src); - if (mask->has_eth_src) { + if (mask->eth_src) { monitor_printf(mon, "(%s)", mask->eth_src); } } } =20 - if (key->has_eth_dst) { + if (key->eth_dst) { if ((strcmp(key->eth_dst, "01:00:00:00:00:00") =3D=3D 0) && - (mask->has_eth_dst) && + mask->eth_dst && (strcmp(mask->eth_dst, "01:00:00:00:00:00") =3D=3D 0)) { monitor_printf(mon, " dst "); } else if ((strcmp(key->eth_dst, "00:00:00:00:00:00") =3D=3D 0= ) && - (mask->has_eth_dst) && + mask->eth_dst && (strcmp(mask->eth_dst, "01:00:00:00:00:00") =3D=3D 0)) { monitor_printf(mon, " dst "); } else { monitor_printf(mon, " dst %s", key->eth_dst); - if (mask->has_eth_dst) { + if (mask->eth_dst) { monitor_printf(mon, "(%s)", mask->eth_dst); } } @@ -2079,7 +2079,7 @@ void hmp_rocker_of_dpa_flows(Monitor *mon, const QDic= t *qdict) } } =20 - if (key->has_ip_dst) { + if (key->ip_dst) { monitor_printf(mon, " dst %s", key->ip_dst); } =20 @@ -2158,7 +2158,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDi= ct *qdict) group->set_vlan_id & VLAN_VID_MASK); } =20 - if (group->has_set_eth_src) { + if (group->set_eth_src) { if (!set) { set =3D true; monitor_printf(mon, " set"); @@ -2166,7 +2166,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDi= ct *qdict) monitor_printf(mon, " src %s", group->set_eth_src); } =20 - if (group->has_set_eth_dst) { + if (group->set_eth_dst) { if (!set) { monitor_printf(mon, " set"); } diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 2b6644f1c3..1b3195bc87 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/rocker.json', 'qapi/run-state.json', 'qapi/stats.json', 'qapi/tpm.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077833; cv=none; d=zohomail.com; s=zohoarc; b=R9ai8Vbp8X9dIXeZ6g0WXK+nGQtqNl7GsT6/8XheMaeLQ2OViLB5qn3qn5ZQlWsDY2tOTWMW0bcFN5hymdoHLJtOzBs2vfcw/SOisNvJ02UGTk2bTomjq03xTlzIVIa5t5FEUpmHPdxowyf1ZypTzoLZfqvwQmloQtI7PB4dmnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077833; 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=V+I0DgILyP0EWrwErZiQbiayV1sI2mJpXrSCUJMVdUc=; b=nsY809Hzjh/J0D8OBMMRqxYI/rXUvwr1SR8fcmG9fk91owu+dkgTaZq4v4dosDTRAYFtcr9JtChT4vhlX1hF5nqxO9OHWzb0Haq2AoJCB1/jZK2QPeyY6noYdiQez5Up14tiWZ0fo52KLsOe9hSqEQ3+u4yLVoZwBLzhxMrkMFM= 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 1666077833847475.5823043208186; Tue, 18 Oct 2022 00:23:53 -0700 (PDT) Received: from localhost ([::1]:34408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgx4-0001gL-Oj for importer@patchew.org; Tue, 18 Oct 2022 03:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okgBz-0005oy-KP for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:35:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okgBw-00024v-Qw for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:35:11 -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-527-b_4asnGhMuG_6MNgVuWxyg-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E58B73C025C4; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C29C8C15BA5; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5993921E6622; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074907; 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=V+I0DgILyP0EWrwErZiQbiayV1sI2mJpXrSCUJMVdUc=; b=EoPTKv2nuTbkcU+hZ+rELyH2Tj87BTwLof3gR7Bj15Y7nSB7NvJQLfNYgD/3oTIp1CuHSS KEGmb1CcSbOfk3kzp0H1Sdw2ZdzM3j9ZzlgylCKarcgZftDZAsMYmj0leKZpvsHhTWVYpW 7P7nE7VaJVPrJlTkwkd37yxr0UP5ILA= X-MC-Unique: b_4asnGhMuG_6MNgVuWxyg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Paolo Bonzini Subject: [PATCH v2 21/28] qapi run-state: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:42 +0200 Message-Id: <20221018062849.3420573-22-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077834300100005 Content-Type: text/plain; charset="utf-8" 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 qapi/run-state.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- softmmu/runstate.c | 18 +++++------------- scripts/qapi/schema.py | 1 - 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 1e68680b9d..682a810d3c 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -479,18 +479,15 @@ void qemu_system_guest_panicked(GuestPanicInformation= *info) */ if (panic_action =3D=3D PANIC_ACTION_PAUSE || (panic_action =3D=3D PANIC_ACTION_SHUTDOWN && shutdown_action = =3D=3D SHUTDOWN_ACTION_PAUSE)) { - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, - !!info, info); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, info); vm_stop(RUN_STATE_GUEST_PANICKED); } else if (panic_action =3D=3D PANIC_ACTION_SHUTDOWN || panic_action =3D=3D PANIC_ACTION_EXIT_FAILURE) { - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, - !!info, info); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, info); vm_stop(RUN_STATE_GUEST_PANICKED); qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC); } else { - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_RUN, - !!info, info); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_RUN, info); } =20 if (info) { @@ -517,13 +514,8 @@ void qemu_system_guest_panicked(GuestPanicInformation = *info) void qemu_system_guest_crashloaded(GuestPanicInformation *info) { qemu_log_mask(LOG_GUEST_ERROR, "Guest crash loaded"); - - qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, - !!info, info); - - if (info) { - qapi_free_GuestPanicInformation(info); - } + qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, info); + qapi_free_GuestPanicInformation(info); } =20 void qemu_system_reset_request(ShutdownCause reason) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 1b3195bc87..f405ab7f49 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/run-state.json', 'qapi/stats.json', 'qapi/tpm.json', 'qapi/transaction.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075811; cv=none; d=zohomail.com; s=zohoarc; b=UrLgWGx9tqEXiROJhT6v98UBupqd+K41bpkb/lRxlazKdabYNPuPHevQ6eLp/0magbnxciCj5o7AVl7bfhST1nyUacUJbdhimXZP/b6D2rTEyVvHpjHyZImGS5XzWI4U93O22ec9k0HhTWI6Q/zkeHGIBxA8CECkOoOEPE+8sps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075811; 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=ZJbeMlbVORzlklCSOckSAH/mUTOUzdazeqW7tCZnAJc=; b=Dbwq7DzGkBS6Q1RVOvgzQSX5k9sii+YxweOtNiREsjLRq1Yy+CeSLA1ZPrg1g/iCCiSoLyqSoGFL93wtXPQBoLp2le5Kfo7KCq4nh01ZBsLtIoemYgqsWFgwRQNhaHf49N4Qizzv0Wf1PKoK09/6JJKBOvaUHS0JQPmUuzIeDRY= 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 166607581115565.79781168492502; Mon, 17 Oct 2022 23:50:11 -0700 (PDT) Received: from localhost ([::1]:49248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQR-0007fp-ND for importer@patchew.org; Tue, 18 Oct 2022 02:50:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6P-0005qA-8E for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg69-0001Eo-9z for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:25 -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-620-McBIV0PHNn--UGn4ku-l-Q-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAA483C0D180; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C333A492B0A; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5BD7521E6623; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=ZJbeMlbVORzlklCSOckSAH/mUTOUzdazeqW7tCZnAJc=; b=TCcAZ7ebTNjkzUCIGRjRioMQgV/OeNhcaJ7k0766Q/p+GM7e71KPSW0yVvorsljzNf6ZiW pmmx0IELK9oU/10HuCg2a8PT06rKyTqXIthyAsvFJfP8+SxI44JN4RdPG+lcVpbMJBjQZ8 Lcj6aBDTi1dimP0g161rHzmTlYUmJ9Y= X-MC-Unique: McBIV0PHNn--UGn4ku-l-Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Mark Kanda , Paolo Bonzini Subject: [PATCH v2 22/28] qapi stats: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:43 +0200 Message-Id: <20221018062849.3420573-23-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075813145100002 Content-Type: text/plain; charset="utf-8" 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 qapi/stats.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Mark Kanda Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Mark Kanda Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- monitor/qmp-cmds.c | 5 +---- scripts/qapi/schema.py | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 2a0c919472..e3734f1946 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -563,10 +563,7 @@ void add_stats_entry(StatsResultList **stats_results, = StatsProvider provider, StatsResult *entry =3D g_new0(StatsResult, 1); =20 entry->provider =3D provider; - if (qom_path) { - entry->has_qom_path =3D true; - entry->qom_path =3D g_strdup(qom_path); - } + entry->qom_path =3D g_strdup(qom_path); entry->stats =3D stats_list; =20 QAPI_LIST_PREPEND(*stats_results, entry); diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index f405ab7f49..0544037e71 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/stats.json', 'qapi/tpm.json', 'qapi/transaction.json', 'qapi/ui.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075800; cv=none; d=zohomail.com; s=zohoarc; b=XspTdJfMQht9xdt8mhT3yq+KJPtkPZnvHNSs+i4800Mx5dqlwwyW+yNxaMceN6aOaKnbexgOkFDVace47ByaECzZWwHtV7VBRW9NHGYyPRSgGlwU0CdEmlaM7ozriv6TisD9msGjeZrAQkYyZt5h/8B9+wUNZyEyGXseEvnaEyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075800; 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=rtnrEwCVcQhbvlZBS/Q/enpdvGatD4qVW8aQVTgD4F8=; b=B6INzoRhpYUH09c0zUR87h4tvgRbjc+yxBZsoJYmGFX9ixYUxfJNheLWwvqz+G3GtB47BtJQC/4Dtp8AZ/LaFCKf+oHCiP/+Zfw63GOblF0IKpeQEvp7Rtm27ThT1NkM1mjdswXgxwR2ZM3AbVCmC7+37wILy5bLhtkmSo6C3tk= 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 1666075800638905.5842323153323; Mon, 17 Oct 2022 23:50:00 -0700 (PDT) Received: from localhost ([::1]:49198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQI-0007FT-8p for importer@patchew.org; Tue, 18 Oct 2022 02:49:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6L-0005jv-Eg for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg64-0001Ft-PU for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-294-A3uw9DcnMcOfrBVR9f5iug-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7DA9833AEE; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C500C403573F; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5E11321E6627; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074536; 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=rtnrEwCVcQhbvlZBS/Q/enpdvGatD4qVW8aQVTgD4F8=; b=Tw/r57ltWwzj13CpWRN7nn9UtMZ2wFVgOzTGIebzJL0Bx0RUeWfOe1jKeEjEr1w+kvaq2R Zj4Icb/2a71I5VuQQXRaVl2mdE7/9i1jqAQX5WFlweeZD/rZLFQYirgt7bO/ILmNM4raxU cdAurkiT/o2mfzaQIg8egEiqRZJbzk4= X-MC-Unique: A3uw9DcnMcOfrBVR9f5iug-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Stefan Berger , Stefan Berger Subject: [PATCH v2 23/28] qapi tpm: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:44 +0200 Message-Id: <20221018062849.3420573-24-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075801031100001 Content-Type: text/plain; charset="utf-8" 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 qapi/tpm.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Stefan Berger Signed-off-by: Markus Armbruster Reviewed-by: Stefan Berger --- backends/tpm/tpm_passthrough.c | 2 -- monitor/hmp-cmds.c | 8 ++++---- scripts/qapi/schema.py | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/backends/tpm/tpm_passthrough.c b/backends/tpm/tpm_passthrough.c index 5a2f74db1b..179697a3a9 100644 --- a/backends/tpm/tpm_passthrough.c +++ b/backends/tpm/tpm_passthrough.c @@ -259,12 +259,10 @@ tpm_passthrough_handle_device_opts(TPMPassthruState *= tpm_pt, QemuOpts *opts) value =3D qemu_opt_get(opts, "cancel-path"); if (value) { tpm_pt->options->cancel_path =3D g_strdup(value); - tpm_pt->options->has_cancel_path =3D true; } =20 value =3D qemu_opt_get(opts, "path"); if (value) { - tpm_pt->options->has_path =3D true; tpm_pt->options->path =3D g_strdup(value); } =20 diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8f8bd93df1..378f5b083d 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -885,10 +885,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) case TPM_TYPE_PASSTHROUGH: tpo =3D ti->options->u.passthrough.data; monitor_printf(mon, "%s%s%s%s", - tpo->has_path ? ",path=3D" : "", - tpo->has_path ? tpo->path : "", - tpo->has_cancel_path ? ",cancel-path=3D" : "", - tpo->has_cancel_path ? tpo->cancel_path : ""); + tpo->path ? ",path=3D" : "", + tpo->path ?: "", + tpo->cancel_path ? ",cancel-path=3D" : "", + tpo->cancel_path ?: ""); break; case TPM_TYPE_EMULATOR: teo =3D ti->options->u.emulator.data; diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 0544037e71..f0726af876 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/tpm.json', 'qapi/transaction.json', 'qapi/ui.json', 'qapi/virtio.json', --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666076731; cv=none; d=zohomail.com; s=zohoarc; b=G3TMaqpZPLNfWKkG9o4YiJu48aVMGbzvlsykx7Dr9AmhYb0lGt508FwbY/ZZHf7lJFH4vRt0xu9JYLPU/ZgWPzxGmvMt0m4lMKjzYKmGFIzkv1XaH6fmTDg33SYjeKxtydBRHiFey2kNtHmJ/NsFnoF/2vfRrI+P7DpZCWFgkYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666076731; 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=md9k7h4mPcU4G+Vh4flLoQRphuQp6pYsqRcVCKXem48=; b=h0y/Tz8pHsCqa2u4bKHPNpB26D33nOzzXq670m/5jZBeIfYISzFADINZftsG2pvMclhd5eLzdrCBpXavix8boAqbTbfp2jDdqidyZT+MnNn/lOvX/3pKOyJwdTvbgf0QXOIkPG9JutcRzZwvvTwxlePrPvBMkwAjQ22KJ19UKvY= 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 1666076731767146.9706906515928; Tue, 18 Oct 2022 00:05:31 -0700 (PDT) Received: from localhost ([::1]:38416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgfJ-0008Hb-PZ for importer@patchew.org; Tue, 18 Oct 2022 03:05:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6S-0005qo-SI for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23140) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0001F3-QQ for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-527-zrLjecmBOcW9D5Pu2MSMSQ-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC5CE833AF1; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C68F51468208; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 608B921E662A; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=md9k7h4mPcU4G+Vh4flLoQRphuQp6pYsqRcVCKXem48=; b=UvQYsrbaJjBQqJmPGZ0QvMhRMv1MNqWB4AHLZJ6mXiokmMBg3A0waNVoACKCz0qgdw3Z3M txSh42BGqxUnbYi6hE5TLNFv8m2+jxvJ6cCYBYwY5BSuFId7v0xLWQtjMWDp8bcxuvG8Jt YGQcCD8sgVaN5YJcYZH6uzdsK7yYCYU= X-MC-Unique: zrLjecmBOcW9D5Pu2MSMSQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PATCH v2 24/28] qapi transaction: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:45 +0200 Message-Id: <20221018062849.3420573-25-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666076732684100001 Content-Type: text/plain; charset="utf-8" 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 qapi/transaction.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Kevin Wolf Cc: Hanna Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster --- blockdev.c | 3 +-- scripts/qapi/schema.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6a3b8cdbc6..0900a38ca6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1048,7 +1048,7 @@ static void blockdev_do_action(TransactionAction *act= ion, Error **errp) =20 list.value =3D action; list.next =3D NULL; - qmp_transaction(&list, false, NULL, errp); + qmp_transaction(&list, NULL, errp); } =20 void qmp_blockdev_snapshot_sync(const char *device, const char *node_name, @@ -2288,7 +2288,6 @@ static TransactionProperties *get_transaction_propert= ies( * Always run under BQL. */ void qmp_transaction(TransactionActionList *dev_list, - bool has_props, struct TransactionProperties *props, Error **errp) { diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index f0726af876..3673296ad8 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/transaction.json', 'qapi/ui.json', 'qapi/virtio.json', 'qga/qapi-schema.json'] --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077829; cv=none; d=zohomail.com; s=zohoarc; b=B3w6ZKrjQZUXMYAYO949inydDJ5hXCE/xRKs8+8bnixNTUgV6hYVqyo3gjPm7vMCetGjKFHy07qfaIzIW77W1m+o8xANYfJzNbZb4o7rCvXWzE5geAD8Xr+jfaxmbUR7uMP9SH5gmKJI1CJ/fw2kkFC+UvAopDoBGXVHf6dT7pI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077829; 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=SPYjfLa2tJN1fpoytQQbBGJRZJ444KI78FLAHW4M35Y=; b=Q+x9QGRFcMvYIhnyc8LxapBb0Fou2t3m57fYoZF4cLdaAa292LVnNpf2jTvMOhbRPTluWm+OU7QMO18W2rgX185NXaEZs31sRDDN75f5eWztxnG4Wko3/InhJC5MvDCiImZeedQsgNjHTdpS+dGIwMaWPNxDeQgQrb0TZi4yR8I= 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 1666077829209277.4669785861538; Tue, 18 Oct 2022 00:23:49 -0700 (PDT) Received: from localhost ([::1]:49064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgx1-0001Gs-3w for importer@patchew.org; Tue, 18 Oct 2022 03:23:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6D-0005gd-7e for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg65-0001Ep-HV for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:10 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-ErwZM5uQMByHlOZZbWz1dQ-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27F39185A79C; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D55A6409AE1; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 62E0121E662B; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=SPYjfLa2tJN1fpoytQQbBGJRZJ444KI78FLAHW4M35Y=; b=II+/cllJTa3OEunXhJS2L7KQt/82dmf8KSqzxKHGBDKmUIJq2vCDj47fWJVJ4khSHeVurs flwTy1lX3QrZykFG/MggeHemNmFEXTf4Duf6JmSqc56dsKXpoNhK3BHPo9oYGx6rKwfP0n jHPy6xOkMzFGovUOPJGIfcaq5fNb/SI= X-MC-Unique: ErwZM5uQMByHlOZZbWz1dQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Gerd Hoffmann , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 25/28] qapi ui: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:46 +0200 Message-Id: <20221018062849.3420573-26-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.9 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077830375100001 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 qapi/ui.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- monitor/hmp-cmds.c | 12 ++++-------- ui/console.c | 4 ++-- ui/input.c | 4 ++-- ui/spice-core.c | 5 ----- ui/vnc.c | 10 ---------- scripts/qapi/schema.py | 1 - 6 files changed, 8 insertions(+), 28 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 378f5b083d..5285d7f2fe 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -569,11 +569,9 @@ static void hmp_info_vnc_clients(Monitor *mon, VncClie= ntInfoList *client) =20 hmp_info_VncBasicInfo(mon, qapi_VncClientInfo_base(cinfo), "Client= "); monitor_printf(mon, " x509_dname: %s\n", - cinfo->has_x509_dname ? - cinfo->x509_dname : "none"); + cinfo->x509_dname ?: "none"); monitor_printf(mon, " sasl_username: %s\n", - cinfo->has_sasl_username ? - cinfo->sasl_username : "none"); + cinfo->sasl_username ?: "none"); =20 client =3D client->next; } @@ -618,7 +616,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict) hmp_info_vnc_authcrypt(mon, " ", info->auth, info->has_vencrypt ? &info->vencrypt : NULL= ); } - if (info->has_display) { + if (info->display) { monitor_printf(mon, " Display: %s\n", info->display); } info2l =3D info2l->next; @@ -1422,7 +1420,6 @@ void hmp_set_password(Monitor *mon, const QDict *qdic= t) } =20 if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { - opts.u.vnc.has_display =3D !!display; opts.u.vnc.display =3D (char *)display; } =20 @@ -1450,7 +1447,6 @@ void hmp_expire_password(Monitor *mon, const QDict *q= dict) } =20 if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { - opts.u.vnc.has_display =3D !!display; opts.u.vnc.display =3D (char *)display; } =20 @@ -1735,7 +1731,7 @@ hmp_screendump(Monitor *mon, const QDict *qdict) goto end; } =20 - qmp_screendump(filename, id !=3D NULL, id, id !=3D NULL, head, + qmp_screendump(filename, id, id !=3D NULL, head, input_format !=3D NULL, format, &err); end: hmp_handle_error(mon, err); diff --git a/ui/console.c b/ui/console.c index 49da6a91df..35b5680812 100644 --- a/ui/console.c +++ b/ui/console.c @@ -407,7 +407,7 @@ static void graphic_hw_update_bh(void *con) =20 /* Safety: coroutine-only, concurrent-coroutine safe, main thread only */ void coroutine_fn -qmp_screendump(const char *filename, bool has_device, const char *device, +qmp_screendump(const char *filename, const char *device, bool has_head, int64_t head, bool has_format, ImageFormat format, Error **errp) { @@ -416,7 +416,7 @@ qmp_screendump(const char *filename, bool has_device, c= onst char *device, DisplaySurface *surface; int fd; =20 - if (has_device) { + if (device) { con =3D qemu_console_lookup_by_device_name(device, has_head ? head= : 0, errp); if (!con) { diff --git a/ui/input.c b/ui/input.c index e2a90af889..8f4a87d1d7 100644 --- a/ui/input.c +++ b/ui/input.c @@ -124,7 +124,7 @@ qemu_input_find_handler(uint32_t mask, QemuConsole *con) return NULL; } =20 -void qmp_input_send_event(bool has_device, const char *device, +void qmp_input_send_event(const char *device, bool has_head, int64_t head, InputEventList *events, Error **errp) { @@ -133,7 +133,7 @@ void qmp_input_send_event(bool has_device, const char *= device, Error *err =3D NULL; =20 con =3D NULL; - if (has_device) { + if (device) { if (!has_head) { head =3D 0; } diff --git a/ui/spice-core.c b/ui/spice-core.c index c3ac20ad43..72f8f1681c 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -222,7 +222,6 @@ static void channel_event(int event, SpiceChannelEventI= nfo *info) break; case SPICE_CHANNEL_EVENT_INITIALIZED: if (auth) { - server->has_auth =3D true; server->auth =3D g_strdup(auth); } add_channel_info(client, info); @@ -522,13 +521,9 @@ static SpiceInfo *qmp_query_spice_real(Error **errp) port =3D qemu_opt_get_number(opts, "port", 0); tls_port =3D qemu_opt_get_number(opts, "tls-port", 0); =20 - info->has_auth =3D true; info->auth =3D g_strdup(auth); - - info->has_host =3D true; info->host =3D g_strdup(addr ? addr : "*"); =20 - info->has_compiled_version =3D true; major =3D (SPICE_SERVER_VERSION & 0xff0000) >> 16; minor =3D (SPICE_SERVER_VERSION & 0xff00) >> 8; micro =3D SPICE_SERVER_VERSION & 0xff; diff --git a/ui/vnc.c b/ui/vnc.c index acb3629cd8..de0beb9c18 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -244,7 +244,6 @@ static VncServerInfo *vnc_server_info_get(VncDisplay *v= d) info =3D g_malloc0(sizeof(*info)); vnc_init_basic_info_from_server_addr(vd->listener->sioc[0], qapi_VncServerInfo_base(info), &e= rr); - info->has_auth =3D true; info->auth =3D g_strdup(vnc_auth_name(vd)); if (err) { qapi_free_VncServerInfo(info); @@ -263,13 +262,10 @@ static void vnc_client_cache_auth(VncState *client) if (client->tls) { client->info->x509_dname =3D qcrypto_tls_session_get_peer_name(client->tls); - client->info->has_x509_dname =3D - client->info->x509_dname !=3D NULL; } #ifdef CONFIG_VNC_SASL if (client->sasl.conn && client->sasl.username) { - client->info->has_sasl_username =3D true; client->info->sasl_username =3D g_strdup(client->sasl.username); } #endif @@ -341,11 +337,9 @@ static VncClientInfo *qmp_query_vnc_client(const VncSt= ate *client) =20 if (client->tls) { info->x509_dname =3D qcrypto_tls_session_get_peer_name(client->tls= ); - info->has_x509_dname =3D info->x509_dname !=3D NULL; } #ifdef CONFIG_VNC_SASL if (client->sasl.conn && client->sasl.username) { - info->has_sasl_username =3D true; info->sasl_username =3D g_strdup(client->sasl.username); } #endif @@ -426,11 +420,8 @@ VncInfo *qmp_query_vnc(Error **errp) abort(); } =20 - info->has_host =3D true; - info->has_service =3D true; info->has_family =3D true; =20 - info->has_auth =3D true; info->auth =3D g_strdup(vnc_auth_name(vd)); } =20 @@ -568,7 +559,6 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp) if (vd->dcl.con) { dev =3D DEVICE(object_property_get_link(OBJECT(vd->dcl.con), "device", &error_abort)); - info->has_display =3D true; info->display =3D g_strdup(dev->id); } for (i =3D 0; vd->listener !=3D NULL && i < vd->listener->nsioc; i= ++) { diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3673296ad8..fd18f8249b 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/ui.json', 'qapi/virtio.json', 'qga/qapi-schema.json'] if self.info and any(self.info.fname.endswith(mod) --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666077572; cv=none; d=zohomail.com; s=zohoarc; b=Dm1FgBZ6jdOp4jl3PVrIMb335SH1XnOIsocUDLIVvO+w8uX159aozzLRwPD6ZdOEGKOWENPEL3So8UYJD5rYX2j3h6JRgfYOkcIJD7qHVJ1okUAMzriLiPLlVEBIocVt8QKzD7Vju+sqb/07/zZ2DvYiT4mrfy1/faa9/8r0t3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666077572; 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=9g7zV/Yw2Iep9qZjK/aucfFHwkecB3GoOgZCZ7NOgvI=; b=N0PehePgx+7sEN7ryLi4NK0Ofms4iserf5bZAB4sYkdf/CTT3eXwTE4jjO9MJ4F9aL3wc9EujsLR3q0UBtS68bSiX5qAf0/efN0XGYgFV3+VKcMXpvGT5TxZLRwQhVVgTTG/t0zG13lnejnDxGxA+UrxnGu5hjdC0D+RS38+DSo= 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 1666077572468833.5974763933947; Tue, 18 Oct 2022 00:19:32 -0700 (PDT) Received: from localhost ([::1]:53594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgss-0004DQ-7r for importer@patchew.org; Tue, 18 Oct 2022 03:19:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6L-0005jx-Ee for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg62-0001G8-LC for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:16 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-5vB16AQkPJyGLMZXzJBung-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 125A1833AF5; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D782A111DCE5; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 650EC21E662D; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074537; 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=9g7zV/Yw2Iep9qZjK/aucfFHwkecB3GoOgZCZ7NOgvI=; b=E6HwWSzzGagLO81TZRszRMbn+f7V6p12hB49UGFsK4IxmBLTjTpa8quzx82VSksXhURzEV bwde0e6ndNnr0aCkUiCbWjXSSP4xkIVyyKvLs4ZVvhIoL60X7Va5M/j4Xs+t7TUCGTjtpF LpIo8ZnnkO5B7yR535LdYZ4XHzELYOI= X-MC-Unique: 5vB16AQkPJyGLMZXzJBung-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Laurent Vivier , "Michael S . Tsirkin" Subject: [PATCH v2 26/28] qapi virtio: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:47 +0200 Message-Id: <20221018062849.3420573-27-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666077573689100001 Content-Type: text/plain; charset="utf-8" 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 qapi/virtio.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Laurent Vivier Cc: Michael S. Tsirkin Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/virtio/virtio.c | 1 - monitor/hmp-cmds.c | 4 ++-- scripts/qapi/schema.py | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 808446b4c9..883bc7064d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4664,7 +4664,6 @@ VirtioStatus *qmp_x_query_virtio_status(const char *p= ath, Error **errp) status->disable_legacy_check =3D vdev->disable_legacy_check; status->bus_name =3D g_strdup(vdev->bus_name); status->use_guest_notifier_mask =3D vdev->use_guest_notifier_mask; - status->has_vhost_dev =3D vdev->vhost_started; =20 if (vdev->vhost_started) { VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 5285d7f2fe..cbbd9bdc6d 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2570,7 +2570,7 @@ void hmp_virtio_status(Monitor *mon, const QDict *qdi= ct) =20 monitor_printf(mon, "%s:\n", path); monitor_printf(mon, " device_name: %s %s\n", - s->name, s->has_vhost_dev ? "(vhost)" : ""); + s->name, s->vhost_dev ? "(vhost)" : ""); monitor_printf(mon, " device_id: %d\n", s->device_id); monitor_printf(mon, " vhost_started: %s\n", s->vhost_started ? "true" : "false"); @@ -2606,7 +2606,7 @@ void hmp_virtio_status(Monitor *mon, const QDict *qdi= ct) monitor_printf(mon, " Backend features:\n"); hmp_virtio_dump_features(mon, s->backend_features); =20 - if (s->has_vhost_dev) { + if (s->vhost_dev) { monitor_printf(mon, " VHost:\n"); monitor_printf(mon, " nvqs: %d\n", s->vhost_dev->nvqs); diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index fd18f8249b..b2df148e01 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -759,7 +759,6 @@ def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks opt_out =3D [ - 'qapi/virtio.json', 'qga/qapi-schema.json'] if self.info and any(self.info.fname.endswith(mod) for mod in opt_out): --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666076470; cv=none; d=zohomail.com; s=zohoarc; b=j/6VbINDklRNP/aDan3Xb2xsZ5ZToUo0eJ9mnhk5HPjGdQXVrN5UkXhNIWNJlKfyeQir40r5+bQvs3gGWa+95VYHwNVmhMWFnGOlwUZ+7RucIKSe/BfoaEnMxsF/UNOHJHUt82ub4QzXPVtgzfjuBFxySYX2743vMf8BkgiaR2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666076470; 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=cflL3Jcso4wfikplpU7m+Bsd6DC//2lgjHG1Ib5z4/A=; b=WGMd6dC4G2Z0s+brGvCYbiNqi6pwiZDTA2S5PPqyJSTlIEkxxaRYMZtzRLmgEsPCQXU5E98d+BdRiqdpY/XSqLjVbkEqtmarlHwPV+Mdo5MQuRKmykRl0Rr/VrbLaHVRfJu7GdD71GXx5n1bQMrWAxn2VOmm07JkTT2vfYkfyn4= 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 166607647044651.80766220365342; Tue, 18 Oct 2022 00:01:10 -0700 (PDT) Received: from localhost ([::1]:47020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgb7-0002zW-4q for importer@patchew.org; Tue, 18 Oct 2022 03:01:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6W-0005s2-FG for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg66-0001Fv-QM for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:32 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-rYyzvAicO0WVOD9jZY7LIA-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4292A803D4A; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D774FC19145; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 67AF621E6632; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074536; 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=cflL3Jcso4wfikplpU7m+Bsd6DC//2lgjHG1Ib5z4/A=; b=Xdfu9eMKG6mFe3ajkDBfAArBjYXixw7FkK9RCttFOR+1S3zWJWFTdr7uhDwBNnabiVzfse djay+WEOY/uEXaGUKq998vKkmtt4qff9BVk6ZTU86I4BwSj9VJI61iIrE2Rwqp0tpDg/hA cnBw2QnXLmEOWRWQ0p3w5p0ViA9Y2mY= X-MC-Unique: rYyzvAicO0WVOD9jZY7LIA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, Konstantin Kostiuk Subject: [PATCH v2 27/28] qapi qga: Elide redundant has_FOO in generated C Date: Tue, 18 Oct 2022 08:28:48 +0200 Message-Id: <20221018062849.3420573-28-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01, T_SPF_HELO_TEMPERROR=0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666076472416100001 Content-Type: text/plain; charset="utf-8" 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 qga/qapi-schema.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Michael Roth Cc: Konstantin Kostiuk Signed-off-by: Markus Armbruster --- qga/commands-posix.c | 33 ++++++++------------------------- qga/commands-win32.c | 40 +++++++--------------------------------- qga/commands.c | 11 ++++------- scripts/qapi/schema.py | 3 +-- 4 files changed, 20 insertions(+), 67 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index eea819cff0..095e91e18f 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -81,7 +81,7 @@ static void ga_wait_child(pid_t pid, int *status, Error *= *errp) g_assert(rpid =3D=3D pid); } =20 -void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp) +void qmp_guest_shutdown(const char *mode, Error **errp) { const char *shutdown_flag; Error *local_err =3D NULL; @@ -99,7 +99,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, = Error **errp) #endif =20 slog("guest-shutdown called, mode: %s", mode); - if (!has_mode || strcmp(mode, "powerdown") =3D=3D 0) { + if (!mode || strcmp(mode, "powerdown") =3D=3D 0) { shutdown_flag =3D powerdown_flag; } else if (strcmp(mode, "halt") =3D=3D 0) { shutdown_flag =3D halt_flag; @@ -407,14 +407,14 @@ end: return f; } =20 -int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *m= ode, +int64_t qmp_guest_file_open(const char *path, const char *mode, Error **errp) { FILE *fh; Error *local_err =3D NULL; int64_t handle; =20 - if (!has_mode) { + if (!mode) { mode =3D "r"; } slog("guest-file-open called, filepath: %s, mode: %s", path, mode); @@ -1053,7 +1053,6 @@ static bool build_guest_fsinfo_for_ccw_dev(char const= *syspath, return false; } =20 - disk->has_ccw_address =3D true; disk->ccw_address =3D g_new0(GuestCCWAddress, 1); disk->ccw_address->cssid =3D cssid; disk->ccw_address->ssid =3D ssid; @@ -1100,12 +1099,10 @@ static void build_guest_fsinfo_for_real_device(char= const *syspath, devnode =3D udev_device_get_devnode(udevice); if (devnode !=3D NULL) { disk->dev =3D g_strdup(devnode); - disk->has_dev =3D true; } serial =3D udev_device_get_property_value(udevice, "ID_SERIAL"); if (serial !=3D NULL && *serial !=3D 0) { disk->serial =3D g_strdup(serial); - disk->has_serial =3D true; } } =20 @@ -1124,7 +1121,7 @@ static void build_guest_fsinfo_for_real_device(char c= onst *syspath, has_hwinf =3D false; } =20 - if (has_hwinf || disk->has_dev || disk->has_serial) { + if (has_hwinf || disk->dev || disk->serial) { QAPI_LIST_PREPEND(fs->disk, disk); } else { qapi_free_GuestDiskAddress(disk); @@ -1427,7 +1424,6 @@ static void get_nvme_smart(GuestDiskInfo *disk) return; } =20 - disk->has_smart =3D true; disk->smart =3D g_new0(GuestDiskSmart, 1); disk->smart->type =3D GUEST_DISK_BUS_TYPE_NVME; =20 @@ -1465,7 +1461,7 @@ static void get_nvme_smart(GuestDiskInfo *disk) =20 static void get_disk_smart(GuestDiskInfo *disk) { - if (disk->has_address + if (disk->address && (disk->address->bus_type =3D=3D GUEST_DISK_BUS_TYPE_NVME)) { get_nvme_smart(disk); } @@ -1518,7 +1514,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp) disk->name =3D dev_name; disk->partition =3D false; disk->alias =3D get_alias_for_syspath(disk_dir); - disk->has_alias =3D (disk->alias !=3D NULL); QAPI_LIST_PREPEND(ret, disk); =20 /* Get address for non-virtual devices */ @@ -1538,8 +1533,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp) error_get_pretty(local_err)); error_free(local_err); local_err =3D NULL; - } else if (disk->address !=3D NULL) { - disk->has_address =3D true; } } =20 @@ -1899,7 +1892,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) if (fd =3D=3D -1) { result->error =3D g_strdup_printf("failed to open: %s", strerror(errno)); - result->has_error =3D true; continue; } =20 @@ -1914,7 +1906,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) r.minlen =3D has_minimum ? minimum : 0; ret =3D ioctl(fd, FITRIM, &r); if (ret =3D=3D -1) { - result->has_error =3D true; if (errno =3D=3D ENOTTY || errno =3D=3D EOPNOTSUPP) { result->error =3D g_strdup("trim not supported"); } else { @@ -3160,7 +3151,7 @@ GuestNetworkInterfaceList *qmp_guest_network_get_inte= rfaces(Error **errp) QAPI_LIST_APPEND(tail, info); } =20 - if (!info->has_hardware_address) { + if (!info->hardware_address) { /* we haven't obtained HW address yet */ sock =3D socket(PF_INET, SOCK_STREAM, 0); if (sock =3D=3D -1) { @@ -3196,8 +3187,6 @@ GuestNetworkInterfaceList *qmp_guest_network_get_inte= rfaces(Error **errp) (int) mac_addr[0], (int) mac_addr[1], (int) mac_addr[2], (int) mac_addr[3], (int) mac_addr[4], (int) mac_addr[5]); - - info->has_hardware_address =3D true; } close(sock); } @@ -3258,14 +3247,12 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) =20 info->has_ip_addresses =3D true; =20 - if (!info->has_statistics) { + if (!info->statistics) { interface_stat =3D g_malloc0(sizeof(*interface_stat)); if (guest_get_network_stats(info->name, interface_stat) =3D=3D= -1) { - info->has_statistics =3D false; g_free(interface_stat); } else { info->statistics =3D interface_stat; - info->has_statistics =3D true; } } } @@ -3572,11 +3559,8 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp) if (uname(&kinfo) !=3D 0) { error_setg_errno(errp, errno, "uname failed"); } else { - info->has_kernel_version =3D true; info->kernel_version =3D g_strdup(kinfo.version); - info->has_kernel_release =3D true; info->kernel_release =3D g_strdup(kinfo.release); - info->has_machine =3D true; info->machine =3D g_strdup(kinfo.machine); } =20 @@ -3596,7 +3580,6 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp) value =3D g_key_file_get_value(osrelease, "os-release", osfield, NULL)= ; \ if (value !=3D NULL) { \ ga_osrelease_replace_special(value); \ - info->has_ ## field =3D true; \ info->field =3D value; \ } \ } while (0) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index ec9f55b453..7d8d34d87d 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -193,8 +193,7 @@ static void handle_set_nonblocking(HANDLE fh) SetNamedPipeHandleState(fh, &pipe_state, NULL, NULL); } =20 -int64_t qmp_guest_file_open(const char *path, bool has_mode, - const char *mode, Error **errp) +int64_t qmp_guest_file_open(const char *path, const char *mode, Error **er= rp) { int64_t fd =3D -1; HANDLE fh; @@ -206,7 +205,7 @@ int64_t qmp_guest_file_open(const char *path, bool has_= mode, GError *gerr =3D NULL; wchar_t *w_path =3D NULL; =20 - if (!has_mode) { + if (!mode) { mode =3D "r"; } slog("guest-file-open called, filepath: %s, mode: %s", path, mode); @@ -317,14 +316,14 @@ static void execute_async(DWORD WINAPI (*func)(LPVOID= ), LPVOID opaque, } } =20 -void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp) +void qmp_guest_shutdown(const char *mode, Error **errp) { Error *local_err =3D NULL; UINT shutdown_flag =3D EWX_FORCE; =20 slog("guest-shutdown called, mode: %s", mode); =20 - if (!has_mode || strcmp(mode, "powerdown") =3D=3D 0) { + if (!mode || strcmp(mode, "powerdown") =3D=3D 0) { shutdown_flag |=3D EWX_POWEROFF; } else if (strcmp(mode, "halt") =3D=3D 0) { shutdown_flag |=3D EWX_SHUTDOWN; @@ -833,7 +832,6 @@ static void get_disk_properties(HANDLE vol_h, GuestDisk= Address *disk, g_debug("serial number \"%s\"", serial); if (*serial !=3D 0) { disk->serial =3D g_strndup(serial, len); - disk->has_serial =3D true; } } out_free: @@ -951,7 +949,6 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) /* Possibly CD-ROM or a shared drive. Try to pass the volume */ g_debug("volume not on disk"); disk =3D g_new0(GuestDiskAddress, 1); - disk->has_dev =3D true; disk->dev =3D g_strdup(name); get_single_disk_info(0xffffffff, disk, &local_err); if (local_err) { @@ -983,7 +980,6 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) * See also Naming Files, Paths and Namespaces: * https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-= a-file#win32-device-namespaces */ - disk->has_dev =3D true; disk->dev =3D g_strdup_printf("\\\\.\\PhysicalDrive%lu", extents->Extents[i].DiskNumber); =20 @@ -1078,7 +1074,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp) =20 g_debug(" number: %lu", sdn.DeviceNumber); address =3D g_new0(GuestDiskAddress, 1); - address->has_dev =3D true; address->dev =3D g_strdup(disk->name); get_single_disk_info(sdn.DeviceNumber, address, &local_err); if (local_err) { @@ -1089,7 +1084,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp) address =3D NULL; } else { disk->address =3D address; - disk->has_address =3D true; } =20 QAPI_LIST_PREPEND(ret, disk); @@ -1369,7 +1363,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) g_free(uc_path); =20 if (!path) { - res->has_error =3D true; res->error =3D g_strdup(gerr->message); g_error_free(gerr); break; @@ -1387,7 +1380,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) if (!g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NUL= L, &out /* stdout */, NULL /* stdin */, NULL, &gerr)) { - res->has_error =3D true; res->error =3D g_strdup(gerr->message); g_error_free(gerr); } else { @@ -1403,7 +1395,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) if (g_strstr_len(lines[i], -1, "(0x") =3D=3D NULL) { continue; } - res->has_error =3D true; res->error =3D g_strdup(lines[i]); break; } @@ -1683,8 +1674,6 @@ GuestNetworkInterfaceList *qmp_guest_network_get_inte= rfaces(Error **errp) (int) mac_addr[0], (int) mac_addr[1], (int) mac_addr[2], (int) mac_addr[3], (int) mac_addr[4], (int) mac_addr[5]); - - info->has_hardware_address =3D true; } =20 head_addr =3D NULL; @@ -1713,15 +1702,13 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) info->has_ip_addresses =3D true; info->ip_addresses =3D head_addr; } - if (!info->has_statistics) { + if (!info->statistics) { interface_stat =3D g_malloc0(sizeof(*interface_stat)); - if (guest_get_network_stats(addr->AdapterName, - interface_stat) =3D=3D -1) { - info->has_statistics =3D false; + if (guest_get_network_stats(addr->AdapterName, interface_stat) + =3D=3D -1) { g_free(interface_stat); } else { info->statistics =3D interface_stat; - info->has_statistics =3D true; } } } @@ -2113,7 +2100,6 @@ GuestUserList *qmp_guest_get_users(Error **errp) =20 user->user =3D g_strdup(info->UserName); user->domain =3D g_strdup(info->Domain); - user->has_domain =3D true; =20 user->login_time =3D login_time; =20 @@ -2332,29 +2318,19 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp) =20 info =3D g_new0(GuestOSInfo, 1); =20 - info->has_kernel_version =3D true; info->kernel_version =3D g_strdup_printf("%lu.%lu", os_version.dwMajorVersion, os_version.dwMinorVersion); - info->has_kernel_release =3D true; info->kernel_release =3D g_strdup_printf("%lu", os_version.dwBuildNumber); - info->has_machine =3D true; info->machine =3D ga_get_current_arch(); =20 - info->has_id =3D true; info->id =3D g_strdup("mswindows"); - info->has_name =3D true; info->name =3D g_strdup("Microsoft Windows"); - info->has_pretty_name =3D true; info->pretty_name =3D product_name; - info->has_version =3D true; info->version =3D ga_get_win_name(&os_version, false); - info->has_version_id =3D true; info->version_id =3D ga_get_win_name(&os_version, true); - info->has_variant =3D true; info->variant =3D g_strdup(server ? "server" : "client"); - info->has_variant_id =3D true; info->variant_id =3D g_strdup(server ? "server" : "client"); =20 return info; @@ -2478,7 +2454,6 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **er= rp) device_id =3D g_match_info_fetch(match_info, 2); =20 device->id =3D g_new0(GuestDeviceId, 1); - device->has_id =3D true; device->id->type =3D GUEST_DEVICE_TYPE_PCI; id =3D &device->id->u.pci; id->vendor_id =3D g_ascii_strtoull(vendor_id, NULL, 16); @@ -2502,7 +2477,6 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **er= rp) error_setg(errp, "conversion to utf8 failed (driver version)"); return NULL; } - device->has_driver_version =3D true; =20 date =3D (LPFILETIME)cm_get_property(dev_info_data.DevInst, &qga_DEVPKEY_Device_DriverDate, &cm_type); diff --git a/qga/commands.c b/qga/commands.c index 7ff551d092..360077364e 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -206,14 +206,12 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, E= rror **errp) } #endif if (gei->out.length > 0) { - ges->has_out_data =3D true; ges->out_data =3D g_base64_encode(gei->out.data, gei->out.leng= th); g_free(gei->out.data); ges->has_out_truncated =3D gei->out.truncated; } =20 if (gei->err.length > 0) { - ges->has_err_data =3D true; ges->err_data =3D g_base64_encode(gei->err.data, gei->err.leng= th); g_free(gei->err.data); ges->has_err_truncated =3D gei->err.truncated; @@ -385,7 +383,7 @@ close: GuestExec *qmp_guest_exec(const char *path, bool has_arg, strList *arg, bool has_env, strList *env, - bool has_input_data, const char *input_data, + const char *input_data, bool has_capture_output, bool capture_output, Error **errp) { @@ -406,7 +404,7 @@ GuestExec *qmp_guest_exec(const char *path, arglist.value =3D (char *)path; arglist.next =3D has_arg ? arg : NULL; =20 - if (has_input_data) { + if (input_data) { input =3D qbase64_decode(input_data, -1, &ninput, errp); if (!input) { return NULL; @@ -423,7 +421,7 @@ GuestExec *qmp_guest_exec(const char *path, } =20 ret =3D g_spawn_async_with_pipes(NULL, argv, envp, flags, - guest_exec_task_setup, NULL, &pid, has_input_data ? &in_fd : N= ULL, + guest_exec_task_setup, NULL, &pid, input_data ? &in_fd : NULL, has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &ger= r); if (!ret) { error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message); @@ -438,7 +436,7 @@ GuestExec *qmp_guest_exec(const char *path, gei->has_output =3D has_output; g_child_watch_add(pid, guest_exec_child_watch, gei); =20 - if (has_input_data) { + if (input_data) { gei->in.data =3D g_steal_pointer(&input); gei->in.size =3D ninput; #ifdef G_OS_WIN32 @@ -547,7 +545,6 @@ GuestTimezone *qmp_guest_get_timezone(Error **errp) info->offset =3D g_time_zone_get_offset(tz, intv); name =3D g_time_zone_get_abbreviation(tz, intv); if (name !=3D NULL) { - info->has_zone =3D true; info->zone =3D g_strdup(name); } g_time_zone_unref(tz); diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index b2df148e01..4594c69d0b 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -758,8 +758,7 @@ def __init__(self, name, info, typ, optional, ifcond=3D= None, features=3DNone): def need_has(self): assert self.type # Temporary hack to support dropping the has_FOO in reviewable chu= nks - opt_out =3D [ - 'qga/qapi-schema.json'] + opt_out =3D [] if self.info and any(self.info.fname.endswith(mod) for mod in opt_out): return self.optional --=20 2.37.2 From nobody Sun Feb 8 12:13:49 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=1666075815; cv=none; d=zohomail.com; s=zohoarc; b=gGWKidnrZYQiXPAZ4Ezttb9eFKlHbvSjW/ZuPgiLBffeDFrGBGfulhgvKkLCmtHR9JjhHoXqZwgyux18qz5mj2igOOaKCYfMiQxznPlyRmDp89D8s+sySq92koGLm1AH8MA+RYLWLvROGTZojdr7j5Z+iY5/k9UAb5d6cPSt7uI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666075815; 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=s/BbZF7kR9HFCNMsgd5gxX+fEgQaLuo7WT+UhHRLVs4=; b=PthFfKvnNQ7C74DfDkP9wzoiaEP72pUkoF0dCgFu0W3NygxMdcJJ/AO8q/minpMxyIuLb7YAugOtEkqJ71lvp4bgSYmPJ5zXzbhf1aGbgr2bFbcbyxWLBQHvZlTE45xyJxohyQ2za5SaL0QwPirLMz1tJdvlC1/8EJpe3xjZqgU= 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 1666075815154783.528252439367; Mon, 17 Oct 2022 23:50:15 -0700 (PDT) Received: from localhost ([::1]:49276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okgQX-0007gv-Iu for importer@patchew.org; Tue, 18 Oct 2022 02:50:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg6D-0005gZ-2Z for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okg65-0001Eq-Ij for qemu-devel@nongnu.org; Tue, 18 Oct 2022 02:29:11 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-mlaqxNC1OViBRfYZh74_vg-1; Tue, 18 Oct 2022 02:28:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A37B80D088; Tue, 18 Oct 2022 06:28:53 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC537146820A; Tue, 18 Oct 2022 06:28:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6A2D921E6688; Tue, 18 Oct 2022 08:28:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666074534; 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=s/BbZF7kR9HFCNMsgd5gxX+fEgQaLuo7WT+UhHRLVs4=; b=iDAapPnA9uRzsyTekOeARpeQxZ1J2kICzKT7/Kek0f/FaSoerIHniIRt/6rt4X1qH9OKir QMQ2NUsjmZkHwm3iVvRtSoJV/T/qmPbDcShLoj2/0Ut4kuQw2W1wjwMRhHXIZUhu0NUXlp B7Z7LT7BAzV2V7i73eRmAJKQFcSocoQ= X-MC-Unique: mlaqxNC1OViBRfYZh74_vg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v2 28/28] qapi: Drop temporary logic to support conversion step by step Date: Tue, 18 Oct 2022 08:28:49 +0200 Message-Id: <20221018062849.3420573-29-armbru@redhat.com> In-Reply-To: <20221018062849.3420573-1-armbru@redhat.com> References: <20221018062849.3420573-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.7 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666075817433100001 Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qapi/schema.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 4594c69d0b..cd8661125c 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -757,12 +757,6 @@ def __init__(self, name, info, typ, optional, ifcond= =3DNone, features=3DNone): =20 def need_has(self): assert self.type - # Temporary hack to support dropping the has_FOO in reviewable chu= nks - opt_out =3D [] - if self.info and any(self.info.fname.endswith(mod) - for mod in opt_out): - return self.optional - # End of temporary hack return self.optional and self.type.need_has_if_optional() =20 def check(self, schema): --=20 2.37.2