From patchwork Mon Jan 30 11:01:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13120918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1839FC61DA4 for ; Mon, 30 Jan 2023 11:02:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.486882.754282 (Exim 4.92) (envelope-from ) id 1pMRv5-00010c-1G; Mon, 30 Jan 2023 11:01:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 486882.754282; Mon, 30 Jan 2023 11:01:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pMRv4-0000zr-TU; Mon, 30 Jan 2023 11:01:50 +0000 Received: by outflank-mailman (input) for mailman id 486882; Mon, 30 Jan 2023 11:01:50 +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 1pMRv4-0000xa-1D for xen-devel@lists.xenproject.org; Mon, 30 Jan 2023 11:01:50 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7d21635d-a08d-11ed-b8d1-410ff93cb8f0; Mon, 30 Jan 2023 12:01:47 +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 7B02D16F3; Mon, 30 Jan 2023 03:02:28 -0800 (PST) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 268BC3F71E; Mon, 30 Jan 2023 03:01:45 -0800 (PST) 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: 7d21635d-a08d-11ed-b8d1-410ff93cb8f0 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Michal Orzel Subject: [PATCH v2 1/2] xen/cppcheck: sort alphabetically cppcheck report entries Date: Mon, 30 Jan 2023 11:01:31 +0000 Message-Id: <20230130110132.2774782-2-luca.fancellu@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230130110132.2774782-1-luca.fancellu@arm.com> References: <20230130110132.2774782-1-luca.fancellu@arm.com> MIME-Version: 1.0 Sort alphabetically cppcheck report entries when producing the text report, this will help comparing different reports and will group together findings from the same file. The sort operation is performed with two criteria, the first one is sorting by misra rule, the second one is sorting by file. Signed-off-by: Luca Fancellu Reviewed-by: Michal Orzel Acked-by: Stefano Stabellini --- Changes in v2: - Sort with two criteria, first misra rule, second filename (Michal, Jan) --- --- xen/scripts/xen_analysis/cppcheck_report_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/scripts/xen_analysis/cppcheck_report_utils.py b/xen/scripts/xen_analysis/cppcheck_report_utils.py index 02440aefdfec..0b6cc72b9ac1 100644 --- a/xen/scripts/xen_analysis/cppcheck_report_utils.py +++ b/xen/scripts/xen_analysis/cppcheck_report_utils.py @@ -104,6 +104,13 @@ def cppcheck_merge_txt_fragments(fragments_list, out_txt_file, strip_paths): for path in strip_paths: text_report_content[i] = text_report_content[i].replace( path + "/", "") + # Split by : separator + text_report_content[i] = text_report_content[i].split(":") + # sort alphabetically for second field (misra rule) and as second + # criteria for the first field (file name) + text_report_content.sort(key = lambda x: (x[1], x[0])) + # merge back with : separator + text_report_content = [":".join(x) for x in text_report_content] # Write the final text report outfile.writelines(text_report_content) except OSError as e: