From: Frank Lichtenheld <[email protected]>

Since we do not force __GNUC__ to undefined on Windows
(since we want to support MinGW) cppcheck might stumble
upon __builtin_expect(). When running with gnu.cfg (which
we do not want to do for Windows code) then that has an
existing override. But for our Windows checks we need to
add our own override.

This caused false-positives in buffer code.

Change-Id: I3b835558451414d8a4e8058114643555be69d391
Signed-off-by: Frank Lichtenheld <[email protected]>
Acked-by: Arne Schwabe <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1957
---

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/+/1957
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]>

        
diff --git a/dev-tools/openvpn-cppcheck-windows.cfg 
b/dev-tools/openvpn-cppcheck-windows.cfg
new file mode 100644
index 0000000..9ac7282
--- /dev/null
+++ b/dev-tools/openvpn-cppcheck-windows.cfg
@@ -0,0 +1,10 @@
+<?xml version ="1.0"?>
+<!-- Only used for the Windows run. Can't be in openvpn-cppcheck-library.cfg
+     because it conflicts with gnu.cfg. -->
+<def>
+  <!-- MinGW uses GCC, so we need to handle GCC builtins. gnu.cfg has these,
+       but we do not load it for Windows. Without this cppcheck does not
+       understand our likely()/unlikely() macros. -->
+  <define name="__builtin_expect(X,Y)" value="(X)" />
+  <define name="__builtin_expect_with_probability(exp,c,probability)" 
value="(exp)" />
+</def>
diff --git a/dev-tools/run-cppcheck.sh b/dev-tools/run-cppcheck.sh
index 6b2c2be..3c71c83 100755
--- a/dev-tools/run-cppcheck.sh
+++ b/dev-tools/run-cppcheck.sh
@@ -49,7 +49,7 @@
     tests/unit_tests/plugins/ || ret=$?
 cppcheck $COMMON_ARGS \
     --platform=win64 \
-    --library=windows.cfg \
+    --library=windows.cfg --library=${SCRIPT_DIR}/openvpn-cppcheck-windows.cfg 
\
     -D_WIN32 \
     -UTARGET_LINUX -UTARGET_FREEBSD -UTARGET_OPENBSD -UTARGET_NETBSD \
     -UTARGET_DARWIN -UTARGET_ANDROID -UTARGET_SOLARIS -UTARGET_DRAGONFLY \


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to