mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
xen/misra: xen-analysis.py: fix parallel analysis Cppcheck errors
Currently Cppcheck has a limitation that prevents to use make with
parallel build and have a parallel Cppcheck invocation on each
translation unit (the .c files), because of spurious internal errors.
The issue comes from the fact that when using the build directory,
Cppcheck saves temporary files as <filename>.c.<many-extensions>, but
this doesn't work well when files with the same name are being
analysed at the same time, leading to race conditions.
Fix the issue creating, under the build directory, the same directory
structure of the file being analysed to avoid any clash.
Fixes: 02b26c02c7 ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
1 parent
42abf5b9c5
commit
45bfff6511
2 files changed
+21
-6
No files matched your search
@@ -139,7 +139,6 @@ def generate_cppcheck_deps():
|
||||
# Compiler defines are in compiler-def.h which is included in config.h
|
||||
#
|
||||
cppcheck_flags="""
|
||||
--cppcheck-build-dir={}/{}
|
||||
--max-ctu-depth=10
|
||||
--enable=style,information,missingInclude
|
||||
--template=\'{{file}}({{line}},{{column}}):{{id}}:{{severity}}:{{message}}\'
|
||||
@@ -150,8 +149,7 @@ def generate_cppcheck_deps():
|
||||
--suppress='unusedStructMember:*'
|
||||
--include={}/include/xen/config.h
|
||||
-DCPPCHECK
|
||||
""".format(settings.outdir, CPPCHECK_BUILD_DIR, settings.xen_dir,
|
||||
settings.outdir, settings.xen_dir)
|
||||
""".format(settings.xen_dir, settings.outdir, settings.xen_dir)
|
||||
|
||||
invoke_cppcheck = utils.invoke_command(
|
||||
"{} --version".format(settings.cppcheck_binpath),
|
||||
@@ -204,9 +202,9 @@ def generate_cppcheck_deps():
|
||||
|
||||
cppcheck_cc_flags = """--compiler={} --cppcheck-cmd={} {}
|
||||
--cppcheck-plat={}/cppcheck-plat --ignore-path=tools/
|
||||
--ignore-path=arch/x86/efi/check.c
|
||||
--ignore-path=arch/x86/efi/check.c --build-dir={}/{}
|
||||
""".format(xen_cc, settings.cppcheck_binpath, cppcheck_flags,
|
||||
settings.tools_dir)
|
||||
settings.tools_dir, settings.outdir, CPPCHECK_BUILD_DIR)
|
||||
|
||||
if settings.cppcheck_html:
|
||||
cppcheck_cc_flags = cppcheck_cc_flags + " --cppcheck-html"
|
||||
|
||||
@@ -24,6 +24,7 @@ Options:
|
||||
EOF
|
||||
}
|
||||
|
||||
BUILD_DIR=""
|
||||
CC_FILE=""
|
||||
COMPILER=""
|
||||
CPPCHECK_HTML="n"
|
||||
@@ -66,6 +67,10 @@ do
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
--build-dir=*)
|
||||
BUILD_DIR="${OPTION#*=}"
|
||||
sm_tool_args="n"
|
||||
;;
|
||||
--compiler=*)
|
||||
COMPILER="${OPTION#*=}"
|
||||
sm_tool_args="n"
|
||||
@@ -107,6 +112,12 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${BUILD_DIR}" = "" ]
|
||||
then
|
||||
echo "--build-dir arg is mandatory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function create_jcd() {
|
||||
local line="${1}"
|
||||
local arg_num=0
|
||||
@@ -199,13 +210,18 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate build directory for the analysed file
|
||||
cppcheck_build_dir="${BUILD_DIR}/${OBJTREE_PATH}"
|
||||
mkdir -p "${cppcheck_build_dir}"
|
||||
|
||||
# Shellcheck complains about missing quotes on CPPCHECK_TOOL_ARGS, but
|
||||
# they can't be used here
|
||||
# shellcheck disable=SC2086
|
||||
${CPPCHECK_TOOL} ${CPPCHECK_TOOL_ARGS} \
|
||||
--project="${JDB_FILE}" \
|
||||
--output-file="${out_file}" \
|
||||
--platform="${platform}"
|
||||
--platform="${platform}" \
|
||||
--cppcheck-build-dir=${cppcheck_build_dir}
|
||||
|
||||
if [ "${CPPCHECK_HTML}" = "y" ]
|
||||
then
|
||||
@@ -216,6 +232,7 @@ then
|
||||
--project="${JDB_FILE}" \
|
||||
--output-file="${out_file%.txt}.xml" \
|
||||
--platform="${platform}" \
|
||||
--cppcheck-build-dir=${cppcheck_build_dir} \
|
||||
-q \
|
||||
--xml
|
||||
fi
|
||||
|
||||