[Openvpn-devel,v2] sample: Fix cppcheck error invalidPrintfArgType_sint

Message ID 20260507075502.25473-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v2] sample: Fix cppcheck error invalidPrintfArgType_sint | expand

Commit Message

Gert Doering May 7, 2026, 7:54 a.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

Change-Id: Ia7ad24181bd97dccbb77865c10e829778f72a506
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1662
---

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

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering May 7, 2026, 8:48 a.m. UTC | #1
Good find... the variables printed are defined in "openvpn-plugin.h"
as "unsigned int", so we should print them as such :-) - not that it
would make any difference (and "unsigned int" really leaves room for
many many openvpn versions).  So treating as cleanup, not bugfix.

Your patch has been applied to the master branch.

commit 74d39dfba2aa8d94110467788dfb9160fc739fad
Author: Frank Lichtenheld
Date:   Thu May 7 09:54:56 2026 +0200

     sample: Fix cppcheck error invalidPrintfArgType_sint

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1662
     Message-Id: <20260507075502.25473-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36844.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/sample/sample-plugins/log/log_v3.c b/sample/sample-plugins/log/log_v3.c
index deae590..d2d44c7 100644
--- a/sample/sample-plugins/log/log_v3.c
+++ b/sample/sample-plugins/log/log_v3.c
@@ -91,7 +91,7 @@ 
     }
 
     /* Print some version information about the OpenVPN process using this plug-in */
-    printf("log_v3: OpenVPN %s  (Major: %i, Minor: %i, Patch: %s)\n", args->ovpn_version,
+    printf("log_v3: OpenVPN %s  (Major: %u, Minor: %u, Patch: %s)\n", args->ovpn_version,
            args->ovpn_version_major, args->ovpn_version_minor, args->ovpn_version_patch);
 
     /*  Which callbacks to intercept.  */
diff --git a/sample/sample-plugins/simple/base64.c b/sample/sample-plugins/simple/base64.c
index ab6aed8..3b11543 100644
--- a/sample/sample-plugins/simple/base64.c
+++ b/sample/sample-plugins/simple/base64.c
@@ -122,7 +122,7 @@ 
     ovpn_base64_decode = args->callbacks->plugin_base64_decode;
 
     /* Print some version information about the OpenVPN process using this plug-in */
-    ovpn_log(PLOG_NOTE, PLUGIN_NAME, "OpenVPN %s  (Major: %i, Minor: %i, Patch: %s)\n",
+    ovpn_log(PLOG_NOTE, PLUGIN_NAME, "OpenVPN %s  (Major: %u, Minor: %u, Patch: %s)\n",
              args->ovpn_version, args->ovpn_version_major, args->ovpn_version_minor,
              args->ovpn_version_patch);