[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/misra: xen-analysis.py: allow cppcheck version above 2.7



commit 069cb96fbd7595c80bf2af6a06454ce5c732721e
Author:     Luca Fancellu <luca.fancellu@xxxxxxx>
AuthorDate: Thu May 4 14:12:44 2023 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xxxxxxx>
CommitDate: Wed May 17 16:13:05 2023 -0700

    xen/misra: xen-analysis.py: allow cppcheck version above 2.7
    
    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 <luca.fancellu@xxxxxxx>
    Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    Tested-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 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 658795bb9f..c3783e8df3 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
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.