From nobody Mon Feb 9 23:03:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1706699013798193.19188924497075; Wed, 31 Jan 2024 03:03:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.673918.1048494 (Exim 4.92) (envelope-from ) id 1rV8N3-0001R3-Ia; Wed, 31 Jan 2024 11:03:09 +0000 Received: by outflank-mailman (output) from mailman id 673918.1048494; Wed, 31 Jan 2024 11:03:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rV8N3-0001QO-Di; Wed, 31 Jan 2024 11:03:09 +0000 Received: by outflank-mailman (input) for mailman id 673918; Wed, 31 Jan 2024 11:03:08 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rV8N2-0001NO-BK for xen-devel@lists.xenproject.org; Wed, 31 Jan 2024 11:03:08 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 4ff0d39e-c028-11ee-8a43-1f161083a0e0; Wed, 31 Jan 2024 12:03:07 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D5AE71477; Wed, 31 Jan 2024 03:03:49 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E71183F762; Wed, 31 Jan 2024 03:03:05 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4ff0d39e-c028-11ee-8a43-1f161083a0e0 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini Subject: [PATCH 2/3] xen-analysis.py: Substitute only the comment instead of the line Date: Wed, 31 Jan 2024 11:02:40 +0000 Message-Id: <20240131110241.3951995-3-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240131110241.3951995-1-luca.fancellu@arm.com> References: <20240131110241.3951995-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706699014826100007 Content-Type: text/plain; charset="utf-8" Change the code in tag_database.py to substitute only the SAF-* comment instead of replacing the line. Signed-off-by: Luca Fancellu --- xen/scripts/xen_analysis/tag_database.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_ana= lysis/tag_database.py index abba163aec71..dc0558a46ed6 100644 --- a/xen/scripts/xen_analysis/tag_database.py +++ b/xen/scripts/xen_analysis/tag_database.py @@ -16,14 +16,18 @@ tool_syntax =3D { "eclair":"-E> hide VID 1 \"\"" } =20 +def get_xen_tag_regex(tool): + return rf'(?PSAF-(?P\d+)-(?Psafe|false-positive-{tool})= )' + =20 def get_xen_tag_index_type_regex(tool): - return rf'^SAF-(?P\d+)-(?Psafe|false-positive-{tool})$' + return rf'^{get_xen_tag_regex(tool)}$' =20 =20 def get_xen_tag_comment_regex(tool): - tag=3Drf'(?PSAF-\d+-(?:safe|false-positive-{tool}))' - return rf'^[ \t]*/\* +{tag}.*\*/$' + before_comment =3D r'(?P[ \t]*)' + comment =3D rf'(?P/\* +{get_xen_tag_regex(tool)}.*\*/)' + return rf'^(?P{before_comment}{comment})$' =20 =20 # Returns a data structure containing dictionaries for safe and false-posi= tive-* @@ -66,7 +70,7 @@ def load_tag_database(tool, input_files, data_struct =3D = None, schema =3D "safe"): # Save in safe or false-positive-* the key {#id: "comment"} id_number =3D int(xen_tag.group('id')) key =3D xen_tag.group('type') - ret[key][id_number] =3D "/* {} */\n".format(comment) + ret[key][id_number] =3D "/* {} */".format(comment) else: raise TagDatabaseError( "Error in database file, entry {} has unexpected " @@ -101,7 +105,11 @@ def substitute_tags(tool, input_file, grep_struct, sub= s_rules): id_number =3D int(xen_tag_regex_obj.group('id')) key =3D xen_tag_regex_obj.group('type') if id_number in subs_rules[key]: - parsed_content[line_number-1] =3D subs_rules[key][id_n= umber] + comment_in =3D grep_struct["matches"][line_number]['co= mment'] + comment_out =3D subs_rules[key][id_number] + parsed_content[line_number-1] =3D re.sub( + re.escape(comment_in), comment_out, + parsed_content[line_number-1]) =20 outfile.writelines(parsed_content) except Exception as e: --=20 2.34.1