Gert Doering has submitted this change. ( 
https://gerrit.openvpn.net/c/openvpn/+/2107?usp=email )

Change subject: Provide minimal netlink defines for cppcheck on FreeBSD and 
macOS
......................................................................

Provide minimal netlink defines for cppcheck on FreeBSD and macOS

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 <[email protected]>
Acked-by: Frank Lichtenheld <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2107
Message-Id: <[email protected]>
URL: 
https://www.mail-archive.com/[email protected]/msg40579.html
Signed-off-by: Gert Doering <[email protected]>
---
A dev-tools/openvpn-cppcheck-netlink.cfg
M dev-tools/run-cppcheck.sh
2 files changed, 10 insertions(+), 0 deletions(-)




diff --git a/dev-tools/openvpn-cppcheck-netlink.cfg 
b/dev-tools/openvpn-cppcheck-netlink.cfg
new file mode 100644
index 0000000..b63adf0
--- /dev/null
+++ b/dev-tools/openvpn-cppcheck-netlink.cfg
@@ -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>
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index d1c22c5..debcd46 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -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} \

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2107?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I36430bab897e5fe9b1cfd48de50224395d56d8fc
Gerrit-Change-Number: 2107
Gerrit-PatchSet: 2
Gerrit-Owner: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Frank Lichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to