mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/misra: xen-analysis.py: Improve the cppcheck version check
Use tuple comparison to check the cppcheck version. Take the occasion to harden the regex, escaping the dots so that we check for them instead of generic characters. Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com> Acked-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
1 parent
cca2361947
commit
56c0063f4e
1 file changed
+4
-9
@@ -157,7 +157,7 @@ def generate_cppcheck_deps():
|
|||||||
"Error occured retrieving cppcheck version:\n{}\n\n{}"
|
"Error occured retrieving cppcheck version:\n{}\n\n{}"
|
||||||
)
|
)
|
||||||
|
|
||||||
version_regex = re.search('^Cppcheck (\d+).(\d+)(?:.\d+)?$',
|
version_regex = re.search('^Cppcheck (\d+)\.(\d+)(?:\.\d+)?$',
|
||||||
invoke_cppcheck, flags=re.M)
|
invoke_cppcheck, flags=re.M)
|
||||||
# Currently, only cppcheck version >= 2.7 is supported, but version 2.8 is
|
# Currently, only cppcheck version >= 2.7 is supported, but version 2.8 is
|
||||||
# known to be broken, please refer to docs/misra/cppcheck.txt
|
# known to be broken, please refer to docs/misra/cppcheck.txt
|
||||||
@@ -166,15 +166,10 @@ def generate_cppcheck_deps():
|
|||||||
"Can't find cppcheck version or version not identified: "
|
"Can't find cppcheck version or version not identified: "
|
||||||
"{}".format(invoke_cppcheck)
|
"{}".format(invoke_cppcheck)
|
||||||
)
|
)
|
||||||
major = int(version_regex.group(1))
|
version = (int(version_regex.group(1)), int(version_regex.group(2)))
|
||||||
minor = int(version_regex.group(2))
|
if version < (2, 7) or version == (2, 8):
|
||||||
if major < 2 or (major == 2 and minor < 7):
|
|
||||||
raise CppcheckDepsPhaseError(
|
raise CppcheckDepsPhaseError(
|
||||||
"Cppcheck version < 2.7 is not supported"
|
"Cppcheck version < 2.7 or 2.8 are 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
|
# If misra option is selected, append misra addon and generate cppcheck
|
||||||
|
|||||||