From nobody Tue Feb 10 12:58:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506953939763821.9659582096687; Mon, 2 Oct 2017 07:18:59 -0700 (PDT) Received: from localhost ([::1]:52517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz1YW-0002QF-Uu for importer@patchew.org; Mon, 02 Oct 2017 10:18:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz1Th-0006xT-IN for qemu-devel@nongnu.org; Mon, 02 Oct 2017 10:13:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz1Tg-0003c1-7S for qemu-devel@nongnu.org; Mon, 02 Oct 2017 10:13:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dz1Tf-0003bM-Us for qemu-devel@nongnu.org; Mon, 02 Oct 2017 10:13:48 -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 mx1.redhat.com (Postfix) with ESMTPS id 1831BC04AC6C for ; Mon, 2 Oct 2017 14:13:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 710C599DC4; Mon, 2 Oct 2017 14:13:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DC2AF115626E; Mon, 2 Oct 2017 16:13:41 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1831BC04AC6C Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 2 Oct 2017 16:13:34 +0200 Message-Id: <20171002141341.24616-5-armbru@redhat.com> In-Reply-To: <20171002141341.24616-1-armbru@redhat.com> References: <20171002141341.24616-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 02 Oct 2017 14:13:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/11] qapi: Make cur_doc local to QAPISchemaParser.__init__() X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" QAPISchemaParser.cur_doc is used only by .__init__() and its helper .reject_expr_doc(). Make it local to __init__() and pass it to .reject_expr_doc() explicitly. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 6c8001e96d..2f2738f562 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -272,21 +272,21 @@ class QAPISchemaParser(object): self.line_pos =3D 0 self.exprs =3D [] self.docs =3D [] - self.cur_doc =3D None self.accept() + cur_doc =3D None =20 while self.tok is not None: info =3D {'file': self.fname, 'line': self.line, 'parent': self.incl_info} if self.tok =3D=3D '#': - self.reject_expr_doc() - self.cur_doc =3D self.get_doc(info) - self.docs.append(self.cur_doc) + self.reject_expr_doc(cur_doc) + cur_doc =3D self.get_doc(info) + self.docs.append(cur_doc) continue =20 expr =3D self.get_expr(False) if 'include' in expr: - self.reject_expr_doc() + self.reject_expr_doc(cur_doc) if len(expr) !=3D 1: raise QAPISemError(info, "Invalid 'include' directive") include =3D expr['include'] @@ -296,7 +296,7 @@ class QAPISchemaParser(object): self._include(include, info, os.path.dirname(abs_fname), previously_included) elif "pragma" in expr: - self.reject_expr_doc() + self.reject_expr_doc(cur_doc) if len(expr) !=3D 1: raise QAPISemError(info, "Invalid 'pragma' directive") pragma =3D expr['pragma'] @@ -308,22 +308,22 @@ class QAPISchemaParser(object): else: expr_elem =3D {'expr': expr, 'info': info} - if self.cur_doc: - if not self.cur_doc.symbol: + if cur_doc: + if not cur_doc.symbol: raise QAPISemError( - self.cur_doc.info, - "Expression documentation required") - expr_elem['doc'] =3D self.cur_doc + cur_doc.info, "Expression documentation requir= ed") + expr_elem['doc'] =3D cur_doc self.exprs.append(expr_elem) - self.cur_doc =3D None - self.reject_expr_doc() + cur_doc =3D None + self.reject_expr_doc(cur_doc) =20 - def reject_expr_doc(self): - if self.cur_doc and self.cur_doc.symbol: + @staticmethod + def reject_expr_doc(doc): + if doc and doc.symbol: raise QAPISemError( - self.cur_doc.info, + doc.info, "Documentation for '%s' is not followed by the definition" - % self.cur_doc.symbol) + % doc.symbol) =20 def _include(self, include, info, base_dir, previously_included): incl_abs_fname =3D os.path.join(base_dir, include) --=20 2.13.6