From nobody Wed Nov 13 07:13:25 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