From patchwork Thu May 4 13:12:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13231209 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 C3277C7EE21 for ; Thu, 4 May 2023 13:13:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.529726.824430 (Exim 4.92) (envelope-from ) id 1puYlX-00049z-Gr; Thu, 04 May 2023 13:12:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 529726.824430; Thu, 04 May 2023 13:12:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1puYlX-00049q-E4; Thu, 04 May 2023 13:12:59 +0000 Received: by outflank-mailman (input) for mailman id 529726; Thu, 04 May 2023 13:12:58 +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 1puYlW-0003tK-9n for xen-devel@lists.xenproject.org; Thu, 04 May 2023 13:12:58 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 633d48c4-ea7d-11ed-b226-6b7b168915f2; Thu, 04 May 2023 15:12: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 6418112FC; Thu, 4 May 2023 06:13: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 E283A3F67D; Thu, 4 May 2023 06:12:55 -0700 (PDT) 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: 633d48c4-ea7d-11ed-b226-6b7b168915f2 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 Subject: [PATCH 2/3] xen/misra: xen-analysis.py: allow cppcheck version above 2.7 Date: Thu, 4 May 2023 14:12:44 +0100 Message-Id: <20230504131245.2985400-3-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504131245.2985400-1-luca.fancellu@arm.com> References: <20230504131245.2985400-1-luca.fancellu@arm.com> MIME-Version: 1.0 Allow the use of Cppcheck version above 2.7, exception for 2.8 which is known and documented do be broken. Signed-off-by: Luca Fancellu Acked-by: Stefano Stabellini Tested-by: Stefano Stabellini --- xen/scripts/xen_analysis/cppcheck_analysis.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py index 658795bb9f5b..c3783e8df343 100644 --- a/xen/scripts/xen_analysis/cppcheck_analysis.py +++ b/xen/scripts/xen_analysis/cppcheck_analysis.py @@ -157,13 +157,25 @@ def generate_cppcheck_deps(): "Error occured retrieving cppcheck version:\n{}\n\n{}" ) - version_regex = re.search('^Cppcheck (.*)$', invoke_cppcheck, flags=re.M) + version_regex = re.search('^Cppcheck (\d+).(\d+)(?:.\d+)?$', + invoke_cppcheck, flags=re.M) # Currently, only cppcheck version >= 2.7 is supported, but version 2.8 is # known to be broken, please refer to docs/misra/cppcheck.txt - if (not version_regex) or (not version_regex.group(1).startswith("2.7")): + if (not version_regex) or len(version_regex.groups()) < 2: raise CppcheckDepsPhaseError( - "Can't find cppcheck version or version is not 2.7" - ) + "Can't find cppcheck version or version not identified: " + "{}".format(invoke_cppcheck) + ) + major = int(version_regex.group(1)) + minor = int(version_regex.group(2)) + if major < 2 or (major == 2 and minor < 7): + raise CppcheckDepsPhaseError( + "Cppcheck version < 2.7 is not supported" + ) + if major == 2 and minor == 8: + raise CppcheckDepsPhaseError( + "Cppcheck version 2.8 is known to be broken, see the documentation" + ) # If misra option is selected, append misra addon and generate cppcheck # files for misra analysis