From nobody Thu May 2 17:26:34 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631077129510877.8752146535023; Tue, 7 Sep 2021 21:58:49 -0700 (PDT) Received: from localhost ([::1]:53236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNpfV-00071f-04 for importer@patchew.org; Wed, 08 Sep 2021 00:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbc-0007DS-T4 for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37268) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpba-0003nT-Gi for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:40 -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-330-TSsceqIMOwusAeoUF681jg-1; Wed, 08 Sep 2021 00:54:35 -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 4461384A5E3; Wed, 8 Sep 2021 04:54:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 44CB877701; Wed, 8 Sep 2021 04:54:30 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CF9921138611; Wed, 8 Sep 2021 06:54:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631076876; 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=DFb3t7eriCszmhhZuLlnl6smKPjA75DRssls46B/OFc=; b=jGDBSWaaVbkTQYhWQkaSnf+Tu2POqHK2hwqOXZXPvj3aWpSy9hcjQk3lXweiKiSBkrNLwL u1Mwo3LbGk9f97DSxLuf8MLkbmMHwihU0mT2OPhiS20LyU6ZuJXL/ajrhI4uErgFZwYoQb VMLBEzb7B5T9X12Ce+fLRG2leb9B/L8= X-MC-Unique: TSsceqIMOwusAeoUF681jg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 1/5] qapi: Fix a botched type annotation Date: Wed, 8 Sep 2021 06:54:24 +0200 Message-Id: <20210908045428.2689093-2-armbru@redhat.com> In-Reply-To: <20210908045428.2689093-1-armbru@redhat.com> References: <20210908045428.2689093-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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, jsnow@redhat.com, michael.roth@amd.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631077131077100001 Content-Type: text/plain; charset="utf-8" Mypy is unhappy: $ mypy --config-file=3Dscripts/qapi/mypy.ini `git-ls-files scripts/qapi= /\*py` scripts/qapi/common.py:208: error: Function is missing a return type an= notation scripts/qapi/common.py:227: error: Returning Any from function declared= to return "str" Messed up in commit ccea6a8637 "qapi: Factor common recursion out of cgen_ifcond(), docgen_ifcond()". Tidy up. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 5f8f76e5b2..c4d11b9637 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -205,7 +205,8 @@ def gen_ifcond(ifcond: Optional[Union[str, Dict[str, An= y]]], cond_fmt: str, not_fmt: str, all_operator: str, any_operator: str) -> str: =20 - def do_gen(ifcond: Union[str, Dict[str, Any]], need_parens: bool): + def do_gen(ifcond: Union[str, Dict[str, Any]], + need_parens: bool) -> str: if isinstance(ifcond, str): return cond_fmt % ifcond assert isinstance(ifcond, dict) and len(ifcond) =3D=3D 1 --=20 2.31.1 From nobody Thu May 2 17:26:34 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631077122659139.5842769731172; Tue, 7 Sep 2021 21:58:42 -0700 (PDT) Received: from localhost ([::1]:53364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNpfV-00076b-Np for importer@patchew.org; Wed, 08 Sep 2021 00:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbf-0007Kt-N1 for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbZ-0003nW-NJ for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:43 -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-495-MuhgNHVjMX-6vy3ZkVj04g-1; Wed, 08 Sep 2021 00:54:35 -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 617EC180FD8F; Wed, 8 Sep 2021 04:54:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F0CC369A; Wed, 8 Sep 2021 04:54:30 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D1FA511385C7; Wed, 8 Sep 2021 06:54:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631076876; 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=npDFODy2eKteeb4JRNZZSD7dOo7nI5cVmBQw3BVDw6o=; b=CB1MAwnemOVxJsvH8/olCCbHWYELP2HTu324ZGJ4hujqxZZ/Jn6PToE88Mh7EEwY29PrJe i2BFD7MMagbritQ+5G7pdCXsYzLNXpdm0yuBSf5+jUVia1Nmeq3UAS1FDDjtQdlcJuD4ac idopv7H6Fuj7EygAjchVZc6P+aOrsxI= X-MC-Unique: MuhgNHVjMX-6vy3ZkVj04g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 2/5] qapi: Drop Indentation.__bool__() Date: Wed, 8 Sep 2021 06:54:25 +0200 Message-Id: <20210908045428.2689093-3-armbru@redhat.com> In-Reply-To: <20210908045428.2689093-1-armbru@redhat.com> References: <20210908045428.2689093-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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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: marcandre.lureau@redhat.com, jsnow@redhat.com, michael.roth@amd.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631077124740100001 Content-Type: text/plain; charset="utf-8" Intentation.__bool__() is not worth its keep: it has just one user, which can just as well check .__str__() instead. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index c4d11b9637..1d62c27fb7 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -142,10 +142,6 @@ def __str__(self) -> str: """Return the current indentation as a string of spaces.""" return ' ' * self._level =20 - def __bool__(self) -> bool: - """True when there is a non-zero indentation.""" - return bool(self._level) - def increase(self, amount: int =3D 4) -> None: """Increase the indentation level by ``amount``, default 4.""" self._level +=3D amount @@ -169,8 +165,9 @@ def cgen(code: str, **kwds: object) -> str: Obey `indent`, and strip `EATSPACE`. """ raw =3D code % kwds - if indent: - raw =3D re.sub(r'^(?!(#|$))', str(indent), raw, flags=3Dre.MULTILI= NE) + pfx =3D str(indent) + if pfx: + raw =3D re.sub(r'^(?!(#|$))', pfx, raw, flags=3Dre.MULTILINE) return re.sub(re.escape(EATSPACE) + r' *', '', raw) =20 =20 --=20 2.31.1 From nobody Thu May 2 17:26:34 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631077000558972.7012219957952; Tue, 7 Sep 2021 21:56:40 -0700 (PDT) Received: from localhost ([::1]:45186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNpdX-0001WZ-Dh for importer@patchew.org; Wed, 08 Sep 2021 00:56:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbc-0007CU-Gy for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbZ-0003mi-Jr for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:39 -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-300-PwmppVlmNtiL0miO8pqpLA-1; Wed, 08 Sep 2021 00:54:34 -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 58A4884A5E0; Wed, 8 Sep 2021 04:54:33 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F145100238C; Wed, 8 Sep 2021 04:54:30 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D5F6A1138220; Wed, 8 Sep 2021 06:54:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631076875; 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=EMGURndCw+evKuhXByRYvX/sDzPGAXD9ztdMsYVEBbY=; b=I3JM98CP0uthNyhBfsww1qiGiacrvApI7RGR9FXWRv3+exvdkH+ggNxbaCS5g83UWjC+S8 J9dTC3sODASO42xov29PRY3KlY1g+56fuJfmdz7kzY7Ns0sFio6MMrGZ4Ex0f4/m0eh6mb 15cZOL3zN+eDXN6FSkxbenJKJrNpuRg= X-MC-Unique: PwmppVlmNtiL0miO8pqpLA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 3/5] qapi: Bury some unused code in class Indentation Date: Wed, 8 Sep 2021 06:54:26 +0200 Message-Id: <20210908045428.2689093-4-armbru@redhat.com> In-Reply-To: <20210908045428.2689093-1-armbru@redhat.com> References: <20210908045428.2689093-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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, jsnow@redhat.com, michael.roth@amd.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631077002280100007 Content-Type: text/plain; charset="utf-8" .__int__() has never been used. Drop it. .decrease() raises ArithmeticError when asked to decrease indentation level below zero. Nothing catches it. It's a programming error. Dumb down to assert. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 1d62c27fb7..489273574a 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -132,9 +132,6 @@ class Indentation: def __init__(self, initial: int =3D 0) -> None: self._level =3D initial =20 - def __int__(self) -> int: - return self._level - def __repr__(self) -> str: return "{}({:d})".format(type(self).__name__, self._level) =20 @@ -148,9 +145,7 @@ def increase(self, amount: int =3D 4) -> None: =20 def decrease(self, amount: int =3D 4) -> None: """Decrease the indentation level by ``amount``, default 4.""" - if self._level < amount: - raise ArithmeticError( - f"Can't remove {amount:d} spaces from {self!r}") + assert amount <=3D self._level self._level -=3D amount =20 =20 --=20 2.31.1 From nobody Thu May 2 17:26:34 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163107699897397.77865493856962; Tue, 7 Sep 2021 21:56:38 -0700 (PDT) Received: from localhost ([::1]:45070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNpdV-0001RS-Rs for importer@patchew.org; Wed, 08 Sep 2021 00:56:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbc-0007Bo-C7 for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbZ-0003mF-3b for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:39 -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-60-hQmbfVe_MAqUucJz_Jlkiw-1; Wed, 08 Sep 2021 00:54:34 -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 58E1610053E7; Wed, 8 Sep 2021 04:54:33 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60181100763B; Wed, 8 Sep 2021 04:54:30 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DB96B1138221; Wed, 8 Sep 2021 06:54:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631076875; 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=8s3GVflHgiaeZv1+C+0LpGk9NBKUroVD7P8DxZqB9Q0=; b=bBEro6IBt42n5omxZNftNj7RTCWkKkaf9MwaVjkL81BYImOD42ASy9G+cZzszgm1Nce/wl eppI117Y70OtjkpadBkI3oNcB0yR4LEjNYDOCJ7Yypo+X97MRsxXqUF58kjpGGIOktZkBV WXtGDsIwWwj8M4zYnDajvNXNCvEAVbs= X-MC-Unique: hQmbfVe_MAqUucJz_Jlkiw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 4/5] tests/qapi-schema: Cover 'not' condition with empty argument Date: Wed, 8 Sep 2021 06:54:27 +0200 Message-Id: <20210908045428.2689093-5-armbru@redhat.com> In-Reply-To: <20210908045428.2689093-1-armbru@redhat.com> References: <20210908045428.2689093-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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, jsnow@redhat.com, michael.roth@amd.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631077000562100002 Content-Type: text/plain; charset="utf-8" We flag this, but the error message is bogus: bad-if-not.json:2: 'if' condition [] of struct is useless The next commit will fix it. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/qapi-schema/bad-if-not.err | 2 ++ tests/qapi-schema/bad-if-not.json | 3 +++ tests/qapi-schema/bad-if-not.out | 0 tests/qapi-schema/meson.build | 1 + 4 files changed, 6 insertions(+) create mode 100644 tests/qapi-schema/bad-if-not.err create mode 100644 tests/qapi-schema/bad-if-not.json create mode 100644 tests/qapi-schema/bad-if-not.out diff --git a/tests/qapi-schema/bad-if-not.err b/tests/qapi-schema/bad-if-no= t.err new file mode 100644 index 0000000000..b3acdd679a --- /dev/null +++ b/tests/qapi-schema/bad-if-not.err @@ -0,0 +1,2 @@ +bad-if-not.json: In struct 'TestIfStruct': +bad-if-not.json:2: 'if' condition [] of struct is useless diff --git a/tests/qapi-schema/bad-if-not.json b/tests/qapi-schema/bad-if-n= ot.json new file mode 100644 index 0000000000..9fdaacc47b --- /dev/null +++ b/tests/qapi-schema/bad-if-not.json @@ -0,0 +1,3 @@ +# check 'if not' with empy argument +{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, + 'if': { 'not': '' } } diff --git a/tests/qapi-schema/bad-if-not.out b/tests/qapi-schema/bad-if-no= t.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index 4697c070bc..6b2a4ce41a 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -43,6 +43,7 @@ schemas =3D [ 'bad-if-key.json', 'bad-if-keys.json', 'bad-if-list.json', + 'bad-if-not.json', 'bad-type-bool.json', 'bad-type-dict.json', 'bad-type-int.json', --=20 2.31.1 From nobody Thu May 2 17:26:34 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631076999271417.744561278932; Tue, 7 Sep 2021 21:56:39 -0700 (PDT) Received: from localhost ([::1]:45098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNpdW-0001SR-5C for importer@patchew.org; Wed, 08 Sep 2021 00:56:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpbc-0007DA-P9 for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNpba-0003ob-OW for qemu-devel@nongnu.org; Wed, 08 Sep 2021 00:54:40 -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-354-GYDmXL7YOEmZ3TzD4kMuyg-1; Wed, 08 Sep 2021 00:54:35 -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 0B1D210059CF; Wed, 8 Sep 2021 04:54:35 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D060B5D9DC; Wed, 8 Sep 2021 04:54:34 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DECF41138222; Wed, 8 Sep 2021 06:54:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631076877; 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=dLsnqIHIZh+GeDG9cQY/GuK0Dyf7v/+iBa3poJWKt2U=; b=X2TciJH8pTIDCGiv6XlQWMPDnMlRjF+Pc4sAw/jvr1wUUa+abtcxaNLO1qqa0XJPHP52qs OY7OZCtCoyf/BjzLfaGfzxZHsG6ET7ykX2snPgct1+IwlknRXnTY33wzpXFlUbh2FtTotD wIaNYeDtwtAdkeyYiUQQnp+13qnyvu0= X-MC-Unique: GYDmXL7YOEmZ3TzD4kMuyg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 5/5] qapi: Fix bogus error for 'if': { 'not': '' } Date: Wed, 8 Sep 2021 06:54:28 +0200 Message-Id: <20210908045428.2689093-6-armbru@redhat.com> In-Reply-To: <20210908045428.2689093-1-armbru@redhat.com> References: <20210908045428.2689093-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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, jsnow@redhat.com, michael.roth@amd.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631077000563100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/expr.py | 21 +++++++++++++-------- tests/qapi-schema/bad-if-not.err | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index b62f0a3640..ad3732c7f0 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -293,17 +293,22 @@ def _check_if(cond: Union[str, object]) -> None: info, "'if' condition of %s has conflicting keys" % source) =20 - oper, operands =3D next(iter(cond.items())) + if 'not' in cond: + _check_if(cond['not']) + elif 'all' in cond: + _check_infix('all', cond['all']) + else: + _check_infix('any', cond['any']) + + def _check_infix(operator: str, operands: object): + if not isinstance(operands, list): + raise QAPISemError( + info, + "'%s' condition of %s must be an array" + % (operator, source)) if not operands: raise QAPISemError( info, "'if' condition [] of %s is useless" % source) - - if oper =3D=3D "not": - _check_if(operands) - return - if oper in ("all", "any") and not isinstance(operands, list): - raise QAPISemError( - info, "'%s' condition of %s must be an array" % (oper, sou= rce)) for operand in operands: _check_if(operand) =20 diff --git a/tests/qapi-schema/bad-if-not.err b/tests/qapi-schema/bad-if-no= t.err index b3acdd679a..b33f5e16b8 100644 --- a/tests/qapi-schema/bad-if-not.err +++ b/tests/qapi-schema/bad-if-not.err @@ -1,2 +1,2 @@ bad-if-not.json: In struct 'TestIfStruct': -bad-if-not.json:2: 'if' condition [] of struct is useless +bad-if-not.json:2: 'if' condition '' of struct is not a valid identifier --=20 2.31.1