mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
Add Cppcheck analysis to the xen-analysis.py script using the arguments --run-cppcheck. Now cppcheck analysis will build Xen while the analysis is performed on the source files, it will produce a text report and an additional html output when the script is called with --cppcheck-html. With this patch cppcheck will benefit of platform configuration files that will help it to understand the target of the compilation and improve the analysis. These are XML files placed in xen/tools/cppcheck-plat/, describing to cppcheck the length of basic types to help it in the analysis. To do so: - Update xen-analysis.py with the code to integrate cppcheck. - add platform configuration files for cppcheck.. - add cppcheck-cc.sh script that is a wrapper for cppcheck and it's used as Xen compiler, it will intercept all flags given from the make build system and it will execute cppcheck on the compiled file together with the file compilation. - guarded hypercall-defs.c with CPPCHECK define because cppcheck gets confused as the file does not contain c code. - add false-positive-cppcheck.json file - update documentation. - update .gitignore Signed-off-by: Luca Fancellu <luca.fancellu@arm.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Tested-by: Stefano Stabellini <sstabellini@kernel.org>
44 lines
1.8 KiB
Plaintext
44 lines
1.8 KiB
Plaintext
Cppcheck for Xen static and MISRA analysis
|
|
==========================================
|
|
|
|
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.
|
|
|
|
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
|
|
==============================
|
|
|
|
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 readme.md,
|
|
section "GNU make", please add the "install" target to that line and use every
|
|
argument as it is in the documentation of the tool, so that every Xen developer
|
|
following this page can reproduce the same findings.
|
|
|
|
This will compile and install cppcheck in /usr/bin and all the cppcheck config
|
|
files and addons will be installed in /usr/share/cppcheck folder, please modify
|
|
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 just
|
|
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 local
|
|
installation of cppcheck for the Xen analysis.
|
|
|
|
Dependencies are listed in the readme.md of the project repository.
|
|
|
|
Use cppcheck to analyse Xen
|
|
===========================
|
|
|
|
To analyse Xen using cppcheck, please refer to the document
|
|
xen-static-analysis.rst, section "Analyse Xen with Cppcheck".
|
|
|
|
[1] https://sourceforge.net/p/cppcheck/discussion/general/thread/bfc3ab6c41/?limit=25
|