From nobody Sun Apr 28 22:18:06 2024 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=1616536731; cv=none; d=zohomail.com; s=zohoarc; b=iidZ/CN833xO6ZwUOlQoy1SxEzzX4oexFECNicy8HKxuVQiuvr/6JPEQa9cbUpNWZFUitN0XMgSi4wTM7t3wR5TbLwjFeTcnYXEKRkK7PO0LPgAbg9m4+OnPpH1yf8eB0W722D3l6c8fjsDNlh3lTH2ap2fXZW5zxz0Eo7CK6fE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616536731; 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=ZplKmfyzLpn9U8O9j5k7/v/RAV5MmSxFp9+gn1KfJ5Q=; b=lsU+qKG8DJjkBF9U3j6Fc2F2/fVEL1c2SzdTo1prsqRziwiIPYYW0hvlXPBspAaAzqmKG4rk7hp9OVMLD6MfqfIXqixMO9sgK4U1HQZqWsz4ZmAbZLD2RZEyrwl0Vorh1V0Gv6hOukJaysqmVg8zmVl01Lp+QqnxrrXXNkNw0Z8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616536730991534.3048577186385; Tue, 23 Mar 2021 14:58:50 -0700 (PDT) Received: from localhost ([::1]:52732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp33-00016C-OK for importer@patchew.org; Tue, 23 Mar 2021 17:58:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1O-0006tl-6G for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1M-0002kK-8S for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-di5uxwdjPLGbMsqIkn8vpw-1; Tue, 23 Mar 2021 17:57:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 223261B2C983; Tue, 23 Mar 2021 21:57:00 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6DBC5D6D7; Tue, 23 Mar 2021 21:56:59 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7F6D711327F9; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536623; 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=ZplKmfyzLpn9U8O9j5k7/v/RAV5MmSxFp9+gn1KfJ5Q=; b=GOi2sbjQa5duVQ6v9G1s6IVujCqaa+oRfaE721aG3dMsp42zAdBMafNk/QUYzyNoc21Sid 9YOawCg5Mi98r7ZZz+dQh9WnNXbz/hl3+UJJ/vKWeoWCumOWGOUK8fRKKfeVWgf1iLObhh UMG19oQw04i7h70w31+7RSib7FN172I= X-MC-Unique: di5uxwdjPLGbMsqIkn8vpw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 01/29] qapi/pragma: Tidy up after removal of deprecated commands Date: Tue, 23 Mar 2021 22:56:30 +0100 Message-Id: <20210323215658.3840228-2-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit cbde7be900 "migrate: remove QMP/HMP commands for speed, downtime and cache size" neglected to remove query-migrate-cache-size from pragma returns-whitelist. Commit 8af54b9172 "machine: remove 'query-cpus' QMP command" neglected to remove CpuInfo & friends from pragma name-case-exceptions. Remove these now. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-2-armbru@redhat.com> Reviewed-by: John Snow --- qapi/pragma.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/qapi/pragma.json b/qapi/pragma.json index cffae27666..7f158e183d 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -7,18 +7,14 @@ 'returns-whitelist': [ 'human-monitor-command', 'qom-get', - 'query-migrate-cache-size', 'query-tpm-models', 'query-tpm-types', 'ringbuf-read' ], 'name-case-whitelist': [ 'ACPISlotType', # DIMM, visible through query-acpi-osp= m-status - 'CpuInfoMIPS', # PC, visible through query-cpu - 'CpuInfoTricore', # PC, visible through query-cpu 'BlockdevVmdkSubformat', # all members, to match VMDK spec spel= lings 'BlockdevVmdkAdapterType', # legacyESX, to match VMDK spec spelli= ngs 'QapiErrorClass', # all members, visible through errors 'UuidInfo', # UUID, visible through query-uuid - 'X86CPURegister32', # all members, visible indirectly thro= ugh qom-get - 'CpuInfo' # CPU, visible through query-cpu + 'X86CPURegister32' # all members, visible indirectly thro= ugh qom-get ] } } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 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=1616537086; cv=none; d=zohomail.com; s=zohoarc; b=RyvkM04tPHEqyN0rdXmLPs9OardUaQENsKXDjlLTWAyPUsiTGtRO4dLPrnu21WCgnvpTkTSpxUVGXfNa8Djzn0LPBLsx7Kykl9v9YZRwLd5vw4gU5VHhsf1gDhgU7OIaOS1RuKGD7gx/3UV/kozLLtiiMMUgiR+y7ePAO6M4VyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537086; 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=D50BF+Cvx9tK7B8FrfeoxYklXG0hX43HOVthn614L6Y=; b=U8hP9dPMBAtw441a3ENMfLOYscR1j9d4x3nzOYSQvD0X3svPwGq83NqL5Zx7UdpKC9KmypKrMLXwK7qE8XEH1Pi7IU11fXjuQHuVx/aVMfwTMKHwEfk2qr29tjyNZcyg/k5zyCUF11dCYl/JIiB7AHe7V4P+5QnE/eUU6hedhQY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537086695371.6925005091448; Tue, 23 Mar 2021 15:04:46 -0700 (PDT) Received: from localhost ([::1]:40682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp8n-0002Mk-Eu for importer@patchew.org; Tue, 23 Mar 2021 18:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0006vE-Lf for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1M-0002kH-8P for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-rTwKiPGuPOOxmYAVf4Ow0g-1; Tue, 23 Mar 2021 17:57:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 249ADA0CA3; Tue, 23 Mar 2021 21:57:00 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E965B610A8; Tue, 23 Mar 2021 21:56:59 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 827541132709; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536623; 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=D50BF+Cvx9tK7B8FrfeoxYklXG0hX43HOVthn614L6Y=; b=Gz/GyR3loTg5C7BRNu0tsOl8lKIKkRyZKzhK1p86+klwtVN7ISHLYPvn9z2Jz0dGczQ72Q gNh8S1NoYQcB2Mm8LzVlO0shViRq0634953GtabXu/8JG/MaoVVGITC08RAPvUTl2VYyZ2 IhM9qkoZ22pDgoCPOifVNqcUXFHmxGM= X-MC-Unique: rTwKiPGuPOOxmYAVf4Ow0g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 02/29] tests/qapi-schema: Drop redundant flat-union-inline test Date: Tue, 23 Mar 2021 22:56:31 +0100 Message-Id: <20210323215658.3840228-3-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" flat-union-inline.json covers longhand branch definition with an invalid type value. It's redundant: longhand branch definition is covered by flat-union-inline-invalid-dict.json, and invalid type value is covered by nested-struct-data.json. Drop the test. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-3-armbru@redhat.com> Reviewed-by: John Snow --- tests/qapi-schema/flat-union-inline.err | 2 -- tests/qapi-schema/flat-union-inline.json | 11 ----------- tests/qapi-schema/flat-union-inline.out | 0 tests/qapi-schema/meson.build | 1 - 4 files changed, 14 deletions(-) delete mode 100644 tests/qapi-schema/flat-union-inline.err delete mode 100644 tests/qapi-schema/flat-union-inline.json delete mode 100644 tests/qapi-schema/flat-union-inline.out diff --git a/tests/qapi-schema/flat-union-inline.err b/tests/qapi-schema/fl= at-union-inline.err deleted file mode 100644 index 538283f5db..0000000000 --- a/tests/qapi-schema/flat-union-inline.err +++ /dev/null @@ -1,2 +0,0 @@ -flat-union-inline.json: In union 'TestUnion': -flat-union-inline.json:7: 'data' member 'value1' should be a type name diff --git a/tests/qapi-schema/flat-union-inline.json b/tests/qapi-schema/f= lat-union-inline.json deleted file mode 100644 index a9b3ce3f0d..0000000000 --- a/tests/qapi-schema/flat-union-inline.json +++ /dev/null @@ -1,11 +0,0 @@ -# we require branches to be a struct name -# TODO: should we allow anonymous inline branch types? -{ 'enum': 'TestEnum', - 'data': [ 'value1', 'value2' ] } -{ 'struct': 'Base', - 'data': { 'enum1': 'TestEnum', 'kind': 'str' } } -{ 'union': 'TestUnion', - 'base': 'Base', - 'discriminator': 'enum1', - 'data': { 'value1': { 'type': {} }, - 'value2': { 'integer': 'int' } } } diff --git a/tests/qapi-schema/flat-union-inline.out b/tests/qapi-schema/fl= at-union-inline.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 304ef939bd..d5fa035507 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -111,7 +111,6 @@ schemas =3D [ 'flat-union-clash-member.json', 'flat-union-discriminator-bad-name.json', 'flat-union-empty.json', - 'flat-union-inline.json', 'flat-union-inline-invalid-dict.json', 'flat-union-int-branch.json', 'flat-union-invalid-branch-key.json', --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616536891; cv=none; d=zohomail.com; s=zohoarc; b=jdfxbK5BlaBOuIAn+qa73Dn18OQTZJJ/UDAGRwjEyXgWmIGk0ze7vYXe28cjHab4nfaNzuf6Kl9HGgt0pFpVt/JHhIFaz9VvUW/M4TU6UdUdVEGmTb625Z8JSU7gsRhrqENiijrYUbs0gSgVFS+dGoZJF8+kZLjXecmO/CmWNBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616536891; 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=dqDXgUPGz7iS9cg170eq7KLn6JnELBqkNM9RVf/rCeY=; b=ONG9RsGVSyfayvhqHLnT0GOfIpsmeKHtOSh3W+rabxvNwfKh/lKRLkSXuep2Jm6p4L7VSCWfUOVAov8ugnAnbCYryALnbgJBEvcrUV99Ed4JbfiIw8fHc/2RcYJFe15kUOyMS5wedhy1DvV6FF58PFt+Nr0i9lGB48W15eFgHms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616536891585275.8253947142048; Tue, 23 Mar 2021 15:01:31 -0700 (PDT) Received: from localhost ([::1]:60894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp5e-0005OQ-F5 for importer@patchew.org; Tue, 23 Mar 2021 18:01:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1R-0006yC-JZ for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20268) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1M-0002kB-9k for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-284-9TyL4CJ0NdKZXmmDtR2qaw-1; Tue, 23 Mar 2021 17:57:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A55C108BD06; Tue, 23 Mar 2021 21:57:00 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E773E5C1C5; Tue, 23 Mar 2021 21:56:59 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 85DD41132710; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536623; 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=dqDXgUPGz7iS9cg170eq7KLn6JnELBqkNM9RVf/rCeY=; b=dFDWVDRwEbTo1cXjsKdbODOZ+79zE9gmGpAA4BF0e19ykEgUyce3yFujM2f0+mK5aJ9Z4G 6QJ3ldmhAwAN2V6IV7xqhK/7QKqc+sjk6aMH6dw6crCjzdJR9TZ+ZUeJQvMhY9SeX4r1qI P5GCOFnBcw4/1S2VJT8zxVKN3S9aRe8= X-MC-Unique: 9TyL4CJ0NdKZXmmDtR2qaw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 03/29] tests/qapi-schema: Rework comments on longhand member definitions Date: Tue, 23 Mar 2021 22:56:32 +0100 Message-Id: <20210323215658.3840228-4-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" A few old comments talk about "desired future use of defaults" and "anonymous inline branch types". Kind of misleading since commit 87adbbffd4 "qapi: add a dictionary form for TYPE" added longhand member definitions. Talk about that instead. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-4-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: John Snow --- tests/qapi-schema/event-member-invalid-dict.err | 2 +- tests/qapi-schema/event-member-invalid-dict.json | 2 ++ tests/qapi-schema/flat-union-inline-invalid-dict.json | 4 ++-- tests/qapi-schema/nested-struct-data-invalid-dict.err | 2 +- tests/qapi-schema/nested-struct-data-invalid-dict.json | 3 ++- tests/qapi-schema/nested-struct-data.json | 2 +- tests/qapi-schema/struct-member-invalid-dict.err | 2 +- tests/qapi-schema/struct-member-invalid-dict.json | 3 ++- 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/qapi-schema/event-member-invalid-dict.err b/tests/qapi-s= chema/event-member-invalid-dict.err index c7a6a24305..82f8989344 100644 --- a/tests/qapi-schema/event-member-invalid-dict.err +++ b/tests/qapi-schema/event-member-invalid-dict.err @@ -1,2 +1,2 @@ event-member-invalid-dict.json: In event 'EVENT_A': -event-member-invalid-dict.json:1: 'data' member 'a' misses key 'type' +event-member-invalid-dict.json:3: 'data' member 'a' misses key 'type' diff --git a/tests/qapi-schema/event-member-invalid-dict.json b/tests/qapi-= schema/event-member-invalid-dict.json index ee6f3ecb6f..e58560abca 100644 --- a/tests/qapi-schema/event-member-invalid-dict.json +++ b/tests/qapi-schema/event-member-invalid-dict.json @@ -1,2 +1,4 @@ +# event 'data' member with dict value is (longhand) argument +# definition, not inline complex type { 'event': 'EVENT_A', 'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } } diff --git a/tests/qapi-schema/flat-union-inline-invalid-dict.json b/tests/= qapi-schema/flat-union-inline-invalid-dict.json index 62c7cda617..1779712795 100644 --- a/tests/qapi-schema/flat-union-inline-invalid-dict.json +++ b/tests/qapi-schema/flat-union-inline-invalid-dict.json @@ -1,5 +1,5 @@ -# we require branches to be a struct name -# TODO: should we allow anonymous inline branch types? +# union 'data' member with dict value is (longhand) branch +# definition, not inline complex type { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } { 'struct': 'Base', diff --git a/tests/qapi-schema/nested-struct-data-invalid-dict.err b/tests/= qapi-schema/nested-struct-data-invalid-dict.err index c044b2b17a..375e155fe6 100644 --- a/tests/qapi-schema/nested-struct-data-invalid-dict.err +++ b/tests/qapi-schema/nested-struct-data-invalid-dict.err @@ -1,2 +1,2 @@ nested-struct-data-invalid-dict.json: In command 'foo': -nested-struct-data-invalid-dict.json:2: 'data' member 'a' misses key 'type' +nested-struct-data-invalid-dict.json:3: 'data' member 'a' misses key 'type' diff --git a/tests/qapi-schema/nested-struct-data-invalid-dict.json b/tests= /qapi-schema/nested-struct-data-invalid-dict.json index efbe773ded..aa37b85e19 100644 --- a/tests/qapi-schema/nested-struct-data-invalid-dict.json +++ b/tests/qapi-schema/nested-struct-data-invalid-dict.json @@ -1,3 +1,4 @@ -# inline subtypes collide with our desired future use of defaults +# command 'data' member with dict value is (longhand) argument +# definition, not inline complex type { 'command': 'foo', 'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } } diff --git a/tests/qapi-schema/nested-struct-data.json b/tests/qapi-schema/= nested-struct-data.json index 5b8a40cca3..2980d45d05 100644 --- a/tests/qapi-schema/nested-struct-data.json +++ b/tests/qapi-schema/nested-struct-data.json @@ -1,3 +1,3 @@ -# inline subtypes collide with our desired future use of defaults +# {} is not a valid type reference { 'command': 'foo', 'data': { 'a' : { 'type': {} }, 'b' : 'str' } } diff --git a/tests/qapi-schema/struct-member-invalid-dict.err b/tests/qapi-= schema/struct-member-invalid-dict.err index 0621aecfbd..f9b3f33551 100644 --- a/tests/qapi-schema/struct-member-invalid-dict.err +++ b/tests/qapi-schema/struct-member-invalid-dict.err @@ -1,2 +1,2 @@ struct-member-invalid-dict.json: In struct 'foo': -struct-member-invalid-dict.json:2: 'data' member '*a' misses key 'type' +struct-member-invalid-dict.json:3: 'data' member '*a' misses key 'type' diff --git a/tests/qapi-schema/struct-member-invalid-dict.json b/tests/qapi= -schema/struct-member-invalid-dict.json index 9fe0d455a9..bc3d62ae63 100644 --- a/tests/qapi-schema/struct-member-invalid-dict.json +++ b/tests/qapi-schema/struct-member-invalid-dict.json @@ -1,3 +1,4 @@ -# Long form of member must have a value member 'type' +# struct 'data' member with dict value is (longhand) member +# definition, not inline complex type { 'struct': 'foo', 'data': { '*a': { 'case': 'foo' } } } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 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=1616537229; cv=none; d=zohomail.com; s=zohoarc; b=TIKjRX43x8/QIOL3Mt9KcHgk5mEObOp+vdO3/VAC33bro/8nPSFqETq4+j4o5mwozsWymWgSk7hybg37R9COy9wC3L1AXdDLyVtOQQGBTUnnDdMQByyFmZYM32zaRNjh+kQTRFgc+it1aGQZWzcP17iG7dGY+UDM0zK9rLHKxZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537229; 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=Bb4Twvx0DzYM3S9qYxLX3oCLZr8tMW9mk4G3qccb+8I=; b=dzYrkN3mr8oZ+Cxx7ztEEFptMEYxJW7MlwG3mAMKBcaqKhCDnnwrBLa1eSs+DAknaotLl5JiyZf81SOJMA3Z2VFq4OD3f3phZdvLcN4lG4SHR9oq/vup0V18XLQsn26tr7lZnSrVRSUJBw7po2WJoNjS9TeIQ3b8ZgLvnpWUwzk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537229164769.9348123093582; Tue, 23 Mar 2021 15:07:09 -0700 (PDT) Received: from localhost ([::1]:48726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpB6-0006tB-5j for importer@patchew.org; Tue, 23 Mar 2021 18:07:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1T-00071a-TX for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1O-0002l5-9n for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-f7898g7iMiye-a-CkP_pcw-1; Tue, 23 Mar 2021 17:57:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22F54A0CA2; Tue, 23 Mar 2021 21:57:00 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E768D50DD0; Tue, 23 Mar 2021 21:56:59 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 892771132712; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536625; 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=Bb4Twvx0DzYM3S9qYxLX3oCLZr8tMW9mk4G3qccb+8I=; b=PmQIdofHd3tekwF3VBQVS37nXNLrZrgnYLmQSwh45Fewj+eS6m0r35T47iE0L+lH1su4RD O1cCCdmwf57c7AhVlijNH8MdzeJn9L34pdDBWE24jSicvL3QLqceW4S/k+8NyIvUfZw4bB TrNnkHiNw3EV0J9L8aiwrLkoMhGuiEo= X-MC-Unique: f7898g7iMiye-a-CkP_pcw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 04/29] tests/qapi-schema: Belatedly update comment on alternate clash Date: Tue, 23 Mar 2021 22:56:33 +0100 Message-Id: <20210323215658.3840228-5-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit 0426d53c65 "qapi: Simplify visiting of alternate types" eliminated the implicit alternate enum, but neglected to update a comment about it in a test. Do that now. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-5-armbru@redhat.com> Reviewed-by: John Snow --- tests/qapi-schema/alternate-clash.err | 2 +- tests/qapi-schema/alternate-clash.json | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/qapi-schema/alternate-clash.err b/tests/qapi-schema/alte= rnate-clash.err index f58b977f7b..0fe02f2c99 100644 --- a/tests/qapi-schema/alternate-clash.err +++ b/tests/qapi-schema/alternate-clash.err @@ -1,2 +1,2 @@ alternate-clash.json: In alternate 'Alt1': -alternate-clash.json:7: branch 'a_b' collides with branch 'a-b' +alternate-clash.json:4: branch 'a_b' collides with branch 'a-b' diff --git a/tests/qapi-schema/alternate-clash.json b/tests/qapi-schema/alt= ernate-clash.json index 9a59b88ced..039c4be658 100644 --- a/tests/qapi-schema/alternate-clash.json +++ b/tests/qapi-schema/alternate-clash.json @@ -1,8 +1,5 @@ # Alternate branch name collision # Reject an alternate that would result in a collision in generated C -# names (this would try to generate two enum values 'ALT1_KIND_A_B'). -# TODO: In the future, if alternates are simplified to not generate -# the implicit Alt1Kind enum, we would still have a collision with the -# resulting C union trying to have two members named 'a_b'. +# names (this would try to generate two union members named 'a_b'). { 'alternate': 'Alt1', 'data': { 'a-b': 'bool', 'a_b': 'int' } } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 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=1616536732; cv=none; d=zohomail.com; s=zohoarc; b=XijYzjtIpk39cWpiTircVfnlRjYWVeoncQ9Si0n0btkGmKJB2Md0mCJm9oAvdjSKt390pq2K0YDhtTBSEjIq31qMnUIEJtWTw6FDIBDvyxMsSp4c2P3YCGrdtfJ2BB96ZVG+J3vvA0LU4CpRHOr+BvMSk54oHIZWitFkvX+4uCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616536732; 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=kaZdviGjFloqey3uGIxgfwKMHcRrrSauuVlPypEWPKU=; b=k+pSCCmpu3mIX7/KpWKJq7Yqzc+Rrez1bbYdD/1FPtoH/HAsPpQhhNNN7JNkwX3ZyKd8Y6Yu5KuppQsnICp4ULWcdKTXkutTiwtVem4sBauQAqoVoPtzgH0S1KJ5ud3xxrkc9+osLTl0FXgjsP6RLRotBwzyI2uj/KlLNc55cHg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616536732210812.0067917582131; Tue, 23 Mar 2021 14:58:52 -0700 (PDT) Received: from localhost ([::1]:52836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp35-00019D-3h for importer@patchew.org; Tue, 23 Mar 2021 17:58:51 -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 1lOp1R-0006xX-Bm for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1N-0002l0-Pn for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-UM_-jzDwNMGfXlf-ndVkjw-1; Tue, 23 Mar 2021 17:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0A92108BD09; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FA6E50DD0; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8C8741132713; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536625; 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=kaZdviGjFloqey3uGIxgfwKMHcRrrSauuVlPypEWPKU=; b=RYfY4EroY70VVXEUkG1rM9CUbUE782ADjUb7Bk9m4yXbx3yzBq+EJyaTi9nfQaCbIluG5d TvfznMTJhhJfcmamZtDIy8v5eoTylD3fw4Bnwr2OWeLE43q4OKB8haELQKzdzVIr6nlLaZ xySb8ijQcF6+upHS8QZ4C5q7jO3CV6s= X-MC-Unique: UM_-jzDwNMGfXlf-ndVkjw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 05/29] tests/qapi-schema: Drop TODO comment on simple unions Date: Tue, 23 Mar 2021 22:56:34 +0100 Message-Id: <20210323215658.3840228-6-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Simple unions don't need more features, they need to die. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-6-armbru@redhat.com> Reviewed-by: John Snow --- tests/qapi-schema/flat-union-no-base.err | 2 +- tests/qapi-schema/flat-union-no-base.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/qapi-schema/flat-union-no-base.err b/tests/qapi-schema/f= lat-union-no-base.err index 9bd595bcfb..5167565b00 100644 --- a/tests/qapi-schema/flat-union-no-base.err +++ b/tests/qapi-schema/flat-union-no-base.err @@ -1,2 +1,2 @@ flat-union-no-base.json: In union 'TestUnion': -flat-union-no-base.json:9: 'discriminator' requires 'base' +flat-union-no-base.json:8: 'discriminator' requires 'base' diff --git a/tests/qapi-schema/flat-union-no-base.json b/tests/qapi-schema/= flat-union-no-base.json index ffc4c6f0e6..327877b563 100644 --- a/tests/qapi-schema/flat-union-no-base.json +++ b/tests/qapi-schema/flat-union-no-base.json @@ -1,5 +1,4 @@ # flat unions require a base -# TODO: simple unions should be able to use an enum discriminator { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } { 'struct': 'TestTypeB', --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 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=1616536891; cv=none; d=zohomail.com; s=zohoarc; b=jfCANIng6Xf4PNg06jaZH2RSa+By06DjEiWRol1SNf+72sf2SNf6dyyrmsTquvaSL2vwJFf3rOA1LQSXzV+2ErZpzHAohwYDpXficCpYBo7KEWba7efDrTmwkNhmR5N2RbImu/uYzh8ZtIrnHzRfKmir3YaoWXDEWRh8oqLfrrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616536891; 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=PH6SCMZh0TyLRIERQDlH7rc6cNAP4oOTF+bG7eADklE=; b=dfkNBqPxGW5jOU2Q5/VjjCuLHRowbC59rWATCkPhlOk+VHnnO5tUedUUVO1/7A8TG5lnvPhUjcrYiI8zbSPFbTMp3yNeKLJ90ZypZHNgwSSl/2gP46R1etyuI7DzIjRVj2Dwrip4Tv7FWeVyyEHXhQoFkMZOzqVkmUWgqeYMpAw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16165368913811013.6113813994031; Tue, 23 Mar 2021 15:01:31 -0700 (PDT) Received: from localhost ([::1]:60806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp5e-0005LJ-3E for importer@patchew.org; Tue, 23 Mar 2021 18:01:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0006vc-6z for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1N-0002ke-NH for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-8YwTfyE9OjC3dsfyNwHSHQ-1; Tue, 23 Mar 2021 17:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC3F6100746C; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FCC560877; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8FEA11132718; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536624; 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=PH6SCMZh0TyLRIERQDlH7rc6cNAP4oOTF+bG7eADklE=; b=M9ObqJgW/mPyL7idXHtThB0Kaw00I9or7kZYaN3INzPf74BWz7KoPnIQHzMTPLR/oqAMge CAxH81OzwGXATK9LmVNEqpc4K8b6s0tBp1k9Ac3AGjs7baYfDBNK7873gdfi+bf+WJYavn 2q3Nmbt1FLLmRRgllcLZRV5fiZmdN0o= X-MC-Unique: 8YwTfyE9OjC3dsfyNwHSHQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 06/29] tests/qapi-schema: Tweak to demonstrate buggy member name check Date: Tue, 23 Mar 2021 22:56:35 +0100 Message-Id: <20210323215658.3840228-7-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Member name 'u' and names starting with 'has-' or 'has_' are reserved for the generator. check_type() enforces this, covered by tests reserved-member-u and reserved-member-has. These tests neglect to cover optional members, where the name starts with '*'. Tweak reserved-member-u to fix that. Test reserved-member-has still covers non-optional members. This demonstrates the reserved member name check is broken for optional members. The next commit will fix it. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-7-armbru@redhat.com> Reviewed-by: John Snow [Commit message improved slightly] --- tests/qapi-schema/reserved-member-u.err | 2 -- tests/qapi-schema/reserved-member-u.json | 3 ++- tests/qapi-schema/reserved-member-u.out | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/qapi-schema/reserved-member-u.err b/tests/qapi-schema/re= served-member-u.err index 231d552494..e69de29bb2 100644 --- a/tests/qapi-schema/reserved-member-u.err +++ b/tests/qapi-schema/reserved-member-u.err @@ -1,2 +0,0 @@ -reserved-member-u.json: In struct 'Oops': -reserved-member-u.json:7: 'data' member 'u' uses reserved name diff --git a/tests/qapi-schema/reserved-member-u.json b/tests/qapi-schema/r= eserved-member-u.json index 1eaf0f301c..15005abb09 100644 --- a/tests/qapi-schema/reserved-member-u.json +++ b/tests/qapi-schema/reserved-member-u.json @@ -4,4 +4,5 @@ # This is true even for non-unions, because it is possible to convert a # struct to flat union while remaining backwards compatible in QMP. # TODO - we could munge the member name to 'q_u' to avoid the collision -{ 'struct': 'Oops', 'data': { 'u': 'str' } } +# BUG: not rejected +{ 'struct': 'Oops', 'data': { '*u': 'str' } } diff --git a/tests/qapi-schema/reserved-member-u.out b/tests/qapi-schema/re= served-member-u.out index e69de29bb2..6a3705518b 100644 --- a/tests/qapi-schema/reserved-member-u.out +++ b/tests/qapi-schema/reserved-member-u.out @@ -0,0 +1,14 @@ +module ./builtin +object q_empty +enum QType + prefix QTYPE + member none + member qnull + member qnum + member qstring + member qdict + member qlist + member qbool +module reserved-member-u.json +object Oops + member u: str optional=3DTrue --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 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=1616536732; cv=none; d=zohomail.com; s=zohoarc; b=l2n0EUdNMj2KLJN5dsmtfb3byoKsXdFPEcd/hlg+UWA0K1rUENHlHPg4QqREwIvJy13XLl5+uPLaPvuFRzdBwpkiczhLW4Cfr1yzlH7zTI/qlqXN0F4N9qhA7HJR/xzaXL5lIXt5pqkWrxhPHzMIauP+5pkkvOZEGoGm9XR1NEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616536732; 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=Gi9l3vkImGGwn367pXK1Dwjibcvg4l4ZPjXVTfFjJPY=; b=CqD+icmK2OFGMUINmWKwa+6cUmTIyY6v+UwpL6lNAUUCA2y34HYIiC685x7Q3kE3982BMmUIFaGBxE11Cpn4cU34pdZQpJKJ6ts1aw4wLUPnnBFisLscc+gOQoS/GnufMuurXxIJV0MSUn4lh0J0tvQwDdtNCPS4nRY8aB9Js0M= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616536732035181.75108762172738; Tue, 23 Mar 2021 14:58:52 -0700 (PDT) Received: from localhost ([::1]:52796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp34-00017z-Ny for importer@patchew.org; Tue, 23 Mar 2021 17:58:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0006vg-Ac for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1N-0002kb-QB for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-528-Z5m4BR07NTaDCpICSeatXQ-1; Tue, 23 Mar 2021 17:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B34298030D6; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 829D75C1C5; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 934291132719; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536624; 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=Gi9l3vkImGGwn367pXK1Dwjibcvg4l4ZPjXVTfFjJPY=; b=RBoQz77rrXn7iFfchxZ0FK+43J3W628yYfUMr2cdyopeKcrw1KepK3OFxqAArCHoIW4HC2 rVjnV6uma4TIYu9AJsMVFTVl8+bfQQsy8i3T5r29s9m4pCAgGA4Xjvva1iun1+ihptUXFv eqC3YFS9T4fXb52W+lLk0Uq0vIrhqcs= X-MC-Unique: Z5m4BR07NTaDCpICSeatXQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 07/29] qapi: Fix to reject optional members with reserved names Date: Tue, 23 Mar 2021 22:56:36 +0100 Message-Id: <20210323215658.3840228-8-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" check_type() fails to reject optional members with reserved names, because it neglects to strip off the leading '*'. Fix that. The stripping in check_name_str() is now useless. Drop. Also drop the "no leading '*'" assertion, because valid_name.match() ensures it can't fail. Fixes: 9fb081e0b98409556d023c7193eeb68947cd1211 Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-8-armbru@redhat.com> Reviewed-by: John Snow --- scripts/qapi/expr.py | 9 ++++----- tests/qapi-schema/reserved-member-u.err | 2 ++ tests/qapi-schema/reserved-member-u.json | 1 - tests/qapi-schema/reserved-member-u.out | 14 -------------- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 2fcaaa2497..cf09fa9fd3 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -34,12 +34,10 @@ def check_name_is_str(name, info, source): =20 =20 def check_name_str(name, info, source, - allow_optional=3DFalse, enum_member=3DFalse, + enum_member=3DFalse, permit_upper=3DFalse): membername =3D name =20 - if allow_optional and name.startswith('*'): - membername =3D name[1:] # Enum members can start with a digit, because the generated C # code always prefixes it with the enum name if enum_member and membername[0].isdigit(): @@ -52,7 +50,6 @@ def check_name_str(name, info, source, if not permit_upper and name.lower() !=3D name: raise QAPISemError( info, "%s uses uppercase in name" % source) - assert not membername.startswith('*') =20 =20 def check_defn_name_str(name, info, meta): @@ -171,8 +168,10 @@ def check_type(value, info, source, # value is a dictionary, check that each member is okay for (key, arg) in value.items(): key_source =3D "%s member '%s'" % (source, key) + if key.startswith('*'): + key =3D key[1:] check_name_str(key, info, key_source, - allow_optional=3DTrue, permit_upper=3Dpermit_upper) + permit_upper=3Dpermit_upper) if c_name(key, False) =3D=3D 'u' or c_name(key, False).startswith(= 'has_'): raise QAPISemError(info, "%s uses reserved name" % key_source) check_keys(arg, info, key_source, ['type'], ['if', 'features']) diff --git a/tests/qapi-schema/reserved-member-u.err b/tests/qapi-schema/re= served-member-u.err index e69de29bb2..b58e599a00 100644 --- a/tests/qapi-schema/reserved-member-u.err +++ b/tests/qapi-schema/reserved-member-u.err @@ -0,0 +1,2 @@ +reserved-member-u.json: In struct 'Oops': +reserved-member-u.json:7: 'data' member '*u' uses reserved name diff --git a/tests/qapi-schema/reserved-member-u.json b/tests/qapi-schema/r= eserved-member-u.json index 15005abb09..2bfb8f59b6 100644 --- a/tests/qapi-schema/reserved-member-u.json +++ b/tests/qapi-schema/reserved-member-u.json @@ -4,5 +4,4 @@ # This is true even for non-unions, because it is possible to convert a # struct to flat union while remaining backwards compatible in QMP. # TODO - we could munge the member name to 'q_u' to avoid the collision -# BUG: not rejected { 'struct': 'Oops', 'data': { '*u': 'str' } } diff --git a/tests/qapi-schema/reserved-member-u.out b/tests/qapi-schema/re= served-member-u.out index 6a3705518b..e69de29bb2 100644 --- a/tests/qapi-schema/reserved-member-u.out +++ b/tests/qapi-schema/reserved-member-u.out @@ -1,14 +0,0 @@ -module ./builtin -object q_empty -enum QType - prefix QTYPE - member none - member qnull - member qnum - member qstring - member qdict - member qlist - member qbool -module reserved-member-u.json -object Oops - member u: str optional=3DTrue --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537372; cv=none; d=zohomail.com; s=zohoarc; b=eMuTZtAOixNhqLCayFRvXMVJIwggtdMTnOZrEAE+xvtXdOB0D4a2iQBG/pdeyG8E2Nea5VKTXIlnABfkVFG3vxRhgi4YvvGOPhXNzuoPTGWFJhfSWY6pIxr7Vm9M2rMkBM4yaYnighQvldzXR8NWMIxUt8NHc/MPtNEZ0zecgjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537372; 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=hdPJe20CPkbu8OmUjs4Cofbzg7apEeKoHpMHjTJL7ic=; b=atRKo+h1Eenu90WtOTnhAps1397URTcss3tESvv9O4NBG4uG17TdAdQ/S/ngjXnolOEpbYEQO6ajY2srxp+06fIT4s0hcF+6jy5w79Nr81ig4ah2nMKSskGT2501lpixv+NfBk2NKYapsev1fl2HPA0GGrbPnen2N8WdcjjcTmU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537371999618.3395025880279; Tue, 23 Mar 2021 15:09:31 -0700 (PDT) Received: from localhost ([::1]:56384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpDO-0002wz-R6 for importer@patchew.org; Tue, 23 Mar 2021 18:09:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1a-00078N-2g for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0002nZ-FC for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-vfF4AIC4MIOiMyNx93wB0A-1; Tue, 23 Mar 2021 17:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0F881B2C981; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 817776087C; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 969DC113271A; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536627; 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=hdPJe20CPkbu8OmUjs4Cofbzg7apEeKoHpMHjTJL7ic=; b=XDdHlKPWQEugEmcyFcvMH7OlY4GTqOC12q8oTuYXi6zmLoIaub5AMxFg/YTavhH8tXlYyY 9ANckUqbdfWdvUXWa8m8bn66gaCtxlb+RbyyVDBZMjKEbLKOGkHOTJFG1sAMRjkJ/BzU22 fQ+V+c8gh0poI10ugLvS4Le6pYggcmA= X-MC-Unique: vfF4AIC4MIOiMyNx93wB0A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 08/29] qapi: Permit flat union members for any tag value Date: Tue, 23 Mar 2021 22:56:37 +0100 Message-Id: <20210323215658.3840228-9-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Flat union branch names match the tag enum's member names. Omitted branches default to "no members for this tag value". Branch names starting with a digit get rejected like "'data' member '0' has an invalid name". However, omitting the branch works. This is because flat union tag values get checked twice: as enum member name, and as union branch name. The former accepts leading digits, the latter doesn't. Branches whose names start with a digit therefore cannot have members. Feels wrong. Get rid of the restriction by skipping the latter check. This can expose c_name() to input it can't handle: a name starting with a digit. Improve it to return a valid C identifier for any input. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-9-armbru@redhat.com> Reviewed-by: Eric Blake [Commit message rewritten] --- scripts/qapi/common.py | 8 ++++---- scripts/qapi/expr.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 11b86beeab..cbd3fd81d3 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -18,7 +18,6 @@ #: Magic string that gets removed along with all space to its right. EATSPACE =3D '\033EATSPACE.' POINTER_SUFFIX =3D ' *' + EATSPACE -_C_NAME_TRANS =3D str.maketrans('.-', '__') =20 =20 def camel_to_upper(value: str) -> str: @@ -109,9 +108,10 @@ def c_name(name: str, protect: bool =3D True) -> str: 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq']) # namespace pollution: polluted_words =3D set(['unix', 'errno', 'mips', 'sparc', 'i386']) - name =3D name.translate(_C_NAME_TRANS) - if protect and (name in c89_words | c99_words | c11_words | gcc_words - | cpp_words | polluted_words): + name =3D re.sub(r'[^A-Za-z0-9_]', '_', name) + if protect and (name in (c89_words | c99_words | c11_words | gcc_words + | cpp_words | polluted_words) + or name[0].isdigit()): return 'q_' + name return name =20 diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index cf09fa9fd3..507550c340 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -246,7 +246,9 @@ def check_union(expr, info): =20 for (key, value) in members.items(): source =3D "'data' member '%s'" % key - check_name_str(key, info, source) + if discriminator is None: + check_name_str(key, info, source) + # else: name is in discriminator enum, which gets checked check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) check_type(value['type'], info, source, allow_array=3Dnot base) --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616536889; cv=none; d=zohomail.com; s=zohoarc; b=F73mWm5c0BgNaC8QEMorkf/TH/xOJte0urIWIrcDcMuAqX0kugapSpNmbZS8R0zbglNOIdaK+OB5MSRWUgveH2gi6bA9xw9TqDpSDPCeMnsE4+bupLl49/EEwg6kVg4f5SWXHhdkiXu7ulWJoQ8830QaVpm5m3fexP/sBn8cFJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616536889; 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=p7MBbAOeP3f9ji971POfdHs7zCSjkCBBIDGIaVD6EhY=; b=da5SP3GXurT9UcgOlSD6edN4ZpNwr5biqmFjMBlf6LCUMnXqg/Eh2WC9nRt7YNgU/Oqg9GKDODXPBWTQ5gvJMOUCxyMrgIXAY5K3CNeXSBATlA/Ppki+B9dGccs6x77WMlcRq7p9E6PcXk6zdlAfyHPLQUtXTDg2SlCgUZ/Jkvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616536889749249.04349043636114; Tue, 23 Mar 2021 15:01:29 -0700 (PDT) Received: from localhost ([::1]:60790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp5c-0005Kk-AW for importer@patchew.org; Tue, 23 Mar 2021 18:01:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1R-0006wt-3B for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58599) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1N-0002kd-VT for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-281-CHSJFwJEOl2KjzHiSUM_nQ-1; Tue, 23 Mar 2021 17:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0D4C800D53; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FD3F5DEAD; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 99D0C113271B; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536624; 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=p7MBbAOeP3f9ji971POfdHs7zCSjkCBBIDGIaVD6EhY=; b=aDPi7XNiEPQpPYApzpC9WMxnGEdVs97ooFDaJNoXydQjDprvjvbA+FxYZKksbY9uSmJNGD 7kszbHt5dsh90sx/t8rgfEE0uvQ8TFeqUHRB/Jhp0XngR3Ssy6S/DoaspRkLSEPnBDJShJ luSv3TEbARt3rOW0ITBDCrDqqyUQlYI= X-MC-Unique: CHSJFwJEOl2KjzHiSUM_nQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 09/29] qapi: Lift enum-specific code out of check_name_str() Date: Tue, 23 Mar 2021 22:56:38 +0100 Message-Id: <20210323215658.3840228-10-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" check_name_str() masks leading digits when passed enum_member=3DTrue. Only check_enum() does. Lift the masking into check_enum(). Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-10-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/expr.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 507550c340..e00467636c 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -34,18 +34,11 @@ def check_name_is_str(name, info, source): =20 =20 def check_name_str(name, info, source, - enum_member=3DFalse, permit_upper=3DFalse): - membername =3D name - - # Enum members can start with a digit, because the generated C - # code always prefixes it with the enum name - if enum_member and membername[0].isdigit(): - membername =3D 'D' + membername # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty' # and 'q_obj_*' implicit type names. - if not valid_name.match(membername) or \ - c_name(membername, False).startswith('q_'): + if not valid_name.match(name) or \ + c_name(name, False).startswith('q_'): raise QAPISemError(info, "%s has an invalid name" % source) if not permit_upper and name.lower() !=3D name: raise QAPISemError( @@ -213,11 +206,15 @@ def check_enum(expr, info): for m in members] for member in members: source =3D "'data' member" + member_name =3D member['name'] check_keys(member, info, source, ['name'], ['if']) - check_name_is_str(member['name'], info, source) - source =3D "%s '%s'" % (source, member['name']) - check_name_str(member['name'], info, source, - enum_member=3DTrue, permit_upper=3Dpermit_upper) + check_name_is_str(member_name, info, source) + source =3D "%s '%s'" % (source, member_name) + # Enum members may start with a digit + if member_name[0].isdigit(): + member_name =3D 'd' + member_name # Hack: hide the digit + check_name_str(member_name, info, source, + permit_upper=3Dpermit_upper) check_if(member, info, source) =20 =20 --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537668; cv=none; d=zohomail.com; s=zohoarc; b=X4TZhG386zH99KsLUAWGsg4HOISvIyLsKNXGugd9LidT1fpHrasDDrb62pzBdOPawkgpiIMOAQcHNXafBjVh0NupPRrFB5+jDeAm/V92ltG27DFPjrXpAd5wJIO0peQ5kVDFSNc1wLbyTFDV6fBHZ4kIeK5Z/XXWOJHQixP+p5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537668; 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=Eb7mTsMCeC8fidipvCeWAXFLlCOarcflghZSEAnHgvs=; b=Brr0l87wU+VE0M1mSA96/0hPbG6pvvKDsBqNGTtoP7iZb/pasqaxIS7a3BPmzfYcRF43g/lJZ4lePVqXQxjE5IW0TzcP1eIHTTZmv1cAON/pLQgcqObisf6+cL/wOVuVZpJzbmwD7y7jqCgC7n4tfvMQIpsCRG2g43jOjaLExC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537668672568.7964039858306; Tue, 23 Mar 2021 15:14:28 -0700 (PDT) Received: from localhost ([::1]:44326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpIA-0003fT-FS for importer@patchew.org; Tue, 23 Mar 2021 18:14:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1l-0007ME-0i for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54243) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0002nc-FN for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-dT3qYh33PXycoFEU-nUkCw-1; Tue, 23 Mar 2021 17:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9CD11007474; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 821EE610A8; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9D1FA113271C; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536627; 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=Eb7mTsMCeC8fidipvCeWAXFLlCOarcflghZSEAnHgvs=; b=YK8lIQcFj8GSrMV8qfUj/ZljqCVCCs32i+5h81RGm1OPldqwC7yRPyfO7/zGyA6anbwAMy WyUqxyA14XVKEMMyd+NC8a8DHdbqEitAIzG1E8Bs1WxGPsjJ4Ehef597fW6VvvPBuM0LgM 2U+ZvVmwkX0eq5YDoYCGE1Uzub5AUT8= X-MC-Unique: dT3qYh33PXycoFEU-nUkCw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 10/29] qapi: Rework name checking in preparation of stricter checking Date: Tue, 23 Mar 2021 22:56:39 +0100 Message-Id: <20210323215658.3840228-11-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Naming rules differ for the various kinds of names. To prepare enforcing them, define functions to check them: check_name_upper(), check_name_lower(), and check_name_camel(). For now, these merely wrap around check_name_str(), but that will change shortly. Replace the other uses of check_name_str() by appropriate uses of the wrappers. No change in behavior just yet. check_name_str() now returns the name without downstream and x- prefix, for use by the wrappers in later patches. Requires tweaking regexp @valid_name. It accepts the same strings as before. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-11-armbru@redhat.com> Reviewed-by: Eric Blake [Commit message improved] --- scripts/qapi/expr.py | 51 +++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index e00467636c..30285fe334 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -21,11 +21,12 @@ from .error import QAPISemError =20 =20 -# Names must be letters, numbers, -, and _. They must start with letter, -# except for downstream extensions which must start with __RFQDN_. -# Dots are only valid in the downstream extension prefix. -valid_name =3D re.compile(r'^(__[a-zA-Z0-9.-]+_)?' - '[a-zA-Z][a-zA-Z0-9_-]*$') +# Names consist of letters, digits, -, and _, starting with a letter. +# An experimental name is prefixed with x-. A name of a downstream +# extension is prefixed with __RFQDN_. The latter prefix goes first. +valid_name =3D re.compile(r'(__[a-z0-9.-]+_)?' + r'(x-)?' + r'([a-z][a-z0-9_-]*)$', re.IGNORECASE) =20 =20 def check_name_is_str(name, info, source): @@ -37,16 +38,38 @@ def check_name_str(name, info, source, permit_upper=3DFalse): # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty' # and 'q_obj_*' implicit type names. - if not valid_name.match(name) or \ - c_name(name, False).startswith('q_'): + match =3D valid_name.match(name) + if not match or c_name(name, False).startswith('q_'): raise QAPISemError(info, "%s has an invalid name" % source) if not permit_upper and name.lower() !=3D name: raise QAPISemError( info, "%s uses uppercase in name" % source) + return match.group(3) + + +def check_name_upper(name, info, source): + stem =3D check_name_str(name, info, source, permit_upper=3DTrue) + # TODO reject '[a-z-]' in @stem + + +def check_name_lower(name, info, source, + permit_upper=3DFalse): + stem =3D check_name_str(name, info, source, permit_upper) + # TODO reject '_' in stem + + +def check_name_camel(name, info, source): + stem =3D check_name_str(name, info, source, permit_upper=3DTrue) + # TODO reject '[_-]' in stem, require CamelCase =20 =20 def check_defn_name_str(name, info, meta): - check_name_str(name, info, meta, permit_upper=3DTrue) + if meta =3D=3D 'event': + check_name_upper(name, info, meta) + elif meta =3D=3D 'command': + check_name_lower(name, info, meta, permit_upper=3DTrue) + else: + check_name_camel(name, info, meta) if name.endswith('Kind') or name.endswith('List'): raise QAPISemError( info, "%s name should not end in '%s'" % (meta, name[-4:])) @@ -163,8 +186,7 @@ def check_type(value, info, source, key_source =3D "%s member '%s'" % (source, key) if key.startswith('*'): key =3D key[1:] - check_name_str(key, info, key_source, - permit_upper=3Dpermit_upper) + check_name_lower(key, info, key_source, permit_upper) if c_name(key, False) =3D=3D 'u' or c_name(key, False).startswith(= 'has_'): raise QAPISemError(info, "%s uses reserved name" % key_source) check_keys(arg, info, key_source, ['type'], ['if', 'features']) @@ -186,7 +208,7 @@ def check_features(features, info): check_keys(f, info, source, ['name'], ['if']) check_name_is_str(f['name'], info, source) source =3D "%s '%s'" % (source, f['name']) - check_name_str(f['name'], info, source) + check_name_lower(f['name'], info, source) check_if(f, info, source) =20 =20 @@ -213,8 +235,7 @@ def check_enum(expr, info): # Enum members may start with a digit if member_name[0].isdigit(): member_name =3D 'd' + member_name # Hack: hide the digit - check_name_str(member_name, info, source, - permit_upper=3Dpermit_upper) + check_name_lower(member_name, info, source, permit_upper) check_if(member, info, source) =20 =20 @@ -244,7 +265,7 @@ def check_union(expr, info): for (key, value) in members.items(): source =3D "'data' member '%s'" % key if discriminator is None: - check_name_str(key, info, source) + check_name_lower(key, info, source) # else: name is in discriminator enum, which gets checked check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) @@ -258,7 +279,7 @@ def check_alternate(expr, info): raise QAPISemError(info, "'data' must not be empty") for (key, value) in members.items(): source =3D "'data' member '%s'" % key - check_name_str(key, info, source) + check_name_lower(key, info, source) check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) check_type(value['type'], info, source) --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537591; cv=none; d=zohomail.com; s=zohoarc; b=nVuncDYDYtqVcppTME8CMAWlkS0c9gQG9f3F+VM5lXJNikfuAHuydvu9PTJaAgjJet/yCnqgAdt1RbqQZaD3jagAqd0b/Cqbz7QyOZYDMNa8C1trUitjRoRb6Ry3jSkjNl20BpWmvpo2SPZ0h/iaHOHmQK2LvTOX4FVqE1+yf08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537591; 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=0/KIBW1QPXWRz/AffdiQM4DbqUD+Wco6EeEefGLSZLQ=; b=ldvT73DHje8UVDQzi+Ecd+8NzhZDHeuGifMCZI3M1pK86ufSMbuUSx9NXdSZt3aHJK9CZ4NLxF1Q7hq2U+yY88Ip3Exmb5/VBV09CiuP4T6qv4xpYS9YMGPhHk4qCkFujPtDP2p8KgXRgdWsa783ak3V8i2sm18GyhEHVWJEoX4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537591479443.4843471320762; Tue, 23 Mar 2021 15:13:11 -0700 (PDT) Received: from localhost ([::1]:39060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpGw-0000R6-Ds for importer@patchew.org; Tue, 23 Mar 2021 18:13:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1f-0007H5-0s for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28757) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0002nQ-5W for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-155-ts3Em8LgNCqOG9r5lECJaw-1; Tue, 23 Mar 2021 17:57:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF1B88030B5; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C0AF963BA7; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A05D9113271E; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536627; 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=0/KIBW1QPXWRz/AffdiQM4DbqUD+Wco6EeEefGLSZLQ=; b=Ha1ADI1c6Qhd+25psajwfz79Qq21kN/DH1CgQVxcFV1cfHubSem0MrXgNM3Kf4vjo465T0 rfa4nxXklvgz7SZs1Sp7EXri569lYUh8VovDRwDfGFdWmSqyMRCpwXxODONASDYnEvw5cf 1ZYJnKmtCOrgd9gJJD5PLBbH0GD+WLA= X-MC-Unique: ts3Em8LgNCqOG9r5lECJaw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 11/29] qapi: Move uppercase rejection to check_name_lower() Date: Tue, 23 Mar 2021 22:56:40 +0100 Message-Id: <20210323215658.3840228-12-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" check_name_lower() is the only user of check_name_str() using permit_upper=3DFalse. Move the associated code from check_name_str() to check_name_lower(), and drop the parameter. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-12-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/expr.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 30285fe334..a815060ee2 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -34,32 +34,31 @@ def check_name_is_str(name, info, source): raise QAPISemError(info, "%s requires a string name" % source) =20 =20 -def check_name_str(name, info, source, - permit_upper=3DFalse): +def check_name_str(name, info, source): # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty' # and 'q_obj_*' implicit type names. match =3D valid_name.match(name) if not match or c_name(name, False).startswith('q_'): raise QAPISemError(info, "%s has an invalid name" % source) - if not permit_upper and name.lower() !=3D name: - raise QAPISemError( - info, "%s uses uppercase in name" % source) return match.group(3) =20 =20 def check_name_upper(name, info, source): - stem =3D check_name_str(name, info, source, permit_upper=3DTrue) + stem =3D check_name_str(name, info, source) # TODO reject '[a-z-]' in @stem =20 =20 def check_name_lower(name, info, source, permit_upper=3DFalse): - stem =3D check_name_str(name, info, source, permit_upper) + stem =3D check_name_str(name, info, source) + if not permit_upper and name.lower() !=3D name: + raise QAPISemError( + info, "%s uses uppercase in name" % source) # TODO reject '_' in stem =20 =20 def check_name_camel(name, info, source): - stem =3D check_name_str(name, info, source, permit_upper=3DTrue) + stem =3D check_name_str(name, info, source) # TODO reject '[_-]' in stem, require CamelCase =20 =20 --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537372; cv=none; d=zohomail.com; s=zohoarc; b=bpuKjsCBKasgT7BwiVmdPBceALep58PNT90GtfQfVBFoOFiaDlimulOL4nzY4/vRvkjJQfZUDTCpeCV7/Gxc8BvO5i5Lif6IDZFYfBe9qjxPByxVI4TosHQxkr0S80ekuJgaXBkZrESvpfpFCkPB6vcJ3if+SY0iUqn056Se9mY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537372; 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=RDiXmR2TTEsN6LbnZF98k6cnE4MbF+oWNJuw04k0aEg=; b=I4v8nbO2AAQqkmn1ft0DyXXkTgUsSqu2gfeH/QfBkLNtAizdMoKuTYON2Nl12MocFsAhvcz/E6UcPvJJo0kaIlLwDkAjXOgQGy3zjNDfgxLZe0SN8kSp6Xca1PFpzNFESsWFb5t22ow/B8/wEvjavrkdxUqeQnpNw2JCh3Gkj6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537372590485.4361034047919; Tue, 23 Mar 2021 15:09:32 -0700 (PDT) Received: from localhost ([::1]:56348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpDO-0002vt-W9 for importer@patchew.org; Tue, 23 Mar 2021 18:09:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1X-000745-AM for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1O-0002lZ-Hi for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-155-0CxNhis5NLyDqWdpEXHHMQ-1; Tue, 23 Mar 2021 17:57:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAF98A0CA0; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC1A350DD0; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A39E6113271F; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536625; 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=RDiXmR2TTEsN6LbnZF98k6cnE4MbF+oWNJuw04k0aEg=; b=C4to1RflQ2JuAC5BedUol5W7BzVhvp23uHpEV2vdzohK9FHSKSgBvMp35Xu/OVUN9I8KTC MVzGRxHBVS1NUftn0jcvSrweOYUo7NjfGDALKbc/PyQciLFAriAhA6mlgi79ulVXC2UusU h/9P8T1ecelarNpz9gGXqTGBxuAmjMQ= X-MC-Unique: 0CxNhis5NLyDqWdpEXHHMQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 12/29] qapi: Consistently permit any case in downstream prefixes Date: Tue, 23 Mar 2021 22:56:41 +0100 Message-Id: <20210323215658.3840228-13-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We require lowercase __RFQDN_ downstream prefixes only where we require the prefixed name to be lowercase. Don't; permit any case in __RFQDN_ prefixes anywhere. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-13-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/expr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index a815060ee2..b5fb0be48b 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -51,7 +51,7 @@ def check_name_upper(name, info, source): def check_name_lower(name, info, source, permit_upper=3DFalse): stem =3D check_name_str(name, info, source) - if not permit_upper and name.lower() !=3D name: + if not permit_upper and re.search(r'[A-Z]', stem): raise QAPISemError( info, "%s uses uppercase in name" % source) # TODO reject '_' in stem --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616536892; cv=none; d=zohomail.com; s=zohoarc; b=Z4mgZD7qdEOLZP3JeuKP9hYnqoyjpvmuPa+pqZYCOmNkOkm9NcQL+cA9RH1MH/Y+l6fH5B9cnk0ho/gV2stopPDtsDdfzysuhUqs0lyX4L7Pvwu9XSswltXZe+SEINzZMrvvvc1iUKk7YARE48LRLaX4qlH8sbxr6z0KP8Rucvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616536892; 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=ua5t9NARTvfXg6KfDvdnBWANQ9V3QhqddfP3KeodY0k=; b=hQr7w2HgU8tJOmNsvkf+RW9F1u28YlEJ9dPI+WIpx4swp6NfF4WIsxz2R9ixcU1oXLHwos1eO/nrPktz3iNUzjG6QzqDKCKb72WekyADYUgVIf+uw/DG9drVXi+Wu19MonG530tTwHcQ7DbeBF2GBJV3qAPuItwTyWznSbuV8bQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616536892129567.9881006553348; Tue, 23 Mar 2021 15:01:32 -0700 (PDT) Received: from localhost ([::1]:60886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp5f-0005O5-24 for importer@patchew.org; Tue, 23 Mar 2021 18:01:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1U-00071m-5p for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1O-0002ln-HT for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-HZWEyZHTPxqpN6HYiLn8Iw-1; Tue, 23 Mar 2021 17:57:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F77F1007476; Tue, 23 Mar 2021 21:57:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C075F60245; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A707D11326A0; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536625; 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=ua5t9NARTvfXg6KfDvdnBWANQ9V3QhqddfP3KeodY0k=; b=Rtmw4V0KFMnZvKI69Z856oN/tL9r0bKvpIuHma7/0bsY75EDzU20dQlNIyQpGD7OqHwygL c603PCGvWG5bmIUXWisZUic1N3+2Lk/fu62TibAi0+A39fYzRwvOIxTSwwe3UW+wxI1hfb FyrKyvU+h8mMgj75TLobr/Zbzk7zhdg= X-MC-Unique: HZWEyZHTPxqpN6HYiLn8Iw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 13/29] qapi: Enforce event naming rules Date: Tue, 23 Mar 2021 22:56:42 +0100 Message-Id: <20210323215658.3840228-14-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Event names should be ALL_CAPS with words separated by underscore. Enforce this. The only offenders are in tests/. Fix them. Existing test event-case covers the new error. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-14-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/unit/test-qmp-event.c | 6 +++--- scripts/qapi/expr.py | 4 +++- tests/qapi-schema/doc-good.json | 4 ++-- tests/qapi-schema/doc-good.out | 4 ++-- tests/qapi-schema/doc-good.txt | 2 +- tests/qapi-schema/doc-invalid-return.json | 4 ++-- tests/qapi-schema/event-case.err | 2 ++ tests/qapi-schema/event-case.json | 2 -- tests/qapi-schema/event-case.out | 14 -------------- tests/qapi-schema/qapi-schema-test.json | 6 +++--- tests/qapi-schema/qapi-schema-test.out | 8 ++++---- 11 files changed, 22 insertions(+), 34 deletions(-) diff --git a/tests/unit/test-qmp-event.c b/tests/unit/test-qmp-event.c index 047f44ff9a..d58c3b78f2 100644 --- a/tests/unit/test-qmp-event.c +++ b/tests/unit/test-qmp-event.c @@ -143,7 +143,7 @@ static void test_event_d(TestEventData *data, =20 static void test_event_deprecated(TestEventData *data, const void *unused) { - data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST-EVENT-FEATU= RES1' }"); + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST_EVENT_FEATU= RES1' }"); =20 memset(&compat_policy, 0, sizeof(compat_policy)); =20 @@ -163,7 +163,7 @@ static void test_event_deprecated_data(TestEventData *d= ata, const void *unused) { memset(&compat_policy, 0, sizeof(compat_policy)); =20 - data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST-EVENT-FEATU= RES0'," + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST_EVENT_FEATU= RES0'," " 'data': { 'foo': 42 } }"); qapi_event_send_test_event_features0(42); g_assert(data->emitted); @@ -172,7 +172,7 @@ static void test_event_deprecated_data(TestEventData *d= ata, const void *unused) =20 compat_policy.has_deprecated_output =3D true; compat_policy.deprecated_output =3D COMPAT_POLICY_OUTPUT_HIDE; - data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST-EVENT-FEATU= RES0' }"); + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST_EVENT_FEATU= RES0' }"); qapi_event_send_test_event_features0(42); g_assert(data->emitted); =20 diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index b5fb0be48b..c065505b27 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -45,7 +45,9 @@ def check_name_str(name, info, source): =20 def check_name_upper(name, info, source): stem =3D check_name_str(name, info, source) - # TODO reject '[a-z-]' in @stem + if re.search(r'[a-z-]', stem): + raise QAPISemError( + info, "name of %s must not use lowercase or '-'" % source) =20 =20 def check_name_lower(name, info, source, diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index e9af0857db..423ea23e07 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -179,10 +179,10 @@ 'features': [ 'cmd-feat1', 'cmd-feat2' ] } =20 ## -# @EVT-BOXED: +# @EVT_BOXED: # Features: # @feat3: a feature ## -{ 'event': 'EVT-BOXED', 'boxed': true, +{ 'event': 'EVT_BOXED', 'boxed': true, 'features': [ 'feat3' ], 'data': 'Object' } diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 715b0bbc1a..8f54ceff2e 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -63,7 +63,7 @@ command cmd-boxed Object -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse feature cmd-feat1 feature cmd-feat2 -event EVT-BOXED Object +event EVT_BOXED Object boxed=3DTrue feature feat3 doc freeform @@ -211,7 +211,7 @@ another feature -> in =20 <- out -doc symbol=3DEVT-BOXED +doc symbol=3DEVT_BOXED body=3D =20 feature=3Dfeat3 diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 6ca03d49d0..726727af74 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -272,7 +272,7 @@ Example <- out =20 =20 -"EVT-BOXED" (Event) +"EVT_BOXED" (Event) ------------------- =20 =20 diff --git a/tests/qapi-schema/doc-invalid-return.json b/tests/qapi-schema/= doc-invalid-return.json index 1ba45de414..95e7583930 100644 --- a/tests/qapi-schema/doc-invalid-return.json +++ b/tests/qapi-schema/doc-invalid-return.json @@ -1,7 +1,7 @@ # Events can't have 'Returns' section =20 ## -# @foo: +# @FOO: # Returns: blah ## -{ 'event': 'foo' } +{ 'event': 'FOO' } diff --git a/tests/qapi-schema/event-case.err b/tests/qapi-schema/event-cas= e.err index e69de29bb2..d3007cfa63 100644 --- a/tests/qapi-schema/event-case.err +++ b/tests/qapi-schema/event-case.err @@ -0,0 +1,2 @@ +event-case.json: In event 'oops': +event-case.json:1: name of event must not use lowercase or '-' diff --git a/tests/qapi-schema/event-case.json b/tests/qapi-schema/event-ca= se.json index 3a92d8b610..4d8a5d8a71 100644 --- a/tests/qapi-schema/event-case.json +++ b/tests/qapi-schema/event-case.json @@ -1,3 +1 @@ -# TODO: might be nice to enforce naming conventions; but until then this w= orks -# even though events should usually be ALL_CAPS { 'event': 'oops' } diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-cas= e.out index 9ae44052ac..e69de29bb2 100644 --- a/tests/qapi-schema/event-case.out +++ b/tests/qapi-schema/event-case.out @@ -1,14 +0,0 @@ -module ./builtin -object q_empty -enum QType - prefix QTYPE - member none - member qnull - member qnum - member qstring - member qdict - member qlist - member qbool -module event-case.json -event oops None - boxed=3DFalse diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 12ec588b52..a355321258 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -249,7 +249,7 @@ =20 { 'command': 'TestCmdReturnDefThree', 'returns': 'UserDefThree' } =20 -{ 'event': 'TestIfEvent', 'data': +{ 'event': 'TEST_IF_EVENT', 'data': { 'foo': 'TestIfStruct', 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' } @@ -324,8 +324,8 @@ 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] }= ] } =20 -{ 'event': 'TEST-EVENT-FEATURES0', +{ 'event': 'TEST_EVENT_FEATURES0', 'data': 'FeatureStruct1' } =20 -{ 'event': 'TEST-EVENT-FEATURES1', +{ 'event': 'TEST_EVENT_FEATURES1', 'features': [ 'deprecated' ] } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index f5741df97f..882d0e7c56 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -349,12 +349,12 @@ command TestCmdReturnDefThree None -> UserDefThree gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse array TestIfEnumList TestIfEnum if ['defined(TEST_IF_ENUM)'] -object q_obj_TestIfEvent-arg +object q_obj_TEST_IF_EVENT-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnumList optional=3DFalse if ['defined(TEST_IF_EVT_BAR)'] if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)'] -event TestIfEvent q_obj_TestIfEvent-arg +event TEST_IF_EVENT q_obj_TEST_IF_EVENT-arg boxed=3DFalse if ['defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)'] object FeatureStruct0 @@ -440,9 +440,9 @@ command test-command-cond-features3 None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse feature feature1 if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] -event TEST-EVENT-FEATURES0 FeatureStruct1 +event TEST_EVENT_FEATURES0 FeatureStruct1 boxed=3DFalse -event TEST-EVENT-FEATURES1 None +event TEST_EVENT_FEATURES1 None boxed=3DFalse feature deprecated module include/sub-module.json --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537087; cv=none; d=zohomail.com; s=zohoarc; b=bABzaLF504IEzohxlJkEKklqIbtkQEqZlUF2T+OG7Vwyw+TuFz+uXgJLONhD1z+5joLpNVZO/HrMHmfXL40Zcvk0+Fy3j1pagwJOejFgBjPscjsIjhK3xyWxLCPmq49hAEACKAx8nU0Dw4XcYt9Ur6JqNYYlzjemQVffaVTxDRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537087; 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=oO4u9YZ++qV+luw5AGlqnIh72dl8pLHeZD/b8jz3L+M=; b=oG15Ie0Utt6lRo1o4Byb5ujsYw489yMwLAmI8ULCxXA/jByi935TErKFKR2hUmWjM6bLcB7/7MZyO6kAUr5Zs9t86N8vn5YK/4pjhxWNJ1DBCaPvXeRUUR7nwiu9py6WmFXaA8ogofb+/6CoxZ/E+euCw/qfzVJ3mc+frskGM/g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537087363366.46642034114075; Tue, 23 Mar 2021 15:04:47 -0700 (PDT) Received: from localhost ([::1]:40706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp8o-0002NM-3p for importer@patchew.org; Tue, 23 Mar 2021 18:04:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1T-00070X-21 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1O-0002lk-DM for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-0aRxjp5dPAOPChZUXrKLNQ-1; Tue, 23 Mar 2021 17:57:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21E6D83DD20; Tue, 23 Mar 2021 21:57:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C0E655C1C5; Tue, 23 Mar 2021 21:57:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AA6A911326A1; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536625; 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=oO4u9YZ++qV+luw5AGlqnIh72dl8pLHeZD/b8jz3L+M=; b=RlfP8+LOl6CmuPDZ34C5sw+yqYHgkFvxjomc2NWhJXxnftuNsCsuVCrneBTlkcdPJJxg9b KlQLD09FSR6Y5SrPFhO3kv6pD7limkHSsE4yM4aYncV9ngLmTQniJyhgPt0TpHakdbpfcS /23ryO4fRAFK18/wTDwAjFhuDMFJZFE= X-MC-Unique: 0aRxjp5dPAOPChZUXrKLNQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 14/29] qapi: Enforce type naming rules Date: Tue, 23 Mar 2021 22:56:43 +0100 Message-Id: <20210323215658.3840228-15-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Type names should be CamelCase. Enforce this. The only offenders are in tests/. Fix them. Add test type-case to cover the new error. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-15-armbru@redhat.com> Reviewed-by: Eric Blake [Regexp simplified, new test made more robust] --- scripts/qapi/expr.py | 3 ++- tests/qapi-schema/doc-bad-union-member.json | 4 ++-- tests/qapi-schema/double-type.err | 2 +- tests/qapi-schema/double-type.json | 2 +- tests/qapi-schema/features-deprecated-type.err | 2 +- tests/qapi-schema/features-deprecated-type.json | 2 +- tests/qapi-schema/meson.build | 1 + tests/qapi-schema/redefined-builtin.err | 4 ++-- tests/qapi-schema/redefined-builtin.json | 4 ++-- tests/qapi-schema/redefined-type.err | 6 +++--- tests/qapi-schema/redefined-type.json | 4 ++-- tests/qapi-schema/struct-data-invalid.err | 2 +- tests/qapi-schema/struct-data-invalid.json | 2 +- tests/qapi-schema/struct-member-invalid-dict.err | 2 +- tests/qapi-schema/struct-member-invalid-dict.json | 2 +- tests/qapi-schema/struct-member-invalid.err | 2 +- tests/qapi-schema/struct-member-invalid.json | 2 +- tests/qapi-schema/type-case.err | 2 ++ tests/qapi-schema/type-case.json | 2 ++ tests/qapi-schema/type-case.out | 0 tests/qapi-schema/unknown-expr-key.err | 2 +- tests/qapi-schema/unknown-expr-key.json | 2 +- 22 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 tests/qapi-schema/type-case.err create mode 100644 tests/qapi-schema/type-case.json create mode 100644 tests/qapi-schema/type-case.out diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index c065505b27..7bd15559de 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -61,7 +61,8 @@ def check_name_lower(name, info, source, =20 def check_name_camel(name, info, source): stem =3D check_name_str(name, info, source) - # TODO reject '[_-]' in stem, require CamelCase + if not re.match(r'[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$', stem): + raise QAPISemError(info, "name of %s must use CamelCase" % source) =20 =20 def check_defn_name_str(name, info, meta): diff --git a/tests/qapi-schema/doc-bad-union-member.json b/tests/qapi-schem= a/doc-bad-union-member.json index d611435f6a..bd231a0109 100644 --- a/tests/qapi-schema/doc-bad-union-member.json +++ b/tests/qapi-schema/doc-bad-union-member.json @@ -11,9 +11,9 @@ 'data': { 'nothing': 'Empty' } } =20 { 'struct': 'Base', - 'data': { 'type': 'T' } } + 'data': { 'type': 'FrobType' } } =20 { 'struct': 'Empty', 'data': { } } =20 -{ 'enum': 'T', 'data': ['nothing'] } +{ 'enum': 'FrobType', 'data': ['nothing'] } diff --git a/tests/qapi-schema/double-type.err b/tests/qapi-schema/double-t= ype.err index 71fc4dbb52..576e716197 100644 --- a/tests/qapi-schema/double-type.err +++ b/tests/qapi-schema/double-type.err @@ -1,3 +1,3 @@ -double-type.json: In struct 'bar': +double-type.json: In struct 'Bar': double-type.json:2: struct has unknown key 'command' Valid keys are 'base', 'data', 'features', 'if', 'struct'. diff --git a/tests/qapi-schema/double-type.json b/tests/qapi-schema/double-= type.json index 911fa7af50..2c0809f38d 100644 --- a/tests/qapi-schema/double-type.json +++ b/tests/qapi-schema/double-type.json @@ -1,2 +1,2 @@ # we reject an expression with ambiguous metatype -{ 'command': 'foo', 'struct': 'bar', 'data': { } } +{ 'command': 'foo', 'struct': 'Bar', 'data': { } } diff --git a/tests/qapi-schema/features-deprecated-type.err b/tests/qapi-sc= hema/features-deprecated-type.err index af4ffe20aa..ddaedf604e 100644 --- a/tests/qapi-schema/features-deprecated-type.err +++ b/tests/qapi-schema/features-deprecated-type.err @@ -1,2 +1,2 @@ -features-deprecated-type.json: In struct 'S': +features-deprecated-type.json: In struct 'Foo': features-deprecated-type.json:2: feature 'deprecated' is not supported for= types diff --git a/tests/qapi-schema/features-deprecated-type.json b/tests/qapi-s= chema/features-deprecated-type.json index 4b5bf5b86e..265849b1f7 100644 --- a/tests/qapi-schema/features-deprecated-type.json +++ b/tests/qapi-schema/features-deprecated-type.json @@ -1,3 +1,3 @@ # Feature 'deprecated' is not supported for types -{ 'struct': 'S', 'data': {}, +{ 'struct': 'Foo', 'data': {}, 'features': [ 'deprecated' ] } diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index d5fa035507..ba11cb76ac 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -180,6 +180,7 @@ schemas =3D [ 'trailing-comma-list.json', 'trailing-comma-object.json', 'type-bypass-bad-gen.json', + 'type-case.json', 'unclosed-list.json', 'unclosed-object.json', 'unclosed-string.json', diff --git a/tests/qapi-schema/redefined-builtin.err b/tests/qapi-schema/re= defined-builtin.err index 58c7e42ffc..92bc62dc76 100644 --- a/tests/qapi-schema/redefined-builtin.err +++ b/tests/qapi-schema/redefined-builtin.err @@ -1,2 +1,2 @@ -redefined-builtin.json: In struct 'size': -redefined-builtin.json:2: built-in type 'size' is already defined +redefined-builtin.json: In struct 'QType': +redefined-builtin.json:2: enum type 'QType' is already defined diff --git a/tests/qapi-schema/redefined-builtin.json b/tests/qapi-schema/r= edefined-builtin.json index 45b8a550ad..cad555cc73 100644 --- a/tests/qapi-schema/redefined-builtin.json +++ b/tests/qapi-schema/redefined-builtin.json @@ -1,2 +1,2 @@ -# we reject types that duplicate builtin names -{ 'struct': 'size', 'data': { 'myint': 'size' } } +# we reject types that clash with predefined types +{ 'struct': 'QType', 'data': { 'myint': 'size' } } diff --git a/tests/qapi-schema/redefined-type.err b/tests/qapi-schema/redef= ined-type.err index b7103fc15f..5e5406f811 100644 --- a/tests/qapi-schema/redefined-type.err +++ b/tests/qapi-schema/redefined-type.err @@ -1,4 +1,4 @@ -redefined-type.json: In enum 'foo': -redefined-type.json:3: 'foo' is already defined -redefined-type.json: In struct 'foo': +redefined-type.json: In enum 'Foo': +redefined-type.json:3: 'Foo' is already defined +redefined-type.json: In struct 'Foo': redefined-type.json:2: previous definition diff --git a/tests/qapi-schema/redefined-type.json b/tests/qapi-schema/rede= fined-type.json index a09e768bae..291453e70d 100644 --- a/tests/qapi-schema/redefined-type.json +++ b/tests/qapi-schema/redefined-type.json @@ -1,3 +1,3 @@ # we reject types defined more than once -{ 'struct': 'foo', 'data': { 'one': 'str' } } -{ 'enum': 'foo', 'data': [ 'two' ] } +{ 'struct': 'Foo', 'data': { 'one': 'str' } } +{ 'enum': 'Foo', 'data': [ 'two' ] } diff --git a/tests/qapi-schema/struct-data-invalid.err b/tests/qapi-schema/= struct-data-invalid.err index 5ed4bec573..23cbfc60ea 100644 --- a/tests/qapi-schema/struct-data-invalid.err +++ b/tests/qapi-schema/struct-data-invalid.err @@ -1,2 +1,2 @@ -struct-data-invalid.json: In struct 'foo': +struct-data-invalid.json: In struct 'Foo': struct-data-invalid.json:1: 'data' should be an object or type name diff --git a/tests/qapi-schema/struct-data-invalid.json b/tests/qapi-schema= /struct-data-invalid.json index 9adbc3bb6b..00ad11ef94 100644 --- a/tests/qapi-schema/struct-data-invalid.json +++ b/tests/qapi-schema/struct-data-invalid.json @@ -1,2 +1,2 @@ -{ 'struct': 'foo', +{ 'struct': 'Foo', 'data': false } diff --git a/tests/qapi-schema/struct-member-invalid-dict.err b/tests/qapi-= schema/struct-member-invalid-dict.err index f9b3f33551..517793cc9b 100644 --- a/tests/qapi-schema/struct-member-invalid-dict.err +++ b/tests/qapi-schema/struct-member-invalid-dict.err @@ -1,2 +1,2 @@ -struct-member-invalid-dict.json: In struct 'foo': +struct-member-invalid-dict.json: In struct 'Foo': struct-member-invalid-dict.json:3: 'data' member '*a' misses key 'type' diff --git a/tests/qapi-schema/struct-member-invalid-dict.json b/tests/qapi= -schema/struct-member-invalid-dict.json index bc3d62ae63..df5d018f65 100644 --- a/tests/qapi-schema/struct-member-invalid-dict.json +++ b/tests/qapi-schema/struct-member-invalid-dict.json @@ -1,4 +1,4 @@ # struct 'data' member with dict value is (longhand) member # definition, not inline complex type -{ 'struct': 'foo', +{ 'struct': 'Foo', 'data': { '*a': { 'case': 'foo' } } } diff --git a/tests/qapi-schema/struct-member-invalid.err b/tests/qapi-schem= a/struct-member-invalid.err index 9a2c934538..7e01a41d7c 100644 --- a/tests/qapi-schema/struct-member-invalid.err +++ b/tests/qapi-schema/struct-member-invalid.err @@ -1,2 +1,2 @@ -struct-member-invalid.json: In struct 'foo': +struct-member-invalid.json: In struct 'Foo': struct-member-invalid.json:1: 'data' member 'a' should be a type name diff --git a/tests/qapi-schema/struct-member-invalid.json b/tests/qapi-sche= ma/struct-member-invalid.json index 8f172f7a87..a4cd860c67 100644 --- a/tests/qapi-schema/struct-member-invalid.json +++ b/tests/qapi-schema/struct-member-invalid.json @@ -1,2 +1,2 @@ -{ 'struct': 'foo', +{ 'struct': 'Foo', 'data': { 'a': false } } diff --git a/tests/qapi-schema/type-case.err b/tests/qapi-schema/type-case.= err new file mode 100644 index 0000000000..36d2de2d00 --- /dev/null +++ b/tests/qapi-schema/type-case.err @@ -0,0 +1,2 @@ +type-case.json: In struct 'not-a-camel': +type-case.json:2: name of struct must use CamelCase diff --git a/tests/qapi-schema/type-case.json b/tests/qapi-schema/type-case= .json new file mode 100644 index 0000000000..a43c68e7eb --- /dev/null +++ b/tests/qapi-schema/type-case.json @@ -0,0 +1,2 @@ +# Type names should use CamelCase +{ 'struct': 'not-a-camel', 'data': {} } diff --git a/tests/qapi-schema/type-case.out b/tests/qapi-schema/type-case.= out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/unknown-expr-key.err b/tests/qapi-schema/unk= nown-expr-key.err index c5f395bf79..f2538e3ce7 100644 --- a/tests/qapi-schema/unknown-expr-key.err +++ b/tests/qapi-schema/unknown-expr-key.err @@ -1,3 +1,3 @@ -unknown-expr-key.json: In struct 'bar': +unknown-expr-key.json: In struct 'Bar': unknown-expr-key.json:2: struct has unknown keys 'bogus', 'phony' Valid keys are 'base', 'data', 'features', 'if', 'struct'. diff --git a/tests/qapi-schema/unknown-expr-key.json b/tests/qapi-schema/un= known-expr-key.json index 13292d75ed..8003a0c36e 100644 --- a/tests/qapi-schema/unknown-expr-key.json +++ b/tests/qapi-schema/unknown-expr-key.json @@ -1,2 +1,2 @@ # we reject an expression with unknown top-level keys -{ 'struct': 'bar', 'data': { 'string': 'str'}, 'bogus': { }, 'phony': { } } +{ 'struct': 'Bar', 'data': { 'string': 'str'}, 'bogus': { }, 'phony': { } } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537474; cv=none; d=zohomail.com; s=zohoarc; b=De4kQkSZ6UxDsfGCVSfUD+fHpaYNx4eiSn1ace44ISPG9hIrMgbyJ4wq+u0bnLrnI2JM+uHsOeJ588EPy7ZNOqPC7mu8i6C5l6YEEK3Mb8LcDG8hPBG3L6Scv1ax+lWqQkkw49rNXsG1cDSVt3di+X8EOHE6VOEwpRL89rHvE54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537474; 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=owElM5L4n18qKa0mu/5QrYM624ElKwa6DpjKZ3UKHx8=; b=XivHNeEuGDosoIZzWKHsdn3ovty3b8POt3LMajQPDBW99nzA4WtCBM402BhKlAYFdGXNufTThkuydkr+s/bFsWXN49p/naqSd7bLkVB68enFGjX1pOD11JXl6y7RtFL4IK54ECsXwJt8PBy5SWdyhld5++ameUU5AgPH7BBRa3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537474089817.2777227684245; Tue, 23 Mar 2021 15:11:14 -0700 (PDT) Received: from localhost ([::1]:35954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpF3-0007D8-05 for importer@patchew.org; Tue, 23 Mar 2021 18:11:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1X-00073r-59 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30941) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1P-0002md-Em for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-3eQ-AZVtOnO1EranUwOMWQ-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67CB41B2C984; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 316141F07C; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B3B1811326A2; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=owElM5L4n18qKa0mu/5QrYM624ElKwa6DpjKZ3UKHx8=; b=cwk2XDG1XrKwecFXCB6lcJnnY0UDscRl22DHCftmFFbQIuMr3TtBtGvyEUo6y+TAGVgU3V uk/ByQHZk5uM6bRWUkZuLxf8/FuYJybFdDRzdHFItfy6aNACUwwDy6g+rzFcBSLaJdi+tq r88OKkHX4VXeYv9+ePgM07DmQj3lss8= X-MC-Unique: 3eQ-AZVtOnO1EranUwOMWQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 15/29] tests/qapi-schema: Rename redefined-builtin to redefined-predefined Date: Tue, 23 Mar 2021 22:56:44 +0100 Message-Id: <20210323215658.3840228-16-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The previous commit changed this test to clash with a predefined enum type, not a built-in type. Adjust its name. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-16-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/qapi-schema/meson.build | 2 +- tests/qapi-schema/redefined-builtin.err | 2 -- tests/qapi-schema/redefined-predefined.err | 2 ++ .../{redefined-builtin.json =3D> redefined-predefined.json} | 0 .../{redefined-builtin.out =3D> redefined-predefined.out} | 0 5 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 tests/qapi-schema/redefined-builtin.err create mode 100644 tests/qapi-schema/redefined-predefined.err rename tests/qapi-schema/{redefined-builtin.json =3D> redefined-predefined= .json} (100%) rename tests/qapi-schema/{redefined-builtin.out =3D> redefined-predefined.= out} (100%) diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index ba11cb76ac..664f9ee22d 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -152,9 +152,9 @@ schemas =3D [ 'pragma-returns-whitelist-crap.json', 'qapi-schema-test.json', 'quoted-structural-chars.json', - 'redefined-builtin.json', 'redefined-command.json', 'redefined-event.json', + 'redefined-predefined.json', 'redefined-type.json', 'reserved-command-q.json', 'reserved-enum-q.json', diff --git a/tests/qapi-schema/redefined-builtin.err b/tests/qapi-schema/re= defined-builtin.err deleted file mode 100644 index 92bc62dc76..0000000000 --- a/tests/qapi-schema/redefined-builtin.err +++ /dev/null @@ -1,2 +0,0 @@ -redefined-builtin.json: In struct 'QType': -redefined-builtin.json:2: enum type 'QType' is already defined diff --git a/tests/qapi-schema/redefined-predefined.err b/tests/qapi-schema= /redefined-predefined.err new file mode 100644 index 0000000000..2924dde60b --- /dev/null +++ b/tests/qapi-schema/redefined-predefined.err @@ -0,0 +1,2 @@ +redefined-predefined.json: In struct 'QType': +redefined-predefined.json:2: enum type 'QType' is already defined diff --git a/tests/qapi-schema/redefined-builtin.json b/tests/qapi-schema/r= edefined-predefined.json similarity index 100% rename from tests/qapi-schema/redefined-builtin.json rename to tests/qapi-schema/redefined-predefined.json diff --git a/tests/qapi-schema/redefined-builtin.out b/tests/qapi-schema/re= defined-predefined.out similarity index 100% rename from tests/qapi-schema/redefined-builtin.out rename to tests/qapi-schema/redefined-predefined.out --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537374; cv=none; d=zohomail.com; s=zohoarc; b=CEMQ8UFSTMjSg3oM5fwzpGUvWwYsMffIzEBkE5x4S48B7Ya5Zkv7l6N1Hc197EV6GdoSGtBRkf4Fw5WQ+C1+r4tt2JGhUNM7BA4kvX5ebU+iwUt9ECqJAfugQw1CzVb5MUu5QwX+npAQo0w0kZpygbbghCir+krFhUsg3yoLP+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537374; 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=flo14ZI1uMO4FevF6YW+gZZCBEx08J1IumCEZo9DURQ=; b=FSUlOBPBI1bQEKAwCwP5OH2wJ1egpPC8pBNa0kbiLviTxc5y83Iy3fGgEO6v0780NeUIN42BSIdZaU7oQUK0kV5dBrRow5wToHl7K6NyoUnASDPKpldNI5/ilg3DV2i3sYiQ4z9uMzxq3BSh4Ci0FCeK8y74JqLtiHu/qmrE/3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537374120510.1872680230699; Tue, 23 Mar 2021 15:09:34 -0700 (PDT) Received: from localhost ([::1]:56548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpDQ-000328-Q2 for importer@patchew.org; Tue, 23 Mar 2021 18:09:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1g-0007In-Sv for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1R-0002nv-2D for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-GhcglaprMZmOhNH3-G2LEA-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5FC39108BD06; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30DD160245; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BB24211326A3; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536628; 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=flo14ZI1uMO4FevF6YW+gZZCBEx08J1IumCEZo9DURQ=; b=GFMvb/cWaGmdOhmswcqA5QjhIe9vhmK1hm1GbwfyiYn9FNsC7efSlICOL5zeexfwqks4ko lQTbnU5AVA55nwxHNLqt2UTEID+ePTIRSPmgJb8/If6a9zr6pXfU+OAKuHJOLn0sDM1PrZ PkJ5mi5UqDAjUTwgaMxpRgUQX6O5S8E= X-MC-Unique: GhcglaprMZmOhNH3-G2LEA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 16/29] qapi: Factor out QAPISchemaParser._check_pragma_list_of_str() Date: Tue, 23 Mar 2021 22:56:45 +0100 Message-Id: <20210323215658.3840228-17-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-17-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/parser.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 116afe549a..8eed69333f 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -119,6 +119,13 @@ def _include(self, include, info, incl_fname, previous= ly_included): =20 return QAPISchemaParser(incl_fname, previously_included, info) =20 + def _check_pragma_list_of_str(self, name, value, info): + if (not isinstance(value, list) + or any([not isinstance(elt, str) for elt in value])): + raise QAPISemError( + info, + "pragma %s must be a list of strings" % name) + def _pragma(self, name, value, info): if name =3D=3D 'doc-required': if not isinstance(value, bool): @@ -126,18 +133,10 @@ def _pragma(self, name, value, info): "pragma 'doc-required' must be boolean") info.pragma.doc_required =3D value elif name =3D=3D 'returns-whitelist': - if (not isinstance(value, list) - or any([not isinstance(elt, str) for elt in value])): - raise QAPISemError( - info, - "pragma returns-whitelist must be a list of strings") + self._check_pragma_list_of_str(name, value, info) info.pragma.returns_whitelist =3D value elif name =3D=3D 'name-case-whitelist': - if (not isinstance(value, list) - or any([not isinstance(elt, str) for elt in value])): - raise QAPISemError( - info, - "pragma name-case-whitelist must be a list of strings") + self._check_pragma_list_of_str(name, value, info) info.pragma.name_case_whitelist =3D value else: raise QAPISemError(info, "unknown pragma '%s'" % name) --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537844; cv=none; d=zohomail.com; s=zohoarc; b=NnteA349FP5pX0zcY+mUlarQ47w2qMxwF0uHvlbOovnE+AchgEeqPLTMpcXWY1vc99HT9IKcGSRkTnbO7NIkfQfC4woYG/wI2BYovXMknjSXIIXsH5H/bqSOVDFQd+EAM8mrCiuswf2XfJsu93ZdocE3Fy/wGlxW/8weA5NgOlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537844; 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=+xpZanZqGb7TazAu0Z6lqnwzuWa8Bs2h1wE77WIvK9c=; b=TvBydCLIwK2g+6Z/uEZ+yPmAyykkWvXN2dcrH9JUQwHp4mlacDo0UA95AW2xJjuaE9VC4U9znxbZ0pwBAItP6TnT4TYT7TU/zisHscgGgLsjxQBJBakmxx9ySlcSPyUKYvR57dClLU84JO8rjNNFLK/MOd3nPupC+aKugi8n8LQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537844486410.746120622831; Tue, 23 Mar 2021 15:17:24 -0700 (PDT) Received: from localhost ([::1]:52980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpL0-0008BG-8D for importer@patchew.org; Tue, 23 Mar 2021 18:17:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1p-0007Re-Kk for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1R-0002nu-5R for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-604-BZko93RxMUqUQT_zokf34g-1; Tue, 23 Mar 2021 17:57:05 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E99101B2C983; Tue, 23 Mar 2021 21:57:04 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 319FF1F41B; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C174811326A4; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536628; 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=+xpZanZqGb7TazAu0Z6lqnwzuWa8Bs2h1wE77WIvK9c=; b=gpxf4U04bijNW/vS0XGvleAPFXceDjGesxpbI/R6T9erhhTG09t3t03d/EgI/cIfTcsr/+ OWOZQVT/cmJT4yNulQGi/fWSfUyo2NrlyFKFQif7FfFOAaRqkdZRbHYNivkB5csu2vSx1O ZVDME62afVNG8KHGICeBovh9nXLrRCQ= X-MC-Unique: BZko93RxMUqUQT_zokf34g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 17/29] tests/qapi-schema: Rename pragma-*-crap to pragma-value-not-* Date: Tue, 23 Mar 2021 22:56:46 +0100 Message-Id: <20210323215658.3840228-18-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_SPACE_RATIO=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Rename pragma-doc-required-crap to pragma-not-bool, pragma-returns-whitelist-crap to pragma-value-not-list, and pragma-name-case-whitelist-crap to pragma-value-not-list-of-str. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-18-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/qapi-schema/meson.build | 6 +++--- tests/qapi-schema/pragma-doc-required-crap.err | 1 - tests/qapi-schema/pragma-name-case-whitelist-crap.err | 1 - tests/qapi-schema/pragma-returns-whitelist-crap.err | 1 - tests/qapi-schema/pragma-value-not-bool.err | 1 + ...ma-doc-required-crap.json =3D> pragma-value-not-bool.json} | 2 +- ...agma-doc-required-crap.out =3D> pragma-value-not-bool.out} | 0 tests/qapi-schema/pragma-value-not-list-of-str.err | 1 + ...hitelist-crap.json =3D> pragma-value-not-list-of-str.json} | 2 +- ...-whitelist-crap.out =3D> pragma-value-not-list-of-str.out} | 0 tests/qapi-schema/pragma-value-not-list.err | 1 + ...-case-whitelist-crap.json =3D> pragma-value-not-list.json} | 2 +- ...returns-whitelist-crap.out =3D> pragma-value-not-list.out} | 0 13 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 tests/qapi-schema/pragma-doc-required-crap.err delete mode 100644 tests/qapi-schema/pragma-name-case-whitelist-crap.err delete mode 100644 tests/qapi-schema/pragma-returns-whitelist-crap.err create mode 100644 tests/qapi-schema/pragma-value-not-bool.err rename tests/qapi-schema/{pragma-doc-required-crap.json =3D> pragma-value-= not-bool.json} (55%) rename tests/qapi-schema/{pragma-doc-required-crap.out =3D> pragma-value-n= ot-bool.out} (100%) create mode 100644 tests/qapi-schema/pragma-value-not-list-of-str.err rename tests/qapi-schema/{pragma-returns-whitelist-crap.json =3D> pragma-v= alue-not-list-of-str.json} (57%) rename tests/qapi-schema/{pragma-name-case-whitelist-crap.out =3D> pragma-= value-not-list-of-str.out} (100%) create mode 100644 tests/qapi-schema/pragma-value-not-list.err rename tests/qapi-schema/{pragma-name-case-whitelist-crap.json =3D> pragma= -value-not-list.json} (50%) rename tests/qapi-schema/{pragma-returns-whitelist-crap.out =3D> pragma-va= lue-not-list.out} (100%) diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 664f9ee22d..ffc276b765 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -144,12 +144,12 @@ schemas =3D [ 'oob-coroutine.json', 'oob-test.json', 'allow-preconfig-test.json', - 'pragma-doc-required-crap.json', 'pragma-extra-junk.json', - 'pragma-name-case-whitelist-crap.json', 'pragma-non-dict.json', 'pragma-unknown.json', - 'pragma-returns-whitelist-crap.json', + 'pragma-value-not-bool.json', + 'pragma-value-not-list-of-str.json', + 'pragma-value-not-list.json', 'qapi-schema-test.json', 'quoted-structural-chars.json', 'redefined-command.json', diff --git a/tests/qapi-schema/pragma-doc-required-crap.err b/tests/qapi-sc= hema/pragma-doc-required-crap.err deleted file mode 100644 index 717062cb14..0000000000 --- a/tests/qapi-schema/pragma-doc-required-crap.err +++ /dev/null @@ -1 +0,0 @@ -pragma-doc-required-crap.json:3: pragma 'doc-required' must be boolean diff --git a/tests/qapi-schema/pragma-name-case-whitelist-crap.err b/tests/= qapi-schema/pragma-name-case-whitelist-crap.err deleted file mode 100644 index fbea90d6c5..0000000000 --- a/tests/qapi-schema/pragma-name-case-whitelist-crap.err +++ /dev/null @@ -1 +0,0 @@ -pragma-name-case-whitelist-crap.json:3: pragma name-case-whitelist must be= a list of strings diff --git a/tests/qapi-schema/pragma-returns-whitelist-crap.err b/tests/qa= pi-schema/pragma-returns-whitelist-crap.err deleted file mode 100644 index 69784259df..0000000000 --- a/tests/qapi-schema/pragma-returns-whitelist-crap.err +++ /dev/null @@ -1 +0,0 @@ -pragma-returns-whitelist-crap.json:3: pragma returns-whitelist must be a l= ist of strings diff --git a/tests/qapi-schema/pragma-value-not-bool.err b/tests/qapi-schem= a/pragma-value-not-bool.err new file mode 100644 index 0000000000..6247539616 --- /dev/null +++ b/tests/qapi-schema/pragma-value-not-bool.err @@ -0,0 +1 @@ +pragma-value-not-bool.json:3: pragma 'doc-required' must be boolean diff --git a/tests/qapi-schema/pragma-doc-required-crap.json b/tests/qapi-s= chema/pragma-value-not-bool.json similarity index 55% rename from tests/qapi-schema/pragma-doc-required-crap.json rename to tests/qapi-schema/pragma-value-not-bool.json index ed763c5ffc..feb489f15b 100644 --- a/tests/qapi-schema/pragma-doc-required-crap.json +++ b/tests/qapi-schema/pragma-value-not-bool.json @@ -1,3 +1,3 @@ -# 'doc-required' must be bool +# pragma value must be bool =20 { 'pragma': { 'doc-required': {} } } diff --git a/tests/qapi-schema/pragma-doc-required-crap.out b/tests/qapi-sc= hema/pragma-value-not-bool.out similarity index 100% rename from tests/qapi-schema/pragma-doc-required-crap.out rename to tests/qapi-schema/pragma-value-not-bool.out diff --git a/tests/qapi-schema/pragma-value-not-list-of-str.err b/tests/qap= i-schema/pragma-value-not-list-of-str.err new file mode 100644 index 0000000000..44870fe5d9 --- /dev/null +++ b/tests/qapi-schema/pragma-value-not-list-of-str.err @@ -0,0 +1 @@ +pragma-value-not-list-of-str.json:3: pragma returns-whitelist must be a li= st of strings diff --git a/tests/qapi-schema/pragma-returns-whitelist-crap.json b/tests/q= api-schema/pragma-value-not-list-of-str.json similarity index 57% rename from tests/qapi-schema/pragma-returns-whitelist-crap.json rename to tests/qapi-schema/pragma-value-not-list-of-str.json index f6b81b093f..12bbbed2e8 100644 --- a/tests/qapi-schema/pragma-returns-whitelist-crap.json +++ b/tests/qapi-schema/pragma-value-not-list-of-str.json @@ -1,3 +1,3 @@ -# 'returns-whitelist' must be list of strings +# pragma value must be list of strings =20 { 'pragma': { 'returns-whitelist': [ 'good', [ 'bad' ] ] } } diff --git a/tests/qapi-schema/pragma-name-case-whitelist-crap.out b/tests/= qapi-schema/pragma-value-not-list-of-str.out similarity index 100% rename from tests/qapi-schema/pragma-name-case-whitelist-crap.out rename to tests/qapi-schema/pragma-value-not-list-of-str.out diff --git a/tests/qapi-schema/pragma-value-not-list.err b/tests/qapi-schem= a/pragma-value-not-list.err new file mode 100644 index 0000000000..21736c5723 --- /dev/null +++ b/tests/qapi-schema/pragma-value-not-list.err @@ -0,0 +1 @@ +pragma-value-not-list.json:3: pragma name-case-whitelist must be a list of= strings diff --git a/tests/qapi-schema/pragma-name-case-whitelist-crap.json b/tests= /qapi-schema/pragma-value-not-list.json similarity index 50% rename from tests/qapi-schema/pragma-name-case-whitelist-crap.json rename to tests/qapi-schema/pragma-value-not-list.json index 734e1c617b..2c61a97dd3 100644 --- a/tests/qapi-schema/pragma-name-case-whitelist-crap.json +++ b/tests/qapi-schema/pragma-value-not-list.json @@ -1,3 +1,3 @@ -# 'name-case-whitelist' must be list of strings +# pragma value must be list =20 { 'pragma': { 'name-case-whitelist': false } } diff --git a/tests/qapi-schema/pragma-returns-whitelist-crap.out b/tests/qa= pi-schema/pragma-value-not-list.out similarity index 100% rename from tests/qapi-schema/pragma-returns-whitelist-crap.out rename to tests/qapi-schema/pragma-value-not-list.out --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537226; cv=none; d=zohomail.com; s=zohoarc; b=KvtLaTTT7xm3/NxN6p0rT2yuJfll8pjyX/mgKL+yfZwoQ68uATiTL+SW3HB9ULkuS6SHP+yatCojflDjSVBQ2LTO/syTGxLqN4f9g7xbV9m/rFuaJxosJKAwv5ypfIxeWY3ptleZDr3DWbn+NHzBbxovhz4pLgjs/HeUjie8BcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537226; 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=21nJvjA+GH2g+nMkZt6Wt4tRob7Dh6P7KVMyu2vIfpg=; b=E/SpN7OgH8bp4EflxtRr0Q+zrC9T+Hm778eCVYSvNM8NcCdOUAuZkkMqx5JOIwob0WeTAslQ03y1V1/Gd1SaQMrACPcHFDgXmFoEEOhRSJkMwkxym6biWPkgg+hX7kxYx3Dc5ntdhv7a/M6XB+4RjSz3rW0cD393W53wu9JFhg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161653722666950.16268669716294; Tue, 23 Mar 2021 15:07:06 -0700 (PDT) Received: from localhost ([::1]:48484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpB3-0006m8-Fc for importer@patchew.org; Tue, 23 Mar 2021 18:07:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Z-00075v-3b for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1P-0002n3-Vk for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-v23-f4aKMhm1iQm1FtFFPQ-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA436100747E; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3030D2BFC7; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C63EF11326A6; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=21nJvjA+GH2g+nMkZt6Wt4tRob7Dh6P7KVMyu2vIfpg=; b=bY8+kYbTRoIxZ8vDEqXNbIcns9Bt4wbEMO/MaGJ+3UDMB1UAQFf4LhKCqYPXG9TyISy9kU IbEAHPBGNiR/H7Ks85HL3HUGuBMjpLwtKTipEmtGuM92v+JkTRj0iRtcNuAF1+/hbMO1iX EA8nCOQ9cB5i4C1ekMepKyu3bi/+bdA= X-MC-Unique: v23-f4aKMhm1iQm1FtFFPQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 18/29] tests/qapi-schema: Rename returns-whitelist to returns-bad-type Date: Tue, 23 Mar 2021 22:56:47 +0100 Message-Id: <20210323215658.3840228-19-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This test covers returning "bad" types. Pragma returns-whitelist is just one aspect. Naming it returns-whitelist is suboptimal. Rename to returns-bad-type. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-19-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/qapi-schema/meson.build | 2 +- tests/qapi-schema/returns-bad-type.err | 2 ++ .../{returns-whitelist.json =3D> returns-bad-type.json} | 0 .../qapi-schema/{returns-whitelist.out =3D> returns-bad-type.out} | 0 tests/qapi-schema/returns-whitelist.err | 2 -- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 tests/qapi-schema/returns-bad-type.err rename tests/qapi-schema/{returns-whitelist.json =3D> returns-bad-type.jso= n} (100%) rename tests/qapi-schema/{returns-whitelist.out =3D> returns-bad-type.out}= (100%) delete mode 100644 tests/qapi-schema/returns-whitelist.err diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index ffc276b765..4e7635f0a8 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -166,9 +166,9 @@ schemas =3D [ 'reserved-type-list.json', 'returns-alternate.json', 'returns-array-bad.json', + 'returns-bad-type.json', 'returns-dict.json', 'returns-unknown.json', - 'returns-whitelist.json', 'string-code-point-31.json', 'string-code-point-127.json', 'struct-base-clash-deep.json', diff --git a/tests/qapi-schema/returns-bad-type.err b/tests/qapi-schema/ret= urns-bad-type.err new file mode 100644 index 0000000000..2c270de9ad --- /dev/null +++ b/tests/qapi-schema/returns-bad-type.err @@ -0,0 +1,2 @@ +returns-bad-type.json: In command 'no-way-this-will-get-whitelisted': +returns-bad-type.json:14: command's 'returns' cannot take array type ['int= '] diff --git a/tests/qapi-schema/returns-whitelist.json b/tests/qapi-schema/r= eturns-bad-type.json similarity index 100% rename from tests/qapi-schema/returns-whitelist.json rename to tests/qapi-schema/returns-bad-type.json diff --git a/tests/qapi-schema/returns-whitelist.out b/tests/qapi-schema/re= turns-bad-type.out similarity index 100% rename from tests/qapi-schema/returns-whitelist.out rename to tests/qapi-schema/returns-bad-type.out diff --git a/tests/qapi-schema/returns-whitelist.err b/tests/qapi-schema/re= turns-whitelist.err deleted file mode 100644 index c6e46b9b86..0000000000 --- a/tests/qapi-schema/returns-whitelist.err +++ /dev/null @@ -1,2 +0,0 @@ -returns-whitelist.json: In command 'no-way-this-will-get-whitelisted': -returns-whitelist.json:14: command's 'returns' cannot take array type ['in= t'] --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616538190; cv=none; d=zohomail.com; s=zohoarc; b=W/CUxsY7DLriiVIUKXr8zYco9hugB5DW89suSr3JXPjY+CBDAzA++owXIPfyNGWZUT4IDoJvMCZG12JEDEMNVxI5uRlFcTs4L5clEezbTQpqkzMoNGZuhPRWnmUau99rpe+ZypaWj/aNI3PV7l/gkeP+TVdoGHnNIehZunWP8sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616538190; 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=oK3tQ2uWaIc3eX+TrlnBNSz3nwtMZ0vz2Ih0d1LKk4A=; b=U3R9L51zHkPFs3KyRLnyNhk+9DhL3ExbeYGTW+WLdtWGJFuWaQylDNWM5Vc6XRtauOUiu+kKpc7Pi4PmlVmWJDME74Vf8vzDZrLW/x/P3g9raodNcLLSLt45hPHY371hamCPD0TBrbz48GiKNjPFVnYWzlwVnTsjg0a7F9y4e1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616538190849889.4053954989025; Tue, 23 Mar 2021 15:23:10 -0700 (PDT) Received: from localhost ([::1]:41288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpQb-0007wi-K1 for importer@patchew.org; Tue, 23 Mar 2021 18:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1u-0007YN-PG for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1T-0002ov-Jf for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-pqZd_OvBPPCRcHn0UYQRtw-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 896651B2C988; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 318AC1B581; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CB4C611326A7; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536629; 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=oK3tQ2uWaIc3eX+TrlnBNSz3nwtMZ0vz2Ih0d1LKk4A=; b=KUHytrsKnecrJYGeT8sD6lQuVkwxKcQCUAAXI0X/23GaNh+pIh1M4iA/8y4FypBpZ4JP4f GvmqMbPkbJzmI9u3+BUWUKBCX/rh53qj+uGuyEL9Lnjjg8VBm0kEM4lYxO3aMPHpng5dtm /ez4SMYXRtGBkVsDMcCKN09OGinv6e4= X-MC-Unique: pqZd_OvBPPCRcHn0UYQRtw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 19/29] qapi: Rename pragma *-whitelist to *-exceptions Date: Tue, 23 Mar 2021 22:56:48 +0100 Message-Id: <20210323215658.3840228-20-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Rename pragma returns-whitelist to command-returns-exceptions, and name-case-whitelist to member-name-case-exceptions. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-20-armbru@redhat.com> Reviewed-by: Eric Blake --- docs/devel/qapi-code-gen.txt | 21 ++++++++++--------- qapi/pragma.json | 4 ++-- qga/qapi-schema.json | 2 +- scripts/qapi/expr.py | 4 ++-- scripts/qapi/parser.py | 8 +++---- scripts/qapi/schema.py | 2 +- scripts/qapi/source.py | 8 +++---- tests/qapi-schema/enum-member-case.json | 2 +- .../pragma-value-not-list-of-str.err | 2 +- .../pragma-value-not-list-of-str.json | 2 +- tests/qapi-schema/pragma-value-not-list.err | 2 +- tests/qapi-schema/pragma-value-not-list.json | 3 +-- tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/returns-bad-type.json | 2 +- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 6906a06ad2..23e9823019 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -147,9 +147,10 @@ prevent incomplete include files. =3D=3D=3D Pragma directives =3D=3D=3D =20 Syntax: - PRAGMA =3D { 'pragma': { '*doc-required': BOOL, - '*returns-whitelist': [ STRING, ... ], - '*name-case-whitelist': [ STRING, ... ] } } + PRAGMA =3D { 'pragma': { + '*doc-required': BOOL, + '*command-returns-exceptions': [ STRING, ... ], + '*member-name-exceptions': [ STRING, ... ] } } =20 The pragma directive lets you control optional generator behavior. =20 @@ -159,11 +160,11 @@ pragma to different values in parts of the schema doe= sn't work. Pragma 'doc-required' takes a boolean value. If true, documentation is required. Default is false. =20 -Pragma 'returns-whitelist' takes a list of command names that may +Pragma 'command-returns-exceptions' takes a list of commands that may violate the rules on permitted return types. Default is none. =20 -Pragma 'name-case-whitelist' takes a list of names that may violate -rules on use of upper- vs. lower-case letters. Default is none. +Pragma 'member-name-exceptions' takes a list of types whose member +names may contain uppercase letters. Default is none. =20 =20 =3D=3D=3D Enumeration types =3D=3D=3D @@ -490,9 +491,9 @@ are the arguments. A union type requires 'boxed': true. Member 'returns' defines the command's return type. It defaults to an empty struct type. It must normally be a complex type or an array of a complex type. To return anything else, the command must be listed -in pragma 'returns-whitelist'. If you do this, extending the command -to return additional information will be harder. Use of -'returns-whitelist' for new commands is strongly discouraged. +in pragma 'commands-returns-exceptions'. If you do this, extending +the command to return additional information will be harder. Use of +the pragma for new commands is strongly discouraged. =20 A command's error responses are not specified in the QAPI schema. Error conditions should be documented in comments. @@ -755,7 +756,7 @@ Any name (command, event, type, member, or enum value) = beginning with "x-" is marked experimental, and may be withdrawn or changed incompatibly in a future release. =20 -Pragma 'name-case-whitelist' lets you violate the rules on use of +Pragma 'member-name-exceptions' lets you violate the rules on use of upper and lower case. Use for new code is strongly discouraged. =20 =20 diff --git a/qapi/pragma.json b/qapi/pragma.json index 7f158e183d..4895848c5e 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -4,13 +4,13 @@ # add to them! { 'pragma': { # Commands allowed to return a non-dictionary: - 'returns-whitelist': [ + 'command-returns-exceptions': [ 'human-monitor-command', 'qom-get', 'query-tpm-models', 'query-tpm-types', 'ringbuf-read' ], - 'name-case-whitelist': [ + 'member-name-exceptions': [ 'ACPISlotType', # DIMM, visible through query-acpi-osp= m-status 'BlockdevVmdkSubformat', # all members, to match VMDK spec spel= lings 'BlockdevVmdkAdapterType', # legacyESX, to match VMDK spec spelli= ngs diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 9a82b7e952..2b08b761c2 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -20,7 +20,7 @@ # add to them! { 'pragma': { # Commands allowed to return a non-dictionary: - 'returns-whitelist': [ + 'command-returns-exceptions': [ 'guest-file-open', 'guest-fsfreeze-freeze', 'guest-fsfreeze-freeze-list', diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 7bd15559de..85493efbac 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -181,7 +181,7 @@ def check_type(value, info, source, raise QAPISemError(info, "%s should be an object or type name" % source) =20 - permit_upper =3D allow_dict in info.pragma.name_case_whitelist + permit_upper =3D allow_dict in info.pragma.member_name_exceptions =20 # value is a dictionary, check that each member is okay for (key, arg) in value.items(): @@ -224,7 +224,7 @@ def check_enum(expr, info): if prefix is not None and not isinstance(prefix, str): raise QAPISemError(info, "'prefix' must be a string") =20 - permit_upper =3D name in info.pragma.name_case_whitelist + permit_upper =3D name in info.pragma.member_name_exceptions =20 members[:] =3D [m if isinstance(m, dict) else {'name': m} for m in members] diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 8eed69333f..c16b8b6995 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -132,12 +132,12 @@ def _pragma(self, name, value, info): raise QAPISemError(info, "pragma 'doc-required' must be boolean") info.pragma.doc_required =3D value - elif name =3D=3D 'returns-whitelist': + elif name =3D=3D 'command-returns-exceptions': self._check_pragma_list_of_str(name, value, info) - info.pragma.returns_whitelist =3D value - elif name =3D=3D 'name-case-whitelist': + info.pragma.command_returns_exceptions =3D value + elif name =3D=3D 'member-name-exceptions': self._check_pragma_list_of_str(name, value, info) - info.pragma.name_case_whitelist =3D value + info.pragma.member_name_exceptions =3D value else: raise QAPISemError(info, "unknown pragma '%s'" % name) =20 diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index ff16578f6d..703b446fd2 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -779,7 +779,7 @@ def check(self, schema): if self._ret_type_name: self.ret_type =3D schema.resolve_type( self._ret_type_name, self.info, "command's 'returns'") - if self.name not in self.info.pragma.returns_whitelist: + if self.name not in self.info.pragma.command_returns_exception= s: typ =3D self.ret_type if isinstance(typ, QAPISchemaArrayType): typ =3D self.ret_type.element_type diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py index d7a79a9b8a..d8f9ec377f 100644 --- a/scripts/qapi/source.py +++ b/scripts/qapi/source.py @@ -21,10 +21,10 @@ class QAPISchemaPragma: def __init__(self) -> None: # Are documentation comments required? self.doc_required =3D False - # Whitelist of commands allowed to return a non-dictionary - self.returns_whitelist: List[str] =3D [] - # Whitelist of entities allowed to violate case conventions - self.name_case_whitelist: List[str] =3D [] + # Commands allowed to return a non-dictionary + self.command_returns_exceptions: List[str] =3D [] + # Types whose member names may violate case conventions + self.member_name_exceptions: List[str] =3D [] =20 =20 class QAPISourceInfo: diff --git a/tests/qapi-schema/enum-member-case.json b/tests/qapi-schema/en= um-member-case.json index f8af3e4622..b8969d224d 100644 --- a/tests/qapi-schema/enum-member-case.json +++ b/tests/qapi-schema/enum-member-case.json @@ -1,4 +1,4 @@ # Member names should be 'lower-case' unless the enum is whitelisted -{ 'pragma': { 'name-case-whitelist': [ 'UuidInfo' ] } } +{ 'pragma': { 'member-name-exceptions': [ 'UuidInfo' ] } } { 'enum': 'UuidInfo', 'data': [ 'Value' ] } # UuidInfo is whitelisted { 'enum': 'NoWayThisWillGetWhitelisted', 'data': [ 'Value' ] } diff --git a/tests/qapi-schema/pragma-value-not-list-of-str.err b/tests/qap= i-schema/pragma-value-not-list-of-str.err index 44870fe5d9..b81983dd85 100644 --- a/tests/qapi-schema/pragma-value-not-list-of-str.err +++ b/tests/qapi-schema/pragma-value-not-list-of-str.err @@ -1 +1 @@ -pragma-value-not-list-of-str.json:3: pragma returns-whitelist must be a li= st of strings +pragma-value-not-list-of-str.json:3: pragma command-returns-exceptions mus= t be a list of strings diff --git a/tests/qapi-schema/pragma-value-not-list-of-str.json b/tests/qa= pi-schema/pragma-value-not-list-of-str.json index 12bbbed2e8..27811cff73 100644 --- a/tests/qapi-schema/pragma-value-not-list-of-str.json +++ b/tests/qapi-schema/pragma-value-not-list-of-str.json @@ -1,3 +1,3 @@ # pragma value must be list of strings =20 -{ 'pragma': { 'returns-whitelist': [ 'good', [ 'bad' ] ] } } +{ 'pragma': { 'command-returns-exceptions': [ 'good', [ 'bad' ] ] } } diff --git a/tests/qapi-schema/pragma-value-not-list.err b/tests/qapi-schem= a/pragma-value-not-list.err index 21736c5723..45dde1bf05 100644 --- a/tests/qapi-schema/pragma-value-not-list.err +++ b/tests/qapi-schema/pragma-value-not-list.err @@ -1 +1 @@ -pragma-value-not-list.json:3: pragma name-case-whitelist must be a list of= strings +pragma-value-not-list.json:2: pragma member-name-exceptions must be a list= of strings diff --git a/tests/qapi-schema/pragma-value-not-list.json b/tests/qapi-sche= ma/pragma-value-not-list.json index 2c61a97dd3..3faa340c3b 100644 --- a/tests/qapi-schema/pragma-value-not-list.json +++ b/tests/qapi-schema/pragma-value-not-list.json @@ -1,3 +1,2 @@ # pragma value must be list - -{ 'pragma': { 'name-case-whitelist': false } } +{ 'pragma': { 'member-name-exceptions': false } } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index a355321258..16b03bf308 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -7,7 +7,7 @@ # Whitelists to permit QAPI rule violations { 'pragma': { # Commands allowed to return a non-dictionary: - 'returns-whitelist': [ + 'command-returns-exceptions': [ 'guest-get-time', 'guest-sync' ] } } =20 diff --git a/tests/qapi-schema/returns-bad-type.json b/tests/qapi-schema/re= turns-bad-type.json index da209329b1..0dd96e739e 100644 --- a/tests/qapi-schema/returns-bad-type.json +++ b/tests/qapi-schema/returns-bad-type.json @@ -1,6 +1,6 @@ # we enforce that 'returns' be a dict or array of dict unless whitelisted =20 -{ 'pragma': { 'returns-whitelist': [ +{ 'pragma': { 'command-returns-exceptions': [ 'human-monitor-command', 'query-tpm-models', 'guest-get-time' ] } } =20 { 'command': 'human-monitor-command', --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537474; cv=none; d=zohomail.com; s=zohoarc; b=li/RCrCJwliMhubUj9LNioE6mDHdGTbMxl/sxwfRd46CRxC1/bUntZCcZzANFh2GyN/2foW8jua6ohFbg8po3AkLOGqog/DBJ5NGdRhjzkKs5Hw0FXRO/VP+f7SHXpTnYv/2fe157bxGCpvPlB3mmLwP9iFPylqZVDIsIdesek0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537474; 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=uNYgTYQ6USoiWLOWix/fwpu6hl/EXy12kwfJPQ11HMY=; b=fhYWDUQOjvV8ZM9TwaFUiFsnkTdsRGiYL4BLuG69smdCN0GCvCRCOmWwfW0pc745/4FmwCQGA/yLF9mm3iHgk9SnS4fABoAVzkGFxv4IIWN2U4ZMlUOEa/WOruXs56PPE4mjqnDarGox/4SwDpOI5AZa5saapxR5nLDFc63vvdk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537474842486.5064610894225; Tue, 23 Mar 2021 15:11:14 -0700 (PDT) Received: from localhost ([::1]:36046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpF3-0007GK-Ot for importer@patchew.org; Tue, 23 Mar 2021 18:11:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1c-0007EE-TE for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1P-0002mi-Jj for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-mbcoIDlLM_aVQf3e1W-JlA-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6607E108BD07; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31C0610027A5; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D019B11326A8; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=uNYgTYQ6USoiWLOWix/fwpu6hl/EXy12kwfJPQ11HMY=; b=AdA78hqqpUaYiQqtYncmux/swdHd2w6jWsuWe189agnpi8/KO0XCly5wo1qOQz8vh+nPOQ qfuXox9h1qagnL2z8Xi7914F/xgn+OLExy5NoOShBBTx5WPs8xY7QfP2EQAbS5Qelf5BFr BtqrQLy08eZIefd2++1ZBVGgZH5Vt8k= X-MC-Unique: mbcoIDlLM_aVQf3e1W-JlA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 20/29] qapi/pragma: Streamline comments on member-name-exceptions Date: Tue, 23 Mar 2021 22:56:49 +0100 Message-Id: <20210323215658.3840228-21-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-21-armbru@redhat.com> Reviewed-by: Eric Blake --- qapi/pragma.json | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qapi/pragma.json b/qapi/pragma.json index 4895848c5e..4c47c802d1 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -10,11 +10,13 @@ 'query-tpm-models', 'query-tpm-types', 'ringbuf-read' ], - 'member-name-exceptions': [ - 'ACPISlotType', # DIMM, visible through query-acpi-osp= m-status - 'BlockdevVmdkSubformat', # all members, to match VMDK spec spel= lings - 'BlockdevVmdkAdapterType', # legacyESX, to match VMDK spec spelli= ngs - 'QapiErrorClass', # all members, visible through errors - 'UuidInfo', # UUID, visible through query-uuid - 'X86CPURegister32' # all members, visible indirectly thro= ugh qom-get + # Externally visible types whose member names may use uppercase + 'member-name-exceptions': [ # visible in: + 'ACPISlotType', # query-acpi-ospm-status + 'BlockdevVmdkAdapterType', # blockdev-create (to match VMDK spec) + 'BlockdevVmdkSubformat', # blockdev-create (to match VMDK spec) + 'QapiErrorClass', # QMP error replies + 'UuidInfo', # query-uuid + 'X86CPURegister32' # qom-get of x86 CPU properties + # feature-words, filtered-features ] } } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537226; cv=none; d=zohomail.com; s=zohoarc; b=fO1H21HzRVL37LEpCW9w+Kja7t5xPbmHol8DWVfv+MqnEzM3VVXGFhmNXaFjU0guuzca9qjTHPsnR48tIiWF0Ayj/vC7Mj1evVVR4XBvkoExyVIimfE4OfmvAZEGJLi0ZaQBXEOcq3PV7ZRL7K9GNEjTSl/by2OPQLapEbbONYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537226; 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=nSMV/cddIecCl9oEn/r4ZjtLweD2WXgYLMKe655pV0U=; b=H1Q6Gusdbba29A7+vuHTYa49JSH+/425EpYQcW8G5vgqIMV7J9Hu6vuh7RVzXQruAAQ0y4+QP6K7nUyT3SfPYI1bEdomF0OBbx23eRMeiaewXh/PCkQ1ewxp7I1WIBZdZtbIPEdeMX/ys2V+tM+BaxNnaU3sBNrwtIVljvTeM9w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537226733359.32620587284885; Tue, 23 Mar 2021 15:07:06 -0700 (PDT) Received: from localhost ([::1]:48504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpB3-0006mo-KH for importer@patchew.org; Tue, 23 Mar 2021 18:07:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1V-00072F-L9 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1P-0002mZ-6q for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-540-oGgzIcZ0Pq-7IcgaN86VfA-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E50D80006E; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 301D75C1C5; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D4F1411326A9; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=nSMV/cddIecCl9oEn/r4ZjtLweD2WXgYLMKe655pV0U=; b=B5JQpJDAKCvdwFDdKk4ZxT7xrQBbRlIlIgW/8nR4q1rAV0Jz59CtY8gJDpLT/x9p8koqht rA51w8xDQthtKBHBlUhMx/z+pZdYsvLkbswP98/X3acWA6Vt3tLSBsbfjWnxvBNgKmSOEj sIeT24EanXc+D1AcycceZIhc+rFxDnk= X-MC-Unique: oGgzIcZ0Pq-7IcgaN86VfA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 21/29] tests-qmp-cmds: Drop unused and incorrect qmp_TestIfCmd() Date: Tue, 23 Mar 2021 22:56:50 +0100 Message-Id: <20210323215658.3840228-22-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Commit 967c885108 "qapi: add 'if' to top-level expressions" added command TestIfCmd with an 'if' condition. It also added the qmp_TestIfCmd() to go with it, guarded by the corresponding #if. Commit ccadd6bcba "qapi: Add 'if' to implicit struct members" changed the command, but not the function. Compiles only because we don't satisfy the #if. Instead of fixing the function, simply drop it. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-22-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/unit/test-qmp-cmds.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 266db074b4..99973dde7c 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -13,13 +13,6 @@ =20 static QmpCommandList qmp_commands; =20 -#if defined(TEST_IF_STRUCT) && defined(TEST_IF_CMD) -UserDefThree *qmp_TestIfCmd(TestIfStruct *foo, Error **errp) -{ - return NULL; -} -#endif - UserDefThree *qmp_TestCmdReturnDefThree(Error **errp) { return NULL; --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537663; cv=none; d=zohomail.com; s=zohoarc; b=A2Sb/EKwTiWSwNLV4thUopTDO6d51AzKZZxruyooOXsnqBNludZ/d5A1mAMtPw561ETCVMzct1Yfy+7ps8pGcA2TJFyRqQ+SlrJQ0cMzPZe5K+NojLJuurMh2WESuWDulV6Ez6f/kB/HJo7hjPtuMb7b8HwmfdgCLJMUHXOcH+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537663; 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=tsOa68U6Xk22tJB7tqfHBwMm/s558J14Szlclr9+N5w=; b=Z8CYGUJphlFTaiJm8F0HcOMS8XhN2EjIvxESAK3J4gyw0HKyb+UyFbWzJ1IewVkqQbRy8PusUi1wgITLD4FynKANn2ZseGwmHmhaikfvwmWkrKPDPcgfC1rnheMxUw9gMHJt9w8QG8TalEEGG/q9YBnXr29gs+r5QqCYyguGMqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537663377873.3615002633712; Tue, 23 Mar 2021 15:14:23 -0700 (PDT) Received: from localhost ([::1]:43948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpI6-0003UY-2q for importer@patchew.org; Tue, 23 Mar 2021 18:14:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Z-000769-7W for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0002nL-29 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-FjdXZph-O0-NnlqwgxKnmg-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 849BBA0CA6; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30B835D6AD; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DE53B11326AA; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536627; 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=tsOa68U6Xk22tJB7tqfHBwMm/s558J14Szlclr9+N5w=; b=IvKvtbPZc3Z78NcFAWQEyDFM0RmFdt1ZKWL5wFv9IQyje3TZ9n8IsKDQqhPYWQlMtcFu1b nq0rj7OhSHfYbvBoujuVqswbtZr0Mmkqgz+uiwJ2Pzvncog+STSHClI1MXGON21lcQlcex 2oKZGMaiXsA5OsCt/tm3tJY8uyE2OMY= X-MC-Unique: FjdXZph-O0-NnlqwgxKnmg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 22/29] qapi: Prepare for rejecting underscore in command and member names Date: Tue, 23 Mar 2021 22:56:51 +0100 Message-Id: <20210323215658.3840228-23-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Command names and member names within a type should be all lower case with words separated by a hyphen. We also accept underscore. Rework check_name_lower() to optionally reject underscores, but don't use that option, yet. Update expected test output for the changed error message. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-23-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/expr.py | 24 ++++++++++++++---------- tests/qapi-schema/args-member-case.err | 2 +- tests/qapi-schema/enum-member-case.err | 2 +- tests/qapi-schema/union-branch-case.err | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 85493efbac..e416cc5162 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -51,12 +51,13 @@ def check_name_upper(name, info, source): =20 =20 def check_name_lower(name, info, source, - permit_upper=3DFalse): + permit_upper=3DFalse, + permit_underscore=3DFalse): stem =3D check_name_str(name, info, source) - if not permit_upper and re.search(r'[A-Z]', stem): + if ((not permit_upper and re.search(r'[A-Z]', stem)) + or (not permit_underscore and '_' in stem)): raise QAPISemError( - info, "%s uses uppercase in name" % source) - # TODO reject '_' in stem + info, "name of %s must not use uppercase or '_'" % source) =20 =20 def check_name_camel(name, info, source): @@ -69,7 +70,8 @@ def check_defn_name_str(name, info, meta): if meta =3D=3D 'event': check_name_upper(name, info, meta) elif meta =3D=3D 'command': - check_name_lower(name, info, meta, permit_upper=3DTrue) + check_name_lower(name, info, meta, + permit_upper=3DTrue, permit_underscore=3DTrue) else: check_name_camel(name, info, meta) if name.endswith('Kind') or name.endswith('List'): @@ -188,7 +190,8 @@ def check_type(value, info, source, key_source =3D "%s member '%s'" % (source, key) if key.startswith('*'): key =3D key[1:] - check_name_lower(key, info, key_source, permit_upper) + check_name_lower(key, info, key_source, + permit_upper, permit_underscore=3DTrue) if c_name(key, False) =3D=3D 'u' or c_name(key, False).startswith(= 'has_'): raise QAPISemError(info, "%s uses reserved name" % key_source) check_keys(arg, info, key_source, ['type'], ['if', 'features']) @@ -210,7 +213,7 @@ def check_features(features, info): check_keys(f, info, source, ['name'], ['if']) check_name_is_str(f['name'], info, source) source =3D "%s '%s'" % (source, f['name']) - check_name_lower(f['name'], info, source) + check_name_lower(f['name'], info, source, permit_underscore=3DTrue) check_if(f, info, source) =20 =20 @@ -237,7 +240,8 @@ def check_enum(expr, info): # Enum members may start with a digit if member_name[0].isdigit(): member_name =3D 'd' + member_name # Hack: hide the digit - check_name_lower(member_name, info, source, permit_upper) + check_name_lower(member_name, info, source, + permit_upper, permit_underscore=3DTrue) check_if(member, info, source) =20 =20 @@ -267,7 +271,7 @@ def check_union(expr, info): for (key, value) in members.items(): source =3D "'data' member '%s'" % key if discriminator is None: - check_name_lower(key, info, source) + check_name_lower(key, info, source, permit_underscore=3DTrue) # else: name is in discriminator enum, which gets checked check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) @@ -281,7 +285,7 @@ def check_alternate(expr, info): raise QAPISemError(info, "'data' must not be empty") for (key, value) in members.items(): source =3D "'data' member '%s'" % key - check_name_lower(key, info, source) + check_name_lower(key, info, source, permit_underscore=3DTrue) check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) check_type(value['type'], info, source) diff --git a/tests/qapi-schema/args-member-case.err b/tests/qapi-schema/arg= s-member-case.err index 4f33dbbc38..25c3910a17 100644 --- a/tests/qapi-schema/args-member-case.err +++ b/tests/qapi-schema/args-member-case.err @@ -1,2 +1,2 @@ args-member-case.json: In command 'no-way-this-will-get-whitelisted': -args-member-case.json:2: 'data' member 'Arg' uses uppercase in name +args-member-case.json:2: name of 'data' member 'Arg' must not use uppercas= e or '_' diff --git a/tests/qapi-schema/enum-member-case.err b/tests/qapi-schema/enu= m-member-case.err index 8b3aefe37a..c813522c50 100644 --- a/tests/qapi-schema/enum-member-case.err +++ b/tests/qapi-schema/enum-member-case.err @@ -1,2 +1,2 @@ enum-member-case.json: In enum 'NoWayThisWillGetWhitelisted': -enum-member-case.json:4: 'data' member 'Value' uses uppercase in name +enum-member-case.json:4: name of 'data' member 'Value' must not use upperc= ase or '_' diff --git a/tests/qapi-schema/union-branch-case.err b/tests/qapi-schema/un= ion-branch-case.err index b1e9417303..d2d5cb8993 100644 --- a/tests/qapi-schema/union-branch-case.err +++ b/tests/qapi-schema/union-branch-case.err @@ -1,2 +1,2 @@ union-branch-case.json: In union 'Uni': -union-branch-case.json:2: 'data' member 'Branch' uses uppercase in name +union-branch-case.json:2: name of 'data' member 'Branch' must not use uppe= rcase or '_' --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537086; cv=none; d=zohomail.com; s=zohoarc; b=Cq6FZqLZRcsOgMuqySPze/DL+vJB7gRuZNpcs81pOedwAqqxVgJxk/+Z8vfuCfZCKlEbIw92UndCCnszLlZUxrIUqpLXYMbX7eL4LpRi6T1vHvpEcpZZvTH2sfOvBlsgsapHsnso4k7HlqyRADYJu12lAhLvQgjqQs4r/OMUg0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537086; 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=6BXnBBJ4U/HrdRlC7jdLhijQkWvFNBFYBTbYrhu/95g=; b=D+rrvItKVR1vD+vLFtDyy42Re8W/8C1Kz8eS96/iWZmFmYzpe4hqrvABNZJhdEtWPVnd9pkf/C1YRhvQQLB+5hXWVTg3epA6rFOfCrFTeKoBHA0cUmWtRuz834DDoZ8+caRFtbo3McLHnp/RrPLkVAae65sJhu1K7EN7WCzjSXY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161653708674272.51356324049073; Tue, 23 Mar 2021 15:04:46 -0700 (PDT) Received: from localhost ([::1]:40676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp8n-0002MP-9p for importer@patchew.org; Tue, 23 Mar 2021 18:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1V-00072n-Um for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1P-0002mX-19 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-540-5lQA-rYSPtS_LY-gU43ODQ-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6006AA0CA3; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30E42610A8; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E5E0111326AB; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=6BXnBBJ4U/HrdRlC7jdLhijQkWvFNBFYBTbYrhu/95g=; b=AZqarguA+j0UjTTjS2BvI/B2FVVEtekl3iokClusWmj+fZdek1Vy1D2eUP+WUQQ+0OLLHJ /G6PKXhIzeLg4A7cLssM/I/mEsvI8eou2gth0PBuJuJTaQg4LkkOAysywc2hSyTzFnqT83 tXdEMQmwmXpZYIFmy0i/qxoVBj9LU1M= X-MC-Unique: 5lQA-rYSPtS_LY-gU43ODQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 23/29] qapi: Enforce feature naming rules Date: Tue, 23 Mar 2021 22:56:52 +0100 Message-Id: <20210323215658.3840228-24-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Feature names should use '-', not '_'. Enforce this. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-24-armbru@redhat.com> Reviewed-by: Eric Blake --- scripts/qapi/expr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index e416cc5162..d778107c18 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -213,7 +213,7 @@ def check_features(features, info): check_keys(f, info, source, ['name'], ['if']) check_name_is_str(f['name'], info, source) source =3D "%s '%s'" % (source, f['name']) - check_name_lower(f['name'], info, source, permit_underscore=3DTrue) + check_name_lower(f['name'], info, source) check_if(f, info, source) =20 =20 --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537228; cv=none; d=zohomail.com; s=zohoarc; b=gGeuivkiJ7IpQ/f6kFTzOFj6wd6E9YF4r/GpL6HfrzxokKGbcEN4y5zcNhcBEKAk09/r1U3CfoLv/ewzs8i1xxsdpPHDyPOjfdO4QNeIBUQXzxrfwMoTEwBdSvAV6HvTwPRTnZMQS6nCx+lRSkn9vt/BYeUzObZRzadvRBrizLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537228; 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=ly9gUTmur/X47V/CvqLOO5YTsgWFsABTtSdJ2pNqSOo=; b=it49DohGKBdpnI6YeSryalcqXL6onfpcr/0DMFaXcvDr3SAD0ogfM1tAI1SBq8AXParBxuFL8lFLmh/caAGuiI9NrPEHBgQkifioEOhsfp3lsftLBOsDTXOzmhuZCgM3kTppgL2Rl47EoP8/14F39cwS/cdRKwxtaESB8bq9AWw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537228249732.4935973020085; Tue, 23 Mar 2021 15:07:08 -0700 (PDT) Received: from localhost ([::1]:48588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpB5-0006oz-3b for importer@patchew.org; Tue, 23 Mar 2021 18:07:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1a-0007A0-Mo for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30349) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0002mr-DE for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-tkjW0l6-NOOs_13U4RByTw-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF12B100747F; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 317F860CF1; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EF78B11326AC; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=ly9gUTmur/X47V/CvqLOO5YTsgWFsABTtSdJ2pNqSOo=; b=XzKv5Yudr6n6A35RZTTUJk67+jh0HL3+qKj4LnSeYB6AHD07C4YHG+GB6cAhEv1y+83A/3 KSt4K9Z2mb+yqPIHZePs/YY/gVWN+59dmsJmR35yY26WzLIUXFMHYUSB+uGqewJwrunld4 /QqP3B8zqFOjEjxiswKlR1+smH+vqoI= X-MC-Unique: tkjW0l6-NOOs_13U4RByTw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 24/29] qapi: Enforce command naming rules Date: Tue, 23 Mar 2021 22:56:53 +0100 Message-Id: <20210323215658.3840228-25-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Command names should be lower-case. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma command-name-exceptions. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-25-armbru@redhat.com> Reviewed-by: Eric Blake --- docs/devel/qapi-code-gen.txt | 8 ++++++-- qapi/pragma.json | 18 +++++++++++++++++ tests/unit/test-qmp-cmds.c | 10 +++++----- scripts/qapi/expr.py | 5 +++-- scripts/qapi/parser.py | 3 +++ scripts/qapi/source.py | 2 ++ tests/qapi-schema/qapi-schema-test.json | 21 +++++++++++--------- tests/qapi-schema/qapi-schema-test.out | 26 ++++++++++++------------- 8 files changed, 62 insertions(+), 31 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 23e9823019..10e9a0f829 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -149,6 +149,7 @@ prevent incomplete include files. Syntax: PRAGMA =3D { 'pragma': { '*doc-required': BOOL, + '*command-name-exceptions': [ STRING, ... ], '*command-returns-exceptions': [ STRING, ... ], '*member-name-exceptions': [ STRING, ... ] } } =20 @@ -160,6 +161,9 @@ pragma to different values in parts of the schema doesn= 't work. Pragma 'doc-required' takes a boolean value. If true, documentation is required. Default is false. =20 +Pragma 'command-name-exceptions' takes a list of commands whose names +may contain '_' instead of '-'. Default is none. + Pragma 'command-returns-exceptions' takes a list of commands that may violate the rules on permitted return types. Default is none. =20 @@ -756,8 +760,8 @@ Any name (command, event, type, member, or enum value) = beginning with "x-" is marked experimental, and may be withdrawn or changed incompatibly in a future release. =20 -Pragma 'member-name-exceptions' lets you violate the rules on use of -upper and lower case. Use for new code is strongly discouraged. +Pragmas 'command-name-exceptions' and 'member-name-exceptions' let you +violate naming rules. Use for new code is strongly discouraged. =20 =20 =3D=3D=3D Downstream extensions =3D=3D=3D diff --git a/qapi/pragma.json b/qapi/pragma.json index 4c47c802d1..339f067943 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -4,6 +4,24 @@ # add to them! { 'pragma': { # Commands allowed to return a non-dictionary: + 'command-name-exceptions': [ + 'add_client', + 'block_passwd', + 'block_resize', + 'block_set_io_throttle', + 'client_migrate_info', + 'device_add', + 'device_del', + 'expire_password', + 'migrate_cancel', + 'netdev_add', + 'netdev_del', + 'qmp_capabilities', + 'set_link', + 'set_password', + 'system_powerdown', + 'system_reset', + 'system_wakeup' ], 'command-returns-exceptions': [ 'human-monitor-command', 'qom-get', diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 99973dde7c..1b0b7d99df 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -13,7 +13,7 @@ =20 static QmpCommandList qmp_commands; =20 -UserDefThree *qmp_TestCmdReturnDefThree(Error **errp) +UserDefThree *qmp_test_cmd_return_def_three(Error **errp) { return NULL; } @@ -199,7 +199,7 @@ static void test_dispatch_cmd(void) =20 ret =3D qobject_to(QDict, do_qmp_dispatch(false, - "{ 'execute': 'user_def_cmd' }")); + "{ 'execute': 'user-def-cmd' }")); assert(ret && qdict_size(ret) =3D=3D 0); qobject_unref(ret); } @@ -220,11 +220,11 @@ static void test_dispatch_cmd_failure(void) { /* missing arguments */ do_qmp_dispatch_error(false, ERROR_CLASS_GENERIC_ERROR, - "{ 'execute': 'user_def_cmd2' }"); + "{ 'execute': 'user-def-cmd2' }"); =20 /* extra arguments */ do_qmp_dispatch_error(false, ERROR_CLASS_GENERIC_ERROR, - "{ 'execute': 'user_def_cmd'," + "{ 'execute': 'user-def-cmd'," " 'arguments': { 'a': 66 } }"); } =20 @@ -248,7 +248,7 @@ static void test_dispatch_cmd_io(void) int64_t val; =20 ret =3D qobject_to(QDict, do_qmp_dispatch(false, - "{ 'execute': 'user_def_cmd2', 'arguments': {" + "{ 'execute': 'user-def-cmd2', 'arguments': {" " 'ud1a': { 'integer': 42, 'string': 'hello' }," " 'ud1b': { 'integer': 422, 'string': 'hello2' } } }")); =20 diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index d778107c18..9193e68763 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -70,8 +70,9 @@ def check_defn_name_str(name, info, meta): if meta =3D=3D 'event': check_name_upper(name, info, meta) elif meta =3D=3D 'command': - check_name_lower(name, info, meta, - permit_upper=3DTrue, permit_underscore=3DTrue) + check_name_lower( + name, info, meta, + permit_underscore=3Dname in info.pragma.command_name_exception= s) else: check_name_camel(name, info, meta) if name.endswith('Kind') or name.endswith('List'): diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index c16b8b6995..58267c3db9 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -132,6 +132,9 @@ def _pragma(self, name, value, info): raise QAPISemError(info, "pragma 'doc-required' must be boolean") info.pragma.doc_required =3D value + elif name =3D=3D 'command-name-exceptions': + self._check_pragma_list_of_str(name, value, info) + info.pragma.command_name_exceptions =3D value elif name =3D=3D 'command-returns-exceptions': self._check_pragma_list_of_str(name, value, info) info.pragma.command_returns_exceptions =3D value diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py index d8f9ec377f..03b6ede082 100644 --- a/scripts/qapi/source.py +++ b/scripts/qapi/source.py @@ -21,6 +21,8 @@ class QAPISchemaPragma: def __init__(self) -> None: # Are documentation comments required? self.doc_required =3D False + # Commands whose names may use '_' + self.command_name_exceptions: List[str] =3D [] # Commands allowed to return a non-dictionary self.command_returns_exceptions: List[str] =3D [] # Types whose member names may violate case conventions diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 16b03bf308..e635db4a35 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -31,7 +31,7 @@ 'base': { 'type': 'EnumOne' }, 'discriminator': 'type', 'data': { } } =20 -{ 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' } +{ 'command': 'user-def-cmd0', 'data': 'Empty2', 'returns': 'Empty2' } =20 # for testing override of default naming heuristic { 'enum': 'QEnumTwo', @@ -141,9 +141,9 @@ { 'include': 'include/sub-module.json' } =20 # testing commands -{ 'command': 'user_def_cmd', 'data': {} } -{ 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} } -{ 'command': 'user_def_cmd2', +{ 'command': 'user-def-cmd', 'data': {} } +{ 'command': 'user-def-cmd1', 'data': {'ud1a': 'UserDefOne'} } +{ 'command': 'user-def-cmd2', 'data': {'ud1a': {'type': 'UserDefOne'}, '*ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } =20 @@ -230,7 +230,8 @@ 'union_bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} }, 'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' } =20 -{ 'command': 'TestIfUnionCmd', 'data': { 'union_cmd_arg': 'TestIfUnion' }, +{ 'command': 'test-if-union-cmd', + 'data': { 'union_cmd_arg': 'TestIfUnion' }, 'if': 'defined(TEST_IF_UNION)' } =20 { 'alternate': 'TestIfAlternate', 'data': @@ -238,16 +239,18 @@ 'bar': { 'type': 'TestStruct', 'if': 'defined(TEST_IF_ALT_BAR)'} }, 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } =20 -{ 'command': 'TestIfAlternateCmd', 'data': { 'alt_cmd_arg': 'TestIfAlterna= te' }, +{ 'command': 'test-if-alternate-cmd', + 'data': { 'alt_cmd_arg': 'TestIfAlternate' }, 'if': 'defined(TEST_IF_ALT)' } =20 -{ 'command': 'TestIfCmd', 'data': - { 'foo': 'TestIfStruct', +{ 'command': 'test-if-cmd', + 'data': { + 'foo': 'TestIfStruct', 'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_CMD_BAR)' } }, 'returns': 'UserDefThree', 'if': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] } =20 -{ 'command': 'TestCmdReturnDefThree', 'returns': 'UserDefThree' } +{ 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' } =20 { 'event': 'TEST_IF_EVENT', 'data': { 'foo': 'TestIfStruct', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 882d0e7c56..3f1ea345fd 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -32,7 +32,7 @@ object Union case value2: q_empty case value3: q_empty case value4: q_empty -command user_def_cmd0 Empty2 -> Empty2 +command user-def-cmd0 Empty2 -> Empty2 gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse enum QEnumTwo prefix QENUM_TWO @@ -190,16 +190,16 @@ object UserDefListUnion case any: q_obj_anyList-wrapper case user: q_obj_StatusList-wrapper include include/sub-module.json -command user_def_cmd None -> None +command user-def-cmd None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse -object q_obj_user_def_cmd1-arg +object q_obj_user-def-cmd1-arg member ud1a: UserDefOne optional=3DFalse -command user_def_cmd1 q_obj_user_def_cmd1-arg -> None +command user-def-cmd1 q_obj_user-def-cmd1-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse -object q_obj_user_def_cmd2-arg +object q_obj_user-def-cmd2-arg member ud1a: UserDefOne optional=3DFalse member ud1b: UserDefOne optional=3DTrue -command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo +command user-def-cmd2 q_obj_user-def-cmd2-arg -> UserDefTwo gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command cmd-success-response None -> None gen=3DTrue success_response=3DFalse boxed=3DFalse oob=3DFalse preconfi= g=3DFalse @@ -319,10 +319,10 @@ object TestIfUnion case union_bar: q_obj_str-wrapper if ['defined(TEST_IF_UNION_BAR)'] if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)'] -object q_obj_TestIfUnionCmd-arg +object q_obj_test-if-union-cmd-arg member union_cmd_arg: TestIfUnion optional=3DFalse if ['defined(TEST_IF_UNION)'] -command TestIfUnionCmd q_obj_TestIfUnionCmd-arg -> None +command test-if-union-cmd q_obj_test-if-union-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse if ['defined(TEST_IF_UNION)'] alternate TestIfAlternate @@ -331,21 +331,21 @@ alternate TestIfAlternate case bar: TestStruct if ['defined(TEST_IF_ALT_BAR)'] if ['defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)'] -object q_obj_TestIfAlternateCmd-arg +object q_obj_test-if-alternate-cmd-arg member alt_cmd_arg: TestIfAlternate optional=3DFalse if ['defined(TEST_IF_ALT)'] -command TestIfAlternateCmd q_obj_TestIfAlternateCmd-arg -> None +command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse if ['defined(TEST_IF_ALT)'] -object q_obj_TestIfCmd-arg +object q_obj_test-if-cmd-arg member foo: TestIfStruct optional=3DFalse member bar: TestIfEnum optional=3DFalse if ['defined(TEST_IF_CMD_BAR)'] if ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] -command TestIfCmd q_obj_TestIfCmd-arg -> UserDefThree +command test-if-cmd q_obj_test-if-cmd-arg -> UserDefThree gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse if ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] -command TestCmdReturnDefThree None -> UserDefThree +command test-cmd-return-def-three None -> UserDefThree gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse array TestIfEnumList TestIfEnum if ['defined(TEST_IF_ENUM)'] --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537086; cv=none; d=zohomail.com; s=zohoarc; b=Wu5mA8kA2eG9DJDQfo1cPDCPQ+ND4YjTmvPd346bZkAcj5lw6hTKQkLMH/y93Vjiqgn3ajqRB4iga37Xj99GnJy/10LCajfT5acGcdhwa5RHlzqiFryP5Yjjp2CZO4piSg7j0JcQGhHmuYDk+vM1k08PKQ79C8mhH/GCbt7dYUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537086; 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=FDkTYCJdC43syxVh5ZucpwQxwJJ79gWMa1BtOaScK04=; b=dcYLlRyo5eriIPaVUfAmp6dDXLxe2SsyQMYXlcYbw/yYLpJN4Rln6dTkpLH72GGNdI0QSE0ZFYjpsuTJ25W0t2zMKtmdbYlnhZdeJPhbC3OT96o+jmwT41X3D52KpWLsPjSVXlxV07fq8zPwisjCTnGiuTEviy1JJ+2GeiBDmEE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537086630405.810340451642; Tue, 23 Mar 2021 15:04:46 -0700 (PDT) Received: from localhost ([::1]:40632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOp8n-0002L9-8z for importer@patchew.org; Tue, 23 Mar 2021 18:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Z-00077H-QF for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0002mw-EU for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-oAV3CrhnMMS_n30HVv8t-g-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6846B1B2C985; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 316F01F411; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F2B1211326AD; Tue, 23 Mar 2021 22:56:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=FDkTYCJdC43syxVh5ZucpwQxwJJ79gWMa1BtOaScK04=; b=AP3ssh3RKro2R4NfxTAI3PoJtvpDUl0CusciA+CKIh6u55EDjdJnsF8GheXUb+hnIMkXcT tPQ7VcIWW8far596NIenvPEgaA51SfDlqS4dO/c0BRKNeaQWCBpfTUlL5MJ0dDJOL1v5LZ IF6NEHH+2sb4ROloD8HJZNumUidiYFA= X-MC-Unique: oAV3CrhnMMS_n30HVv8t-g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 25/29] tests/qapi-schema: Switch member name clash test to struct Date: Tue, 23 Mar 2021 22:56:54 +0100 Message-Id: <20210323215658.3840228-26-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Test args-name-clash covers command parameter name clash. This effectively covers struct member name clash as well. The next commit will make parameter name clash impossible. Convert args-name-clash from testing command to testing a struct, and rename it to struct-member-name-clash. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-26-armbru@redhat.com> Reviewed-by: Eric Blake [Commit message typo fixed] --- tests/qapi-schema/args-name-clash.err | 2 -- tests/qapi-schema/meson.build | 2 +- tests/qapi-schema/struct-member-name-clash.err | 2 ++ .../{args-name-clash.json =3D> struct-member-name-clash.json} | 2 +- .../{args-name-clash.out =3D> struct-member-name-clash.out} | 0 5 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 tests/qapi-schema/args-name-clash.err create mode 100644 tests/qapi-schema/struct-member-name-clash.err rename tests/qapi-schema/{args-name-clash.json =3D> struct-member-name-cla= sh.json} (64%) rename tests/qapi-schema/{args-name-clash.out =3D> struct-member-name-clas= h.out} (100%) diff --git a/tests/qapi-schema/args-name-clash.err b/tests/qapi-schema/args= -name-clash.err deleted file mode 100644 index 3e04817bc0..0000000000 --- a/tests/qapi-schema/args-name-clash.err +++ /dev/null @@ -1,2 +0,0 @@ -args-name-clash.json: In command 'oops': -args-name-clash.json:4: parameter 'a_b' collides with parameter 'a-b' diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 4e7635f0a8..8ba6917132 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -30,7 +30,6 @@ schemas =3D [ 'args-member-array-bad.json', 'args-member-case.json', 'args-member-unknown.json', - 'args-name-clash.json', 'args-union.json', 'args-unknown.json', 'bad-base.json', @@ -177,6 +176,7 @@ schemas =3D [ 'struct-member-if-invalid.json', 'struct-member-invalid-dict.json', 'struct-member-invalid.json', + 'struct-member-name-clash.json', 'trailing-comma-list.json', 'trailing-comma-object.json', 'type-bypass-bad-gen.json', diff --git a/tests/qapi-schema/struct-member-name-clash.err b/tests/qapi-sc= hema/struct-member-name-clash.err new file mode 100644 index 0000000000..6ac042d59d --- /dev/null +++ b/tests/qapi-schema/struct-member-name-clash.err @@ -0,0 +1,2 @@ +struct-member-name-clash.json: In struct 'Oops': +struct-member-name-clash.json:4: member 'a_b' collides with member 'a-b' diff --git a/tests/qapi-schema/args-name-clash.json b/tests/qapi-schema/str= uct-member-name-clash.json similarity index 64% rename from tests/qapi-schema/args-name-clash.json rename to tests/qapi-schema/struct-member-name-clash.json index 61423cb893..3fb69cc2ce 100644 --- a/tests/qapi-schema/args-name-clash.json +++ b/tests/qapi-schema/struct-member-name-clash.json @@ -1,4 +1,4 @@ # C member name collision # Reject members that clash when mapped to C names (we would have two 'a_b' # members). -{ 'command': 'oops', 'data': { 'a-b': 'str', 'a_b': 'str' } } +{ 'struct': 'Oops', 'data': { 'a-b': 'str', 'a_b': 'str' } } diff --git a/tests/qapi-schema/args-name-clash.out b/tests/qapi-schema/stru= ct-member-name-clash.out similarity index 100% rename from tests/qapi-schema/args-name-clash.out rename to tests/qapi-schema/struct-member-name-clash.out --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616538048; cv=none; d=zohomail.com; s=zohoarc; b=YxUl3IE+IqhVb9aCOXqYkaDqbTGEhAOudqZz7yME/Nt+jh3T8NsSAuoXvZPXL0mH4JTOErAnGz75VEeBCpbN0JgYia9GId85DeZf3jWTuTpE2GrTmOo8+nMvlimaR+Ric2O1JtAgTpBc1qV7mniY21z+LZv/M03ygcWBMVYCnVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616538048; 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=hmpR7JQINpqwOvi0xnhoJLWAROu61vSxuMW8ntIZv+U=; b=XyPfWH94GPNMI97rOddIG99iVdwh4NTcsJX9w014Hpeo8YumQuPFs69U/MwDpmwPhR524fPRJa+GDsqXddzmnGnj6OcwnLX1Ffp9tUuOBU3xBku6BTMtLWyaQbbWoPAgJPCGXEnzIqOHfPSxmssV6QHMBfeC/1MX4rICsq4NJdg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616538048960685.0253484810163; Tue, 23 Mar 2021 15:20:48 -0700 (PDT) Received: from localhost ([::1]:33054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpOJ-00043e-PG for importer@patchew.org; Tue, 23 Mar 2021 18:20:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1u-0007YR-P7 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1T-0002p5-Jj for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-mEX_mV4BOdC7pyTHtfvdjg-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85B7580364C; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30EE063BA7; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0487011326AF; Tue, 23 Mar 2021 22:56:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536630; 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=hmpR7JQINpqwOvi0xnhoJLWAROu61vSxuMW8ntIZv+U=; b=M2t5+CSAR0G40G+6RS1EnnCTIX4TfG0YaDMfhj919GtCaPs/bOa5Lt6Aq1zlFoIY//G47o 44/7sG77FnkkGMuYr7CDmRVzjszjmjEFT5w8mTioDjfpHxc6nJmUkdQA1QA961wRa7tt1J /4N/oxz89KVtXeQUNiJLrIKmroqUAfE= X-MC-Unique: mEX_mV4BOdC7pyTHtfvdjg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 26/29] qapi: Enforce struct member naming rules Date: Tue, 23 Mar 2021 22:56:55 +0100 Message-Id: <20210323215658.3840228-27-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Struct members, including command arguments, event data, and union inline base members, should use '-', not '_'. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma member-name-exceptions. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-27-armbru@redhat.com> Reviewed-by: Eric Blake --- docs/devel/qapi-code-gen.txt | 3 ++- qapi/pragma.json | 17 +++++++++++++++++ qga/qapi-schema.json | 4 ++++ scripts/qapi/expr.py | 5 +++-- tests/qapi-schema/qapi-schema-test.json | 8 ++++++-- tests/qapi-schema/qapi-schema-test.out | 4 ++-- tests/qapi-schema/struct-member-name-clash.err | 2 +- tests/qapi-schema/struct-member-name-clash.json | 1 + 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 10e9a0f829..c1cb6f987d 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -168,7 +168,8 @@ Pragma 'command-returns-exceptions' takes a list of com= mands that may violate the rules on permitted return types. Default is none. =20 Pragma 'member-name-exceptions' takes a list of types whose member -names may contain uppercase letters. Default is none. +names may contain uppercase letters, and '_' instead of '-'. Default +is none. =20 =20 =3D=3D=3D Enumeration types =3D=3D=3D diff --git a/qapi/pragma.json b/qapi/pragma.json index 339f067943..f422a1a2ac 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -31,10 +31,27 @@ # Externally visible types whose member names may use uppercase 'member-name-exceptions': [ # visible in: 'ACPISlotType', # query-acpi-ospm-status + 'AcpiTableOptions', # -acpitable + 'BlkdebugSetStateOptions', # blockdev-add, -blockdev + 'BlockDeviceInfo', # query-block + 'BlockDeviceStats', # query-blockstats + 'BlockDeviceTimedStats', # query-blockstats + 'BlockIOThrottle', # block_set_io_throttle + 'BlockInfo', # query-block 'BlockdevVmdkAdapterType', # blockdev-create (to match VMDK spec) 'BlockdevVmdkSubformat', # blockdev-create (to match VMDK spec) + 'ColoCompareProperties', # object_add, -object + 'FilterMirrorProperties', # object_add, -object + 'FilterRedirectorProperties', # object_add, -object + 'FilterRewriterProperties', # object_add, -object + 'InputLinuxProperties', # object_add, -object + 'NetdevTapOptions', # netdev_add, query-netdev, -netdev + 'PciBusInfo', # query-pci + 'PciDeviceInfo', # query-pci + 'PciMemoryRegion', # query-pci 'QapiErrorClass', # QMP error replies 'UuidInfo', # query-uuid + 'VncClientInfo', # query-vnc, query-vnc-servers, ... 'X86CPURegister32' # qom-get of x86 CPU properties # feature-words, filtered-features ] } } diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 2b08b761c2..fb17eebde3 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -19,6 +19,10 @@ # Whitelists to permit QAPI rule violations; think twice before you # add to them! { 'pragma': { + # Types whose member names may use '_' + 'member-name-exceptions': [ + 'GuestAgentInfo' + ], # Commands allowed to return a non-dictionary: 'command-returns-exceptions': [ 'guest-file-open', diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 9193e68763..ba9f7ad350 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -184,7 +184,7 @@ def check_type(value, info, source, raise QAPISemError(info, "%s should be an object or type name" % source) =20 - permit_upper =3D allow_dict in info.pragma.member_name_exceptions + permissive =3D allow_dict in info.pragma.member_name_exceptions =20 # value is a dictionary, check that each member is okay for (key, arg) in value.items(): @@ -192,7 +192,8 @@ def check_type(value, info, source, if key.startswith('*'): key =3D key[1:] check_name_lower(key, info, key_source, - permit_upper, permit_underscore=3DTrue) + permit_upper=3Dpermissive, + permit_underscore=3Dpermissive) if c_name(key, False) =3D=3D 'u' or c_name(key, False).startswith(= 'has_'): raise QAPISemError(info, "%s uses reserved name" % key_source) check_keys(arg, info, key_source, ['type'], ['if', 'features']) diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index e635db4a35..387678acbb 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -6,6 +6,10 @@ =20 # Whitelists to permit QAPI rule violations { 'pragma': { + # Types whose member names may use '_' + 'member-name-exceptions': [ + 'UserDefA' + ], # Commands allowed to return a non-dictionary: 'command-returns-exceptions': [ 'guest-get-time', @@ -231,7 +235,7 @@ 'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' } =20 { 'command': 'test-if-union-cmd', - 'data': { 'union_cmd_arg': 'TestIfUnion' }, + 'data': { 'union-cmd-arg': 'TestIfUnion' }, 'if': 'defined(TEST_IF_UNION)' } =20 { 'alternate': 'TestIfAlternate', 'data': @@ -240,7 +244,7 @@ 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' } =20 { 'command': 'test-if-alternate-cmd', - 'data': { 'alt_cmd_arg': 'TestIfAlternate' }, + 'data': { 'alt-cmd-arg': 'TestIfAlternate' }, 'if': 'defined(TEST_IF_ALT)' } =20 { 'command': 'test-if-cmd', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 3f1ea345fd..51efe5d7cd 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -320,7 +320,7 @@ object TestIfUnion if ['defined(TEST_IF_UNION_BAR)'] if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)'] object q_obj_test-if-union-cmd-arg - member union_cmd_arg: TestIfUnion optional=3DFalse + member union-cmd-arg: TestIfUnion optional=3DFalse if ['defined(TEST_IF_UNION)'] command test-if-union-cmd q_obj_test-if-union-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse @@ -332,7 +332,7 @@ alternate TestIfAlternate if ['defined(TEST_IF_ALT_BAR)'] if ['defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)'] object q_obj_test-if-alternate-cmd-arg - member alt_cmd_arg: TestIfAlternate optional=3DFalse + member alt-cmd-arg: TestIfAlternate optional=3DFalse if ['defined(TEST_IF_ALT)'] command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse diff --git a/tests/qapi-schema/struct-member-name-clash.err b/tests/qapi-sc= hema/struct-member-name-clash.err index 6ac042d59d..7e53a605d2 100644 --- a/tests/qapi-schema/struct-member-name-clash.err +++ b/tests/qapi-schema/struct-member-name-clash.err @@ -1,2 +1,2 @@ struct-member-name-clash.json: In struct 'Oops': -struct-member-name-clash.json:4: member 'a_b' collides with member 'a-b' +struct-member-name-clash.json:5: member 'a_b' collides with member 'a-b' diff --git a/tests/qapi-schema/struct-member-name-clash.json b/tests/qapi-s= chema/struct-member-name-clash.json index 3fb69cc2ce..571acf05ce 100644 --- a/tests/qapi-schema/struct-member-name-clash.json +++ b/tests/qapi-schema/struct-member-name-clash.json @@ -1,4 +1,5 @@ # C member name collision # Reject members that clash when mapped to C names (we would have two 'a_b' # members). +{ 'pragma': { 'member-name-exceptions': [ 'Oops' ] } } { 'struct': 'Oops', 'data': { 'a-b': 'str', 'a_b': 'str' } } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537478; cv=none; d=zohomail.com; s=zohoarc; b=Wm9W2g6RbAOb+1A82Cus2nDnDfsa10zLzdCP9h4AnKII7bbPjT3+BvLh0XY6jiijJcDdI6xeVTUOWSW/q4nF4Dap0z1gWdm0EUvmtOYJd1u5msibGsAeKBOFUrV5SFT1hR8dbH77TWFXIZDVNbfkpIiUIFbCqRSK3sj/t2czVIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537478; 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=cy5Mfs0692+JnHAjtZDILDF7mAh2stZSel3gqrE5Jhc=; b=OGqteUPMUkYSSZF/TmKvgdldS9oTs9Td8CXCwNHHatKTAovwG9yN2YeWNpb4VWOVcoTprX85jYbMYsNOzJDgAQiJK7DoLTsKmTFPNvakmFAJ1CuuZkpM0c1HK3OB7A9ZLrmycsa0z4//cmiUbGgPWaxWaBH9VCdBB+2XSXFXWwo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537478158861.6147155213723; Tue, 23 Mar 2021 15:11:18 -0700 (PDT) Received: from localhost ([::1]:36288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpF7-0007OC-4i for importer@patchew.org; Tue, 23 Mar 2021 18:11:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1k-0007Lo-Lm for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1R-0002nN-3j for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-523-a7i3WGAtPy-htLwHBGn3hw-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 867C8108BD0A; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 311E56087C; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0A6C311326B2; Tue, 23 Mar 2021 22:56:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536627; 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=cy5Mfs0692+JnHAjtZDILDF7mAh2stZSel3gqrE5Jhc=; b=hYCvvYrDo6A7Aj2WkhhAJvpC47Vxn74D2mkiiVpBf9KNrCS5TWXSqvlRB/bunz1ekiHb2D VUmmxbH2eSsT8yCHmTnweMhajk20t5uPSTmhPSjsTWb9Zt3Q2k+Tzx1qlPEktvq2IHGeow Qzg9LM1CH+rnb3TlN8GrFTY1YS29v0g= X-MC-Unique: a7i3WGAtPy-htLwHBGn3hw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 27/29] qapi: Enforce enum member naming rules Date: Tue, 23 Mar 2021 22:56:56 +0100 Message-Id: <20210323215658.3840228-28-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Enum members should use '-', not '_'. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma member-name-exceptions. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-28-armbru@redhat.com> Reviewed-by: Eric Blake --- qapi/pragma.json | 8 ++++++++ scripts/qapi/expr.py | 5 +++-- tests/qapi-schema/enum-clash-member.err | 2 +- tests/qapi-schema/enum-clash-member.json | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qapi/pragma.json b/qapi/pragma.json index f422a1a2ac..b4e17167e1 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -32,12 +32,15 @@ 'member-name-exceptions': [ # visible in: 'ACPISlotType', # query-acpi-ospm-status 'AcpiTableOptions', # -acpitable + 'BlkdebugEvent', # blockdev-add, -blockdev 'BlkdebugSetStateOptions', # blockdev-add, -blockdev 'BlockDeviceInfo', # query-block 'BlockDeviceStats', # query-blockstats 'BlockDeviceTimedStats', # query-blockstats 'BlockIOThrottle', # block_set_io_throttle 'BlockInfo', # query-block + 'BlockdevAioOptions', # blockdev-add, -blockdev + 'BlockdevDriver', # blockdev-add, query-blockstats, ... 'BlockdevVmdkAdapterType', # blockdev-create (to match VMDK spec) 'BlockdevVmdkSubformat', # blockdev-create (to match VMDK spec) 'ColoCompareProperties', # object_add, -object @@ -46,10 +49,15 @@ 'FilterRewriterProperties', # object_add, -object 'InputLinuxProperties', # object_add, -object 'NetdevTapOptions', # netdev_add, query-netdev, -netdev + 'ObjectType', # object-add, -object + 'PCIELinkSpeed', # internal only 'PciBusInfo', # query-pci 'PciDeviceInfo', # query-pci 'PciMemoryRegion', # query-pci + 'QKeyCode', # send-key, input-sent-event 'QapiErrorClass', # QMP error replies + 'SshHostKeyCheckMode', # blockdev-add, -blockdev + 'SysEmuTarget', # query-cpu-fast, query-target 'UuidInfo', # query-uuid 'VncClientInfo', # query-vnc, query-vnc-servers, ... 'X86CPURegister32' # qom-get of x86 CPU properties diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index ba9f7ad350..d968609c48 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -229,7 +229,7 @@ def check_enum(expr, info): if prefix is not None and not isinstance(prefix, str): raise QAPISemError(info, "'prefix' must be a string") =20 - permit_upper =3D name in info.pragma.member_name_exceptions + permissive =3D name in info.pragma.member_name_exceptions =20 members[:] =3D [m if isinstance(m, dict) else {'name': m} for m in members] @@ -243,7 +243,8 @@ def check_enum(expr, info): if member_name[0].isdigit(): member_name =3D 'd' + member_name # Hack: hide the digit check_name_lower(member_name, info, source, - permit_upper, permit_underscore=3DTrue) + permit_upper=3Dpermissive, + permit_underscore=3Dpermissive) check_if(member, info, source) =20 =20 diff --git a/tests/qapi-schema/enum-clash-member.err b/tests/qapi-schema/en= um-clash-member.err index 5986571427..e4eb102ae2 100644 --- a/tests/qapi-schema/enum-clash-member.err +++ b/tests/qapi-schema/enum-clash-member.err @@ -1,2 +1,2 @@ enum-clash-member.json: In enum 'MyEnum': -enum-clash-member.json:2: value 'one_two' collides with value 'one-two' +enum-clash-member.json:3: value 'one_two' collides with value 'one-two' diff --git a/tests/qapi-schema/enum-clash-member.json b/tests/qapi-schema/e= num-clash-member.json index b6928b8bfd..82bcbf724b 100644 --- a/tests/qapi-schema/enum-clash-member.json +++ b/tests/qapi-schema/enum-clash-member.json @@ -1,2 +1,3 @@ # we reject enums where members will clash when mapped to C enum +{ 'pragma': { 'member-name-exceptions': [ 'MyEnum' ] } } { 'enum': 'MyEnum', 'data': [ 'one-two', 'one_two' ] } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616537663; cv=none; d=zohomail.com; s=zohoarc; b=kZVyuk6PYWtZzhMvZu1Bwc6Ge3d4Dr12ytn0g+ORrWxQJCH1c4aIsldWr+cPQiGocLO43eX3eq5B5DZPJnrrKhfjL5Nsut9gC5DSDrRSX8gWD4RGWiug+f3T3IykdTpJGRsGYhmVsSaR9bL5xQ4Ax+tLMv5lJTUhIaDBNIvucOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537663; 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=w8YGyunyvnoJEoToPAnSB/V3t0T1i2WWd0YF7I11ZEs=; b=fsPFZPvHpcC8MtBrKLnJhSlecs/JkV+qsWd2U3tNUzgThp9s/65Xoo4+CaWm5VAwL2Cqr4UfuIm3HLk88fPLjz5oUsT/Ho0YJqPPbtwT8KBrSSCEcbmPkIHJoOUUBAMEevc1ZCUtweKMNinQUPvX5NJ0+qMk+DwzKAjoqej35cU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161653766365780.3116442795615; Tue, 23 Mar 2021 15:14:23 -0700 (PDT) Received: from localhost ([::1]:43982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpI6-0003VQ-Ie for importer@patchew.org; Tue, 23 Mar 2021 18:14:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1m-0007NW-Vc for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Q-0002mq-Nv for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-F9mQUNo7Na2CKKAltH7V_w-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2BF181425A; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F7CA610A8; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1038B11326B3; Tue, 23 Mar 2021 22:56:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=w8YGyunyvnoJEoToPAnSB/V3t0T1i2WWd0YF7I11ZEs=; b=GrPgyp/M0lBMHDvWLvXHNEeS3h3BbSxEmLX04tITeE+Nk/ueYqCVp6UPXRlem9nshs50sV AiUNDCTWtnllvdcYXaBz9OAoCIH8sndJZbUntjn8tS1Wyg32hETWFupieWkriyHzpsYR8G bIqIgETwAqfZfolD0DHppoSfkII1zV4= X-MC-Unique: F9mQUNo7Na2CKKAltH7V_w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 28/29] qapi: Enforce union and alternate branch naming rules Date: Tue, 23 Mar 2021 22:56:57 +0100 Message-Id: <20210323215658.3840228-29-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Union branch names should use '-', not '_'. Enforce this. The only offenders are in tests/. Fix them. Signed-off-by: Markus Armbruster Message-Id: <20210323094025.3569441-29-armbru@redhat.com> Reviewed-by: Eric Blake [Commit message typo fixed] --- scripts/qapi/expr.py | 4 ++-- tests/qapi-schema/alternate-clash.err | 2 +- tests/qapi-schema/alternate-clash.json | 6 ++++-- tests/qapi-schema/qapi-schema-test.json | 2 +- tests/qapi-schema/qapi-schema-test.out | 4 ++-- tests/qapi-schema/union-clash-branches.err | 2 +- tests/qapi-schema/union-clash-branches.json | 6 ++++-- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index d968609c48..540b3982b1 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -274,7 +274,7 @@ def check_union(expr, info): for (key, value) in members.items(): source =3D "'data' member '%s'" % key if discriminator is None: - check_name_lower(key, info, source, permit_underscore=3DTrue) + check_name_lower(key, info, source) # else: name is in discriminator enum, which gets checked check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) @@ -288,7 +288,7 @@ def check_alternate(expr, info): raise QAPISemError(info, "'data' must not be empty") for (key, value) in members.items(): source =3D "'data' member '%s'" % key - check_name_lower(key, info, source, permit_underscore=3DTrue) + check_name_lower(key, info, source) check_keys(value, info, source, ['type'], ['if']) check_if(value, info, source) check_type(value['type'], info, source) diff --git a/tests/qapi-schema/alternate-clash.err b/tests/qapi-schema/alte= rnate-clash.err index 0fe02f2c99..caa2d42e3f 100644 --- a/tests/qapi-schema/alternate-clash.err +++ b/tests/qapi-schema/alternate-clash.err @@ -1,2 +1,2 @@ alternate-clash.json: In alternate 'Alt1': -alternate-clash.json:4: branch 'a_b' collides with branch 'a-b' +alternate-clash.json:6: name of 'data' member 'a_b' must not use uppercase= or '_' diff --git a/tests/qapi-schema/alternate-clash.json b/tests/qapi-schema/alt= ernate-clash.json index 039c4be658..87f061a74a 100644 --- a/tests/qapi-schema/alternate-clash.json +++ b/tests/qapi-schema/alternate-clash.json @@ -1,5 +1,7 @@ # Alternate branch name collision -# Reject an alternate that would result in a collision in generated C -# names (this would try to generate two union members named 'a_b'). +# Naming rules make collision impossible (even with the pragma). If +# that wasn't the case, then we'd get a collision in generated C: two +# union members a_b. +{ 'pragma': { 'member-name-exceptions': [ 'Alt1' ] } } { 'alternate': 'Alt1', 'data': { 'a-b': 'bool', 'a_b': 'int' } } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 387678acbb..84b9d41f15 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -231,7 +231,7 @@ =20 { 'union': 'TestIfUnion', 'data': { 'foo': 'TestStruct', - 'union_bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} }, + 'bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} }, 'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' } =20 { 'command': 'test-if-union-cmd', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 51efe5d7cd..e0b8a5f0b6 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -309,14 +309,14 @@ object q_obj_TestStruct-wrapper member data: TestStruct optional=3DFalse enum TestIfUnionKind member foo - member union_bar + member bar if ['defined(TEST_IF_UNION_BAR)'] if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)'] object TestIfUnion member type: TestIfUnionKind optional=3DFalse tag type case foo: q_obj_TestStruct-wrapper - case union_bar: q_obj_str-wrapper + case bar: q_obj_str-wrapper if ['defined(TEST_IF_UNION_BAR)'] if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)'] object q_obj_test-if-union-cmd-arg diff --git a/tests/qapi-schema/union-clash-branches.err b/tests/qapi-schema= /union-clash-branches.err index 73bbc2cabd..ef53645728 100644 --- a/tests/qapi-schema/union-clash-branches.err +++ b/tests/qapi-schema/union-clash-branches.err @@ -1,2 +1,2 @@ union-clash-branches.json: In union 'TestUnion': -union-clash-branches.json:4: branch 'a_b' collides with branch 'a-b' +union-clash-branches.json:6: name of 'data' member 'a_b' must not use uppe= rcase or '_' diff --git a/tests/qapi-schema/union-clash-branches.json b/tests/qapi-schem= a/union-clash-branches.json index 3bece8c948..7bdda0b0da 100644 --- a/tests/qapi-schema/union-clash-branches.json +++ b/tests/qapi-schema/union-clash-branches.json @@ -1,5 +1,7 @@ # Union branch name collision -# Reject a union that would result in a collision in generated C names (th= is -# would try to generate two members 'a_b'). +# Naming rules make collision impossible (even with the pragma). If +# that wasn't the case, then we'd get collisions in generated C: two +# union members a_b, and two enum members TEST_UNION_A_B. +{ 'pragma': { 'member-name-exceptions': [ 'TestUnion' ] } } { 'union': 'TestUnion', 'data': { 'a-b': 'int', 'a_b': 'str' } } --=20 2.26.3 From nobody Sun Apr 28 22:18:06 2024 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=1616537374; cv=none; d=zohomail.com; s=zohoarc; b=Pv9oR10e47mWCLZLIc0VBOO7V+tNqkdOW4PkVb12pe2/H5s5doYlAtARZr633zW3yyvTbFMELT9yCtntWy/B/clWn2DFo2dwFvHXpm8nNKLXeujzyj75lmsLRgUQT9lI1N32r+pXpOLjR0Vg/N3Qj7Krm40EqhZVEZjCUdrLcDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616537374; 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=YLrjTVwoMbXiA5kbm5QHR+bbexvD3KTjgQOc0ele8eY=; b=N8zqSdeHNRKtMQfjLcOVHNyRd9PZtbB/jfCFrxE/pA6bmrfX8kYH0mGtd9W+HWAyjjbO0uAtrBNwijrfNhoBhTGrKcNd2pAkeQ6Mr/DTMrVqLRBzOV5af2N7I0GOKMAlqtlMuvJMWC4WUdkILm5Owwuh2H+zxqQGkq7BB0fTsMw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616537374340983.303009672646; Tue, 23 Mar 2021 15:09:34 -0700 (PDT) Received: from localhost ([::1]:56574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOpDR-00032r-9K for importer@patchew.org; Tue, 23 Mar 2021 18:09:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1Y-000754-48 for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOp1P-0002mz-WF for qemu-devel@nongnu.org; Tue, 23 Mar 2021 17:57:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-hA1bQNHmMZyHAYI28kApTA-1; Tue, 23 Mar 2021 17:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A39F0100747D; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7028510027A5; Tue, 23 Mar 2021 21:57:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1633611326B4; Tue, 23 Mar 2021 22:56:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616536626; 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=YLrjTVwoMbXiA5kbm5QHR+bbexvD3KTjgQOc0ele8eY=; b=H2LK0pOGJFgixP8JleA3IhsJT5vNIlauS+DRuaDew9+chBm4IUsIkBXBGYrjQkgQ1xL4eG bS7brvnp2pbnKVvOSvZFy4OYHbyS+RYl5gbIDynsbnkZlv/JRqVOeCkS3LBwEIPBa2PamQ j6ywnuvmOmtRGr5MR6hj7z7QA6+1G+w= X-MC-Unique: hA1bQNHmMZyHAYI28kApTA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 29/29] block: Remove monitor command block_passwd Date: Tue, 23 Mar 2021 22:56:58 +0100 Message-Id: <20210323215658.3840228-30-armbru@redhat.com> In-Reply-To: <20210323215658.3840228-1-armbru@redhat.com> References: <20210323215658.3840228-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Command block_passwd always fails since Commit c01c214b69 "block: remove all encryption handling APIs" (v2.10.0) turned block_passwd into a stub that always fails, and hardcoded encryption_key_missing to false in query-named-block-nodes and query-block. Commit ad1324e044 "block: remove 'encryption_key_missing' flag from QAPI" just landed. Complete the cleanup job: remove block_passwd. Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Markus Armbruster Message-Id: <20210323101951.3686029-1-armbru@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 --- qapi/block-core.json | 14 -------------- qapi/pragma.json | 1 - block/monitor/block-hmp-cmds.c | 10 ---------- blockdev.c | 8 -------- hmp-commands.hx | 15 --------------- 5 files changed, 48 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 1c3f1deb03..6d227924d0 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1207,20 +1207,6 @@ ## { 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] } =20 -## -# @block_passwd: -# -# This command sets the password of a block device that has not been open -# with a password and requires one. -# -# This command is now obsolete and will always return an error since 2.10 -# -## -{ 'command': 'block_passwd', - 'data': { '*device': 'str', - '*node-name': 'str', - 'password': 'str' } } - ## # @block_resize: # diff --git a/qapi/pragma.json b/qapi/pragma.json index b4e17167e1..3bc0335d1f 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -6,7 +6,6 @@ # Commands allowed to return a non-dictionary: 'command-name-exceptions': [ 'add_client', - 'block_passwd', 'block_resize', 'block_set_io_throttle', 'client_migrate_info', diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 75d7fa9510..ebf1033f31 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -515,16 +515,6 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, error); } =20 -void hmp_block_passwd(Monitor *mon, const QDict *qdict) -{ - const char *device =3D qdict_get_str(qdict, "device"); - const char *password =3D qdict_get_str(qdict, "password"); - Error *err =3D NULL; - - qmp_block_passwd(true, device, false, NULL, password, &err); - hmp_handle_error(mon, err); -} - void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; diff --git a/blockdev.c b/blockdev.c index cf70bb4e43..621cc3b7c4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2407,14 +2407,6 @@ exit: job_txn_unref(block_job_txn); } =20 -void qmp_block_passwd(bool has_device, const char *device, - bool has_node_name, const char *node_name, - const char *password, Error **errp) -{ - error_setg(errp, - "Setting block passwords directly is no longer supported"); -} - BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *= node, const char *= name, Error **errp) diff --git a/hmp-commands.hx b/hmp-commands.hx index 9b88c45174..435c591a1c 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1493,21 +1493,6 @@ SRST used by another monitor command. ERST =20 - { - .name =3D "block_passwd", - .args_type =3D "device:B,password:s", - .params =3D "block_passwd device password", - .help =3D "set the password of encrypted block devices", - .cmd =3D hmp_block_passwd, - }, - -SRST -``block_passwd`` *device* *password* - Set the encrypted device *device* password to *password* - - This command is now obsolete and will always return an error since 2.10 -ERST - { .name =3D "block_set_io_throttle", .args_type =3D "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l= ,iops_wr:l", --=20 2.26.3