mirror of https://github.com/neutrinolabs/xrdp
Allow a cppcheck check_level to be specified
Version 2.14.0 of cppcheck generates errors relating to the
check level (e.g.):-
common/base64.c:0:0: information: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches. [normalCheckLevelMaxBranches]
This does not happen with the same sources (commit
f781962a55
) under 2.13.0.
This PR disables the warnings above for 2.14.0, but also allows a '-f'
argument to be passed in to request an exhaustive test. This could be used
(for example) before a major release. An exhaustive test takes a *lot*
longer. The first run with a git runner was around an hour.
The --check-level=flag was only added for 2.11.0, and so this now needs
a version check.
This commit is contained in:
parent
eab3cbb1d5
commit
82c95faaa9
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
# Script to run cppcheck
|
# Script to run cppcheck
|
||||||
#
|
#
|
||||||
# Usage: /path/to/run_cppcheck.sh [ -v CPPCHECK_VER] [<extra_opts_and_dirs>]
|
# Usage: /path/to/run_cppcheck.sh [-f] [ -v CPPCHECK_VER] [<extra_opts_and_dirs>]
|
||||||
#
|
#
|
||||||
# - If <extra_opts_and_dirs> is missing, '.' is assumed
|
# - If <extra_opts_and_dirs> is missing, '.' is assumed
|
||||||
|
# - If '-f' is specified, the exhaustive check level is used. This can take
|
||||||
|
# an hour or two.
|
||||||
# - If -v CPPCHECK_VER is specified, that version of cppcheck is run from
|
# - If -v CPPCHECK_VER is specified, that version of cppcheck is run from
|
||||||
# ~/cppcheck.local (whether or not it's there!). Use install_cppcheck.sh
|
# ~/cppcheck.local (whether or not it's there!). Use install_cppcheck.sh
|
||||||
# to install a new version.
|
# to install a new version.
|
||||||
|
@ -14,11 +16,50 @@
|
||||||
# CPPCHECK : Override the default cppcheck command ('cppcheck').
|
# CPPCHECK : Override the default cppcheck command ('cppcheck').
|
||||||
# Ignored if -v is specified
|
# Ignored if -v is specified
|
||||||
# CPPCHECK_FLAGS : Override the default cppcheck flags
|
# CPPCHECK_FLAGS : Override the default cppcheck flags
|
||||||
|
# CPPCHECK_QUICK : If non-zero, disables the exhaustive check level.
|
||||||
|
# Useful when developing
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# C P P C H E C K V E R S I O N S T R
|
||||||
|
#
|
||||||
|
# Get the cppcheck version, and then convert to AABBCC for comparisons
|
||||||
|
# where AA is the major version, BB is the minor version and CC is the
|
||||||
|
# revision
|
||||||
|
# For example, cppcheck version 2.13.0 produces 021300
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
CppcheckVerCompareStr()
|
||||||
|
{
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
set -- $($CPPCHECK --version 2>/dev/null)
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
[0123456789]*) break;;
|
||||||
|
*) shift
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo 000000 ; # Something has gone wrong
|
||||||
|
else
|
||||||
|
case "$1" in
|
||||||
|
*.*.*) echo "$1" | awk -F. '{printf "%02d%02d%02d",$1,$2,$3 }' ;;
|
||||||
|
*.*) echo "$1" | awk -F. '{printf "%02d%02d00",$1,$2 }' ;;
|
||||||
|
*) printf '%02d0000\n' "$1"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
INSTALL_ROOT=~/cppcheck.local
|
INSTALL_ROOT=~/cppcheck.local
|
||||||
|
|
||||||
# Figure out CPPCHECK setting, if any. Currently '-v' must be the first
|
# Exhaustive test?
|
||||||
# argument on the command line.
|
if [ "$1" = "-f" ]; then
|
||||||
|
check_level=exhaustive
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
check_level=normal
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Figure out CPPCHECK setting, if any.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-v) # Version is separate parameter
|
-v) # Version is separate parameter
|
||||||
if [ $# -ge 2 ]; then
|
if [ $# -ge 2 ]; then
|
||||||
|
@ -45,15 +86,30 @@ if [ -z "$CPPCHECK_FLAGS" ]; then
|
||||||
CPPCHECK_FLAGS="--quiet --force --std=c11 --std=c++11 --inline-suppr \
|
CPPCHECK_FLAGS="--quiet --force --std=c11 --std=c++11 --inline-suppr \
|
||||||
--enable=warning --error-exitcode=1 -i third_party \
|
--enable=warning --error-exitcode=1 -i third_party \
|
||||||
--suppress=uninitMemberVar:ulalaca/ulalaca.cpp \
|
--suppress=uninitMemberVar:ulalaca/ulalaca.cpp \
|
||||||
--suppress=shiftTooManyBits:libxrdp/xrdp_mppc_enc.c \
|
--suppress=shiftTooManyBits:libxrdp/xrdp_mppc_enc.c"
|
||||||
-I . -I common"
|
|
||||||
|
# Check for flags added in later versions
|
||||||
|
CPPCHECK_COMPARE_VERSION=$(CppcheckVerCompareStr)
|
||||||
|
if [ "$CPPCHECK_COMPARE_VERSION" -ge 021100 ]; then
|
||||||
|
if [ "$check_level" = "normal" ]; then
|
||||||
|
# Disable warnings related to the check level
|
||||||
|
CPPCHECK_FLAGS="$CPPCHECK_FLAGS \
|
||||||
|
--suppress=normalCheckLevelMaxBranches"
|
||||||
|
fi
|
||||||
|
CPPCHECK_FLAGS="$CPPCHECK_FLAGS --check-level=$check_level"
|
||||||
|
else
|
||||||
|
# This is echoed later
|
||||||
|
check_level="Default (option not supported)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CPPCHECK_FLAGS="$CPPCHECK_FLAGS -I . -I common"
|
||||||
fi
|
fi
|
||||||
CPPCHECK_FLAGS="$CPPCHECK_FLAGS -D__cppcheck__"
|
CPPCHECK_FLAGS="$CPPCHECK_FLAGS -D__cppcheck__"
|
||||||
|
|
||||||
# Any options/directories specified?
|
# Any options/directories specified?
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
if [ -f /proc/cpuinfo ]; then
|
if [ -f /proc/cpuinfo ]; then
|
||||||
cpus=$(grep '^processor' /proc/cpuinfo | wc -l)
|
cpus=$(grep -c '^processor' /proc/cpuinfo)
|
||||||
else
|
else
|
||||||
cpus=2
|
cpus=2
|
||||||
fi
|
fi
|
||||||
|
@ -63,5 +119,8 @@ fi
|
||||||
# Display the cppcheck version and command for debugging
|
# Display the cppcheck version and command for debugging
|
||||||
"$CPPCHECK" --version && {
|
"$CPPCHECK" --version && {
|
||||||
echo "Command: $CPPCHECK $CPPCHECK_FLAGS" "$@"
|
echo "Command: $CPPCHECK $CPPCHECK_FLAGS" "$@"
|
||||||
|
echo "Check level: $check_level"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
"$CPPCHECK" $CPPCHECK_FLAGS "$@"
|
"$CPPCHECK" $CPPCHECK_FLAGS "$@"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue