[Openvpn-devel,v1] Provide minimal netlink defines for cppcheck on FreeBSD and macOS
Commit Message
From: Arne Schwabe <arne@rfc2549.org>
Without these defines and the hidden goto inside the NLA_PUT functions
cppcheck complains about ret in dco_linux.c. This allows to run
cppcheck on macOS and FreeBSD without triggering these warnings.
Change-Id: I36430bab897e5fe9b1cfd48de50224395d56d8fc
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2107
---
This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2107
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
new file mode 100644
@@ -0,0 +1,7 @@
+<?xml version ="1.0"?>
+<def>
+ <!-- minimal defines to supress the errors on non-Linux platforms that do not have the netlink headers -->
+ <define name="NLA_PUT(msg, attrtype, attrlen, data)" value="if (nla_cppcheck_dummy(msg, attrtype, attrlen, data) < 0) goto nla_put_failure;" />
+ <define name="NLA_PUT_U32(msg, attrtype, value)" value="NLA_PUT(msg, uint32_t, attrtype, value)" />
+ <define name="NLA_PUT_STRING(msg, attrtype, value)" value="NLA_PUT(msg, attrtype, (int) strlen(value) + 1, value)" />
+</def>
@@ -20,9 +20,11 @@
if [ $(uname) = "Darwin" ] || [ $(uname) = "FreeBSD" ]; then
SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
num_procs=$(sysctl -n hw.ncpu)
+ EXTRA_LIBRARY="--library=${SCRIPT_DIR}/openvpn-cppcheck-netlink.cfg"
else
SCRIPT_DIR=$(dirname $(readlink -e "${BASH_SOURCE[0]}"))
num_procs=$(nproc)
+ EXTRA_LIBRARY=""
fi
: ${SOURCE_DIR:=$SCRIPT_DIR/..}
: ${BUILD_DIR:=$PWD}
@@ -35,6 +37,7 @@
-I${BUILD_DIR} -I${BUILD_DIR}/include/ \
--enable=all ${disable_arg} \
--library=${SCRIPT_DIR}/openvpn-cppcheck-library.cfg \
+ ${EXTRA_LIBRARY} \
--library=openssl.cfg \
--suppress-xml=${SCRIPT_DIR}/cppcheck-suppressions.xml --inline-suppr \
--cppcheck-build-dir=${CPPCHECK_DIR} \