From nobody Sat Sep 21 03:17:19 2024 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 16896724589571003.9517505888879; Tue, 18 Jul 2023 02:27:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.565023.882829 (Exim 4.92) (envelope-from ) id 1qLgyy-0000Ln-3R; Tue, 18 Jul 2023 09:27:00 +0000 Received: by outflank-mailman (output) from mailman id 565023.882829; Tue, 18 Jul 2023 09:27:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qLgyy-0000Lg-0T; Tue, 18 Jul 2023 09:27:00 +0000 Received: by outflank-mailman (input) for mailman id 565023; Tue, 18 Jul 2023 09:26:59 +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 1qLgyx-0000LV-BX for xen-devel@lists.xenproject.org; Tue, 18 Jul 2023 09:26:59 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 3da6c0a6-254d-11ee-b23a-6b7b168915f2; Tue, 18 Jul 2023 11:26:57 +0200 (CEST) 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 63D9FD75; Tue, 18 Jul 2023 02:27:40 -0700 (PDT) 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 4CB803F67D; Tue, 18 Jul 2023 02:26:56 -0700 (PDT) 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: 3da6c0a6-254d-11ee-b23a-6b7b168915f2 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini Subject: [PATCH 1/2] xen/misra: diff-report.py: Fix UnifiedFormatParser change line registration Date: Tue, 18 Jul 2023 10:26:35 +0100 Message-Id: <20230718092637.2433974-2-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718092637.2433974-1-luca.fancellu@arm.com> References: <20230718092637.2433974-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1689672459287100001 Content-Type: text/plain; charset="utf-8" Fix the line number on the registration of a 'remove' change type when consecutive 'remove' changes are registered. Currently the algorithm registers consecutive 'remove' changes at the same line it encounter the first one, 'add' changes type are not affected by the bug. Fixes: 1d7c45f895b6 ("xen/misra: diff-report.py: add report patching featur= e") Signed-off-by: Luca Fancellu Acked-by: Stefano Stabellini --- .../xen_analysis/diff_tool/unified_format_parser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py b/= xen/scripts/xen_analysis/diff_tool/unified_format_parser.py index 8b3fbc318df7..6c506caeafce 100644 --- a/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py +++ b/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py @@ -144,6 +144,7 @@ class UnifiedFormatParser(object): file_linenum =3D 0 hunk_a_linemax =3D 0 hunk_b_linemax =3D 0 + consecutive_remove =3D 0 diff_elem =3D None parse_state =3D ParserState.FIND_DIFF_HEADER ChangeMode =3D ChangeSet.ChangeMode @@ -210,14 +211,18 @@ class UnifiedFormatParser(object): if (hunk_b_linemax > 0) and line.startswith("+"): diff_elem.add_change(file_linenum, ChangeType.ADD) hunk_b_linemax -=3D 1 + consecutive_remove =3D 0 elif (hunk_a_linemax > 0) and line.startswith("-"): - diff_elem.add_change(file_linenum, ChangeType.REMOVE) + diff_elem.add_change(file_linenum + consecutive_remove, + ChangeType.REMOVE) hunk_a_linemax -=3D 1 file_linenum -=3D 1 + consecutive_remove +=3D 1 elif ((hunk_a_linemax + hunk_b_linemax) > 0) and \ line.startswith(" "): hunk_a_linemax -=3D 1 if (hunk_a_linemax > 0) else 0 hunk_b_linemax -=3D 1 if (hunk_b_linemax > 0) else 0 + consecutive_remove =3D 0 =20 if (hunk_a_linemax + hunk_b_linemax) <=3D 0: parse_state =3D ParserState.FIND_HUNK_OR_DIFF_HEADER --=20 2.34.1 From nobody Sat Sep 21 03:17:19 2024 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 1689672456654516.9902510345071; Tue, 18 Jul 2023 02:27:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.565025.882849 (Exim 4.92) (envelope-from ) id 1qLgyz-0000q1-P9; Tue, 18 Jul 2023 09:27:01 +0000 Received: by outflank-mailman (output) from mailman id 565025.882849; Tue, 18 Jul 2023 09:27:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qLgyz-0000pq-ML; Tue, 18 Jul 2023 09:27:01 +0000 Received: by outflank-mailman (input) for mailman id 565025; Tue, 18 Jul 2023 09:27:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qLgyy-0000LP-1t for xen-devel@lists.xenproject.org; Tue, 18 Jul 2023 09:27:00 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 3df795e6-254d-11ee-8611-37d641c3527e; Tue, 18 Jul 2023 11:26:58 +0200 (CEST) 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 40931FEC; Tue, 18 Jul 2023 02:27:41 -0700 (PDT) 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 299CF3F67D; Tue, 18 Jul 2023 02:26:57 -0700 (PDT) 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: 3df795e6-254d-11ee-8611-37d641c3527e From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini Subject: [PATCH 2/2] xen/misra: diff-report.py: fix function invocation Date: Tue, 18 Jul 2023 10:26:36 +0100 Message-Id: <20230718092637.2433974-3-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718092637.2433974-1-luca.fancellu@arm.com> References: <20230718092637.2433974-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1689672457222100001 Content-Type: text/plain; charset="utf-8" Fix the invocation of invoke_command() that takes an optional parameter for the exception type, but in the code the error message template was passed instead, so fix it passing a new exception type. Fixes: 1d7c45f895b6 ("xen/misra: diff-report.py: add report patching featur= e") Signed-off-by: Luca Fancellu Acked-by: Stefano Stabellini --- xen/scripts/diff-report.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/scripts/diff-report.py b/xen/scripts/diff-report.py index 636f98f5eebe..a1fe6bc2fccd 100755 --- a/xen/scripts/diff-report.py +++ b/xen/scripts/diff-report.py @@ -13,6 +13,10 @@ from xen_analysis.settings import repo_dir from xen_analysis.utils import invoke_command =20 =20 +class DiffReportError(Exception): + pass + + def log_info(text, end=3D'\n'): # type: (str, str) -> None global args @@ -97,7 +101,7 @@ def main(argv): git_diff =3D invoke_command( "git --git-dir=3D{}/.git diff -C -C {}..{}" .format(repo_dir, args.baseline_rev, args.report_rev), - True, "Error occured invoking:\n{}\n\n{}" + True, DiffReportError, "Error occured invoking:\n{}\n\n{}" ) diff_source =3D git_diff.splitlines(keepends=3DTrue) if diff_source: @@ -105,7 +109,7 @@ def main(argv): diffs =3D UnifiedFormatParser(diff_source) debug.debug_print_parsed_diff(diffs) log_info(" [OK]") - except (ReportError, UnifiedFormatParseError) as e: + except (DiffReportError, ReportError, UnifiedFormatParseError) as e: print("ERROR: {}".format(e)) sys.exit(1) =20 --=20 2.34.1