A recent cppcheck run was found to fail:
https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/8237167472
with:
"type mismatch! call is<type>() before get<type>()" && is<std::string>()
make[3]: *** [arch/x86/boot/Makefile:28: arch/x86/boot/reloc-trampoline.32.o]
Error 1
This turns out to be a parallel build issue, combined with a recent change to
x86. Notably, we now have a case where we build both:
CC arch/x86/boot/reloc-trampoline.32.o
CC arch/x86/boot/reloc-trampoline.o
from the same original C file, and cppcheck uses the source C file as the key
for generating it's intermediate files.
Switch cppcheck to use the object file as the unique key instead.
Fixes: 45bfff651173 ("xen/misra: xen-analysis.py: fix parallel analysis
Cppcheck errors")
Fixes: db8acf31f96b ("x86/boot: Reuse code to relocate trampoline")
Suggested-by: Luca Fancellu <[email protected]>
Signed-off-by: Andrew Cooper <[email protected]>
---
CC: Luca Fancellu <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1522120661
which seems to suggest that cppcheck is still happy.
---
xen/tools/cppcheck-cc.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/xen/tools/cppcheck-cc.sh b/xen/tools/cppcheck-cc.sh
index 16a965edb7ec..8a58c3aa86b3 100755
--- a/xen/tools/cppcheck-cc.sh
+++ b/xen/tools/cppcheck-cc.sh
@@ -26,6 +26,7 @@ EOF
BUILD_DIR=""
CC_FILE=""
+OBJ_FILE=""
COMPILER=""
CPPCHECK_HTML="n"
CPPCHECK_PLAT_PATH=""
@@ -56,6 +57,7 @@ do
then
# This must be the path to the obj file, turn off flag and save
path
OBJTREE_PATH="$(dirname "${OPTION}")"
+ OBJ_FILE="$(basename "${OPTION}")"
obj_arg_content="n"
fi
# Forward any argument to the compiler
@@ -177,12 +179,12 @@ then
done
if [ "${IGNORE_PATH}" = "n" ]
then
- JDB_FILE="${OBJTREE_PATH}/$(basename "${CC_FILE}".json)"
+ JDB_FILE="${OBJTREE_PATH}/${OBJ_FILE}.json"
# Prepare the Json Compilation Database for the file
create_jcd "${COMPILER} ${FORWARD_FLAGS}"
- out_file="${OBJTREE_PATH}/$(basename "${CC_FILE%.c}".cppcheck.txt)"
+ out_file="${OBJTREE_PATH}/${OBJ_FILE}.cppcheck.txt"
# Select the right target platform, ARCH is generated from Xen Makefile
case ${ARCH} in
@@ -211,7 +213,7 @@ then
fi
# Generate build directory for the analysed file
- cppcheck_build_dir="${BUILD_DIR}/${OBJTREE_PATH}"
+ cppcheck_build_dir="${BUILD_DIR}/${OBJTREE_PATH}/${OBJ_FILE}"
mkdir -p "${cppcheck_build_dir}"
# Shellcheck complains about missing quotes on CPPCHECK_TOOL_ARGS, but
base-commit: 2478bed83fc6d8be1d129d9a9617eda2ab3c9790
--
2.39.5