From nobody Sun May 5 16:33:18 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 165650736643688.8174927675409; Wed, 29 Jun 2022 05:56:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.357860.586699 (Exim 4.92) (envelope-from ) id 1o6XEJ-0007W1-76; Wed, 29 Jun 2022 12:55:39 +0000 Received: by outflank-mailman (output) from mailman id 357860.586699; Wed, 29 Jun 2022 12:55:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6XEJ-0007Vu-3q; Wed, 29 Jun 2022 12:55:39 +0000 Received: by outflank-mailman (input) for mailman id 357860; Wed, 29 Jun 2022 12:55:37 +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 1o6XEH-0007Vo-RC for xen-devel@lists.xenproject.org; Wed, 29 Jun 2022 12:55:37 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id c45e385f-f7aa-11ec-bd2d-47488cf2e6aa; Wed, 29 Jun 2022 14:55:36 +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 043F1152B; Wed, 29 Jun 2022 05:55:35 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9811A3F792; Wed, 29 Jun 2022 05:55:33 -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: c45e385f-f7aa-11ec-bd2d-47488cf2e6aa 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 v2] docs/misra: Add instructions for cppcheck Date: Wed, 29 Jun 2022 13:55:26 +0100 Message-Id: <20220629125526.28190-1-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 X-ZM-MESSAGEID: 1656507368545100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add instructions on how to build cppcheck, the version currently used and an example to use the cppcheck integration to run the analysis on the Xen codebase Signed-off-by: Luca Fancellu Acked-by: Julien Grall --- Changes in v2: - typo fixes, removed build command line, rephrasing (Julien) --- docs/misra/cppcheck.txt | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 docs/misra/cppcheck.txt diff --git a/docs/misra/cppcheck.txt b/docs/misra/cppcheck.txt new file mode 100644 index 000000000000..25d8c3050b72 --- /dev/null +++ b/docs/misra/cppcheck.txt @@ -0,0 +1,64 @@ +Cppcheck for Xen static and MISRA analysis +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Xen can be analysed for both static analysis problems and MISRA violation = using +cppcheck, the open source tool allows the creation of a report with all the +findings. Xen has introduced the support in the Makefile so it's very easy= to +use and in this document we can see how. + +The minimum version required for cppcheck is 2.7. Note that at the time of +writing (June 2022), the version 2.8 is known to be broken [1]. + +Install cppcheck on the system +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D + +Cppcheck can be retrieved from the github repository or by downloading the +tarball, the version tested so far is the 2.7: + + - https://github.com/danmar/cppcheck/tree/2.7 + - https://github.com/danmar/cppcheck/archive/2.7.tar.gz + +To compile and install it, the complete command line can be found in readm= e.md, +section "GNU make", please add the "install" target to that line and use e= very +argument as it is in the documentation of the tool, so that every Xen deve= loper +following this page can reproduce the same findings. + +This will compile and install cppcheck in /usr/bin and all the cppcheck co= nfig +files and addons will be installed in /usr/share/cppcheck folder, please m= odify +that path in FILESDIR if it's not convinient for your system. + +If you don't want to overwrite a possible cppcheck binary installed in your +system, you can omit the "install" target and FILESDIR, cppcheck will be j= ust +compiled and the binaries will be available in the same folder. +If you choose to do that, later in this page it's explained how to use a l= ocal +installation of cppcheck for the Xen analysis. + +Dependencies are listed in the readme.md of the project repository. + +Use cppcheck to analyse Xen +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D + +Using cppcheck integration is very simple, it requires few steps: + + 1) Compile Xen + 2) call the cppcheck make target to generate a report in xml format: + make CPPCHECK_MISRA=3Dy cppcheck + 3) call the cppcheck-html make target to generate a report in xml and html + format: + make CPPCHECK_MISRA=3Dy cppcheck-html + + In case the cppcheck binaries are not in the PATH, CPPCHECK and + CPPCHECK_HTMLREPORT variables can be overridden with the full path to = the + binaries: + + make -C xen \ + CPPCHECK=3D/path/to/cppcheck \ + CPPCHECK_HTMLREPORT=3D/path/to/cppcheck-htmlreport \ + CPPCHECK_MISRA=3Dy \ + cppcheck-html + +The output is by default in a folder named cppcheck-htmlreport, but the na= me +can be changed by passing it in the CPPCHECK_HTMLREPORT_OUTDIR variable. + + +[1] https://sourceforge.net/p/cppcheck/discussion/general/thread/bfc3ab6c4= 1/?limit=3D25 --=20 2.17.1