mirror of
https://github.com/OpenVPN/openvpn.git
synced 2026-06-24 08:50:27 -04:00
Massively improve how we call cppcheck to cover more code and identify more issues. When specifying any -D argument all other defines are ignored unless --force or --max-configs is specified as well. I mistakenly assumed that this was covered by --check-level=exhaustive. We need to try finding a value for --max-configs so that cppcheck doesn't spend hours scanning options.c Add a library cfg for our code which for now - identifies some printf-style functions - adds some common macro defines Use existing libraries. Add a second call to cppcheck to separate the Windows and Unixy code scans. This avoids some very non-sensical define combinations. Change-Id: I05720ccc3bcf706bbe62254afb74562580f5de56 Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1665 Message-Id: <20260607170713.4980-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg37078.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
43 lines
1.4 KiB
Bash
Executable file
43 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
SCRIPT_DIR=$(dirname $(readlink -e "${BASH_SOURCE[0]}"))
|
|
: ${SOURCE_DIR:=$SCRIPT_DIR/..}
|
|
: ${BUILD_DIR:=$PWD}
|
|
: ${INCLUDE_FLAGS:=}
|
|
CPPCHECK_DIR="${BUILD_DIR}/cppcheck_build_dir"
|
|
COMMON_ARGS="-j$(nproc) -q \
|
|
-DMBEDTLS_SSL_PROTO_TLS1_3 -DMBEDTLS_SSL_KEYING_MATERIAL_EXPORT \
|
|
-I./include/ -I./tests/unit_tests/openvpn/ \
|
|
-I./src/compat/ -I./src/openvpn/ -I./src/openvpnserv/ -I./src/plugins/auth-pam/ \
|
|
-I${BUILD_DIR} -I${BUILD_DIR}/include/ \
|
|
--enable=all \
|
|
--library=${SCRIPT_DIR}/openvpn-cppcheck-library.cfg \
|
|
--library=openssl.cfg \
|
|
--suppressions-list=${SCRIPT_DIR}/cppcheck-suppression \
|
|
--cppcheck-build-dir=${CPPCHECK_DIR} \
|
|
--check-level=exhaustive --max-configs=10 \
|
|
--error-exitcode=1"
|
|
|
|
|
|
set -x
|
|
|
|
mkdir -p "$CPPCHECK_DIR"
|
|
cd "${SOURCE_DIR}"
|
|
cppcheck $COMMON_ARGS $INCLUDE_FLAGS \
|
|
--platform=unix64 \
|
|
--library=posix.cfg --library=bsd.cfg --library=gnu.cfg \
|
|
-U_WIN32 \
|
|
src/openvpn/ src/compat/ src/plugins/ sample/ \
|
|
tests/unit_tests/example_test/ tests/unit_tests/openvpn/ \
|
|
tests/unit_tests/plugins/
|
|
cppcheck $COMMON_ARGS \
|
|
--platform=win64 \
|
|
--library=windows.cfg \
|
|
-D_WIN32 \
|
|
-UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
|
|
-UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \
|
|
-UTARGET_AIX \
|
|
src/openvpn* src/compat/ \
|
|
tests/unit_tests/example_test/ tests/unit_tests/openvpn*
|