[Openvpn-devel,v1] cppcheck: Add more printf-style functions

Message ID 20261125151936.10270-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] cppcheck: Add more printf-style functions |

Commit Message

Gert Doering Nov. 25, 2026, 3:19 p.m. UTC
  From: Frank Lichtenheld <frank@lichtenheld.com>

Also fix the two issues raised by this.

Change-Id: I8d081c87af0d746a5e3a2382567f04332639622a
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2343
---

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

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
  

Patch

diff --git a/dev-tools/openvpn-cppcheck-library.cfg b/dev-tools/openvpn-cppcheck-library.cfg
index 0537b39..37195d8 100644
--- a/dev-tools/openvpn-cppcheck-library.cfg
+++ b/dev-tools/openvpn-cppcheck-library.cfg
@@ -6,6 +6,12 @@ 
       <formatstr />
     </arg>
   </function>
+  <function name="argv_printf">
+    <formatstr type="printf"/>
+    <arg nr="2">
+      <formatstr />
+    </arg>
+  </function>
   <function name="buf_printf">
     <formatstr type="printf"/>
     <arg nr="2">
diff --git a/dev-tools/openvpn-cppcheck-windows.cfg b/dev-tools/openvpn-cppcheck-windows.cfg
index 932d586..dca2b07 100644
--- a/dev-tools/openvpn-cppcheck-windows.cfg
+++ b/dev-tools/openvpn-cppcheck-windows.cfg
@@ -2,6 +2,12 @@ 
 <!-- Only used for the Windows run. Can't be in openvpn-cppcheck-library.cfg
      because it conflicts with gnu.cfg. -->
 <def>
+  <function name="MsgToEventLog">
+    <formatstr type="printf"/>
+    <arg nr="2">
+      <formatstr />
+    </arg>
+  </function>
   <!-- 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. -->
diff --git a/src/openvpn/networking_iproute2.c b/src/openvpn/networking_iproute2.c
index 6c4c8f4..b079757 100644
--- a/src/openvpn/networking_iproute2.c
+++ b/src/openvpn/networking_iproute2.c
@@ -112,7 +112,7 @@ 
 {
     struct argv argv = argv_new();
 
-    argv_printf(&argv, "%s link set dev %s up mtu %d", iproute_path, iface, mtu);
+    argv_printf(&argv, "%s link set dev %s up mtu %u", iproute_path, iface, mtu);
     argv_msg(M_INFO, &argv);
     openvpn_execve_check(&argv, ctx->es, S_FATAL, "Linux ip link set failed");
 
diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index be57d43..ad0fda2 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -466,7 +466,7 @@ 
     size = bytes / sizeof(*data);
     if ((size == 0) || (size > 4096)) /* our startup data is 1024 wchars at the moment */
     {
-        MsgToEventLog(M_SYSERR, L"malformed startup data: %lu bytes received", size);
+        MsgToEventLog(M_SYSERR, L"malformed startup data: %zu bytes received", size);
         ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);
         goto err;
     }