mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
cppcheck: rework exclusion_file_list.py code
Rework the exclusion_file_list.py code to have the function load_exclusion_file_list() detached from the xen-analysis.py tool, in a way so that other modules can use the function. The xen-analysis tool and in particular its module cppcheck_analysis.py will use a new function cppcheck_exclusion_file_list(). No functional changes are intended. Signed-off-by: Luca Fancellu <luca.fancellu@arm.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
1 parent
f3795523dc
commit
d82a8217d5
2 files changed
+19
-18
No files matched your search
@@ -2,7 +2,8 @@
|
||||
|
||||
import os, re, shutil
|
||||
from . import settings, utils, cppcheck_report_utils, exclusion_file_list
|
||||
from .exclusion_file_list import ExclusionFileListError
|
||||
from .exclusion_file_list import (ExclusionFileListError,
|
||||
cppcheck_exclusion_file_list)
|
||||
|
||||
class GetMakeVarsPhaseError(Exception):
|
||||
pass
|
||||
@@ -54,8 +55,7 @@ def __generate_suppression_list(out_file):
|
||||
try:
|
||||
exclusion_file = \
|
||||
"{}/docs/misra/exclude-list.json".format(settings.repo_dir)
|
||||
exclusion_list = \
|
||||
exclusion_file_list.load_exclusion_file_list(exclusion_file)
|
||||
exclusion_list = cppcheck_exclusion_file_list(exclusion_file)
|
||||
except ExclusionFileListError as e:
|
||||
raise CppcheckDepsPhaseError(
|
||||
"Issue with reading file {}: {}".format(exclusion_file, e)
|
||||
|
||||
@@ -7,16 +7,24 @@ class ExclusionFileListError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def __cppcheck_path_exclude_syntax(path):
|
||||
# Prepending * to the relative path to match every path where the Xen
|
||||
# codebase could be
|
||||
path = "*" + path
|
||||
def cppcheck_exclusion_file_list(input_file):
|
||||
ret = []
|
||||
excl_list = load_exclusion_file_list(input_file)
|
||||
|
||||
return path
|
||||
for entry in excl_list:
|
||||
# Prepending * to the relative path to match every path where the Xen
|
||||
# codebase could be
|
||||
ret.append("*" + entry[0])
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
# Reads the exclusion file list and returns a list of relative path to be
|
||||
# excluded.
|
||||
# Reads the exclusion file list and returns an array containing a set where the
|
||||
# first entry is what was listed in the exclusion list file, and the second
|
||||
# entry is the absolute path of the first entry.
|
||||
# If the first entry contained a wildcard '*', the second entry will have an
|
||||
# array of the solved absolute path for that entry.
|
||||
# Returns [('path',[path,path,...]), ('path',[path,path,...]), ...]
|
||||
def load_exclusion_file_list(input_file):
|
||||
ret = []
|
||||
try:
|
||||
@@ -58,13 +66,6 @@ def load_exclusion_file_list(input_file):
|
||||
.format(path, filepath_object)
|
||||
)
|
||||
|
||||
if settings.analysis_tool == "cppcheck":
|
||||
path = __cppcheck_path_exclude_syntax(path)
|
||||
else:
|
||||
raise ExclusionFileListError(
|
||||
"Unimplemented for {}!".format(settings.analysis_tool)
|
||||
)
|
||||
|
||||
ret.append(path)
|
||||
ret.append((path, check_path))
|
||||
|
||||
return ret
|
||||