Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1960?usp=email
to review the following change.
Change subject: Fix all occurrences of cppcheck invalidPrintfArgType_uint
......................................................................
Fix all occurrences of cppcheck invalidPrintfArgType_uint
Mostly trivially correct. There are some exceptions, though:
- cppcheck treats all numerical literals as "signed" even
though the compilers would probably be more intelligent.
Chose different work-arounds for different occurrences.
- Needed to override PRIx64 again for Windows, since there
it needs to be "llx", not "lx".
Change-Id: I7f910599f0f4005f06a88a93b40417ffa37022a8
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M dev-tools/cppcheck-suppressions.xml
M dev-tools/openvpn-cppcheck-windows.cfg
M src/openvpn/dco_win.c
M src/openvpn/dns.h
M src/openvpn/forward.c
M src/openvpn/init.c
M src/openvpn/options.c
M src/openvpn/platform.c
M src/openvpn/push.c
M src/openvpn/route.c
M src/openvpn/ssl.c
M src/openvpn/tun.c
M src/openvpn/tun.h
M src/openvpnmsica/msica_arg.c
M src/openvpnmsica/msiex.c
M src/openvpnmsica/openvpnmsica.c
M src/openvpnserv/interactive.c
17 files changed, 36 insertions(+), 36 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/1960/1
diff --git a/dev-tools/cppcheck-suppressions.xml
b/dev-tools/cppcheck-suppressions.xml
index 12521e1..38de5f2a 100644
--- a/dev-tools/cppcheck-suppressions.xml
+++ b/dev-tools/cppcheck-suppressions.xml
@@ -9,9 +9,6 @@
<id>constParameterCallback</id>
</suppress>
<suppress>
- <id>invalidPrintfArgType_uint</id>
- </suppress>
- <suppress>
<id>unusedFunction</id>
</suppress>
<suppress>
diff --git a/dev-tools/openvpn-cppcheck-windows.cfg
b/dev-tools/openvpn-cppcheck-windows.cfg
index 9ac7282..932d586 100644
--- a/dev-tools/openvpn-cppcheck-windows.cfg
+++ b/dev-tools/openvpn-cppcheck-windows.cfg
@@ -7,4 +7,7 @@
understand our likely()/unlikely() macros. -->
<define name="__builtin_expect(X,Y)" value="(X)" />
<define name="__builtin_expect_with_probability(exp,c,probability)"
value="(exp)" />
+ <!-- cppcheck understands it directly in format string, but not
+ indirectly when the format string is constructed earlier -->
+ <define name="PRIx64" value=""llx"" />
</def>
diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c
index c01a4e5..7abd06b 100644
--- a/src/openvpn/dco_win.c
+++ b/src/openvpn/dco_win.c
@@ -835,7 +835,7 @@
struct multi_instance *mi = dco->c->multi->instances[stat->PeerId];
if (!mi)
{
- msg(M_WARN, "%s: received data for a non-existing peer %u",
__func__, stat->PeerId);
+ msg(M_WARN, "%s: received data for a non-existing peer %d",
__func__, stat->PeerId);
continue;
}
diff --git a/src/openvpn/dns.h b/src/openvpn/dns.h
index 51bc2de..2c20b0e 100644
--- a/src/openvpn/dns.h
+++ b/src/openvpn/dns.h
@@ -89,7 +89,7 @@
};
#ifndef N_DHCP_ADDR
-#define N_DHCP_ADDR 4
+#define N_DHCP_ADDR 4u
#endif
#ifndef N_SEARCH_LIST_LEN
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c
index 146c498..204b0b7 100644
--- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -1288,7 +1288,7 @@
break;
default:
- msg(D_DCO_DEBUG, "%s: received message of type %u - ignoring",
__func__,
+ msg(D_DCO_DEBUG, "%s: received message of type %d - ignoring",
__func__,
dco->dco_message_type);
return;
}
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 81890d4..3c2ebf9 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -258,7 +258,7 @@
gc = gc_new();
{
struct buffer out = alloc_buf_gc(256, &gc);
- buf_printf(&out, ">PROXY:%u,%s,%s", (l ? l->current : 0) + 1,
+ buf_printf(&out, ">PROXY:%d,%s,%s", (l ? l->current : 0) + 1,
(proto_is_udp(ce->proto) ? "UDP" : "TCP"),
np(ce->remote));
management_notify_generic(BSTR(&out));
management->persist.special_state_msg = BSTR(&out);
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 95e93da..5a57c0a 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -5139,7 +5139,7 @@
}
else
{
- msg(msglevel, "argument to --bind-dev is longer than allowed %u",
IFNAMSIZ - 1);
+ msg(msglevel, "argument to --bind-dev is longer than allowed %d",
IFNAMSIZ - 1);
goto err;
}
}
diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c
index ab581f4..ccdd43d 100644
--- a/src/openvpn/platform.c
+++ b/src/openvpn/platform.c
@@ -551,7 +551,7 @@
++attempts;
if (!checked_snprintf(fname, sizeof(fname), fname_fmt, max_prefix_len,
prefix,
- get_random(), get_random()))
+ (uint64_t)get_random(), (uint64_t)get_random()))
{
msg(M_WARN, "ERROR: temporary filename too long");
return NULL;
diff --git a/src/openvpn/push.c b/src/openvpn/push.c
index d72596e..a514d92a 100644
--- a/src/openvpn/push.c
+++ b/src/openvpn/push.c
@@ -351,7 +351,7 @@
parse_auth_pending_keywords(buffer, &server_timeout);
msg(D_PUSH,
- "AUTH_PENDING received, extending handshake timeout from %us "
+ "AUTH_PENDING received, extending handshake timeout from %ds "
"to %us",
c->options.handshake_window, min_uint(max_timeout, server_timeout));
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 469edb3..b8bac7a 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -2822,7 +2822,7 @@
ret = (ack.error_number == ERROR_OBJECT_ALREADY_EXISTS) ? RTA_EEXIST :
RTA_ERROR;
if (ret == RTA_ERROR)
{
- msg(M_WARN, "ERROR: route %s failed using service: %s [status=%u
if_index=%lu]",
+ msg(M_WARN, "ERROR: route %s failed using service: %s [status=%d
if_index=%lu]",
(add ? "addition" : "deletion"),
strerror_win32(ack.error_number, &gc),
ack.error_number, rt->iface.index);
}
diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index 6a8e78e..3594871 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -1690,7 +1690,7 @@
options->ping_rec_timeout, frame->mss_fix);
if (ret < 0)
{
- msg(D_DCO, "Cannot set DCO peer parameters for peer (id=%u):
%s",
+ msg(D_DCO, "Cannot set DCO peer parameters for peer (id=%d):
%s",
multi->dco_peer_id, strerror(-ret));
return false;
}
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 2d8f36d..85b3074 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -153,7 +153,7 @@
if (ack.error_number != NO_ERROR)
{
- msg(M_WARN, "TUN: %s address failed using service: %s [status=%u
if_index=%lu]",
+ msg(M_WARN, "TUN: %s address failed using service: %s [status=%d
if_index=%lu]",
(add ? "adding" : "deleting"), strerror_win32(ack.error_number,
&gc), ack.error_number,
addr.iface.index);
goto out;
@@ -224,7 +224,7 @@
if (ack.error_number != NO_ERROR)
{
- msg(M_WARN, "TUN: %s DNS domains failed using service: %s [status=%u
if_name=%s]",
+ msg(M_WARN, "TUN: %s DNS domains failed using service: %s [status=%d
if_name=%s]",
(add ? "adding" : "deleting"), strerror_win32(ack.error_number,
&gc), ack.error_number,
dns.iface.name);
goto out;
@@ -294,7 +294,7 @@
if (ack.error_number != NO_ERROR)
{
- msg(M_WARN, "TUN: %s %s dns failed using service: %s [status=%u
if_name=%s]",
+ msg(M_WARN, "TUN: %s %s dns failed using service: %s [status=%d
if_name=%s]",
(add ? "adding" : "deleting"), ip_proto_name,
strerror_win32(ack.error_number, &gc),
ack.error_number, dns.iface.name);
goto out;
@@ -351,7 +351,7 @@
if (ack.error_number != NO_ERROR)
{
- msg(M_WARN, "TUN: %s WINS failed using service: %s [status=%u
if_name=%s]",
+ msg(M_WARN, "TUN: %s WINS failed using service: %s [status=%d
if_name=%s]",
(add ? "adding" : "deleting"), strerror_win32(ack.error_number,
&gc),
ack.error_number, wins.iface.name);
goto out;
@@ -389,7 +389,7 @@
if (ack.error_number != NO_ERROR)
{
- msg(M_NONFATAL, "TUN: setting %s mtu using service failed: %s
[status=%u if_index=%lu]",
+ msg(M_NONFATAL, "TUN: setting %s mtu using service failed: %s
[status=%d if_index=%lu]",
family_name, strerror_win32(ack.error_number, &gc),
ack.error_number,
mtu_msg.iface.index);
}
@@ -467,7 +467,7 @@
if (ack.error_number != NO_ERROR)
{
- msg(M_NONFATAL, "TUN: creating %s adapter using service failed: %s
[status=%u]",
+ msg(M_NONFATAL, "TUN: creating %s adapter using service failed: %s
[status=%d]",
print_tun_backend_driver(driver_type),
strerror_win32(ack.error_number, &gc),
ack.error_number);
}
@@ -5192,7 +5192,7 @@
if (ack.error_number != NO_ERROR)
{
- msg(M_NONFATAL, "TUN: enabling dhcp using service failed: %s
[status=%u if_index=%lu]",
+ msg(M_NONFATAL, "TUN: enabling dhcp using service failed: %s
[status=%d if_index=%lu]",
strerror_win32(ack.error_number, &gc), ack.error_number,
dhcp.iface.index);
}
else
@@ -5441,7 +5441,7 @@
{
msg(M_FATAL,
"ERROR: This version of " PACKAGE_NAME
- " requires a TAP-Windows driver that is at least version %u.%u --
If you recently upgraded your " PACKAGE_NAME
+ " requires a TAP-Windows driver that is at least version %d.%d --
If you recently upgraded your " PACKAGE_NAME
" distribution, a reboot is probably required at this point to get
Windows to see the new driver.",
TAP_WIN_MIN_MAJOR, TAP_WIN_MIN_MINOR);
}
diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h
index 0ff2a0b..393e856 100644
--- a/src/openvpn/tun.h
+++ b/src/openvpn/tun.h
@@ -105,7 +105,7 @@
uint8_t netbios_node_type; /* NBT 1,2,4,8 (46) */
/* Max # of addresses allowed for DNS, WINS, etc. */
-#define N_DHCP_ADDR 4
+#define N_DHCP_ADDR 4u
/* DNS (6) */
in_addr_t dns[N_DHCP_ADDR];
diff --git a/src/openvpnmsica/msica_arg.c b/src/openvpnmsica/msica_arg.c
index d763d93..c1809f0 100644
--- a/src/openvpnmsica/msica_arg.c
+++ b/src/openvpnmsica/msica_arg.c
@@ -57,7 +57,7 @@
struct msica_arg *p = malloc(sizeof(struct msica_arg) + argument_size);
if (p == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__,
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__,
sizeof(struct msica_arg) + argument_size);
}
memcpy(p->val, argument, argument_size);
@@ -77,7 +77,7 @@
struct msica_arg *p = malloc(sizeof(struct msica_arg) + argument_size);
if (p == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__,
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__,
sizeof(struct msica_arg) + argument_size);
}
memcpy(p->val, argument, argument_size);
@@ -102,7 +102,7 @@
LPWSTR str = malloc(size);
if (str == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, size);
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, size);
return NULL;
}
diff --git a/src/openvpnmsica/msiex.c b/src/openvpnmsica/msiex.c
index 4d48f06..c6bc648 100644
--- a/src/openvpnmsica/msiex.c
+++ b/src/openvpnmsica/msiex.c
@@ -51,7 +51,7 @@
*pszValue = (LPWSTR)malloc(++dwLength * sizeof(WCHAR));
if (*pszValue == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
return ERROR_OUTOFMEMORY;
}
@@ -64,7 +64,7 @@
LPWSTR szBufHeap = (LPWSTR)malloc(++dwLength * sizeof(WCHAR));
if (szBufHeap == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
return ERROR_OUTOFMEMORY;
}
@@ -107,7 +107,7 @@
*pszValue = (LPWSTR)malloc(++dwLength * sizeof(WCHAR));
if (*pszValue == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
return ERROR_OUTOFMEMORY;
}
@@ -120,7 +120,7 @@
LPWSTR szBufHeap = (LPWSTR)malloc(++dwLength * sizeof(WCHAR));
if (szBufHeap == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
return ERROR_OUTOFMEMORY;
}
@@ -163,7 +163,7 @@
*pszValue = (LPWSTR)malloc(++dwLength * sizeof(WCHAR));
if (*pszValue == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
return ERROR_OUTOFMEMORY;
}
@@ -176,7 +176,7 @@
LPWSTR szBufHeap = (LPWSTR)malloc(++dwLength * sizeof(WCHAR));
if (szBufHeap == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, dwLength *
sizeof(WCHAR));
return ERROR_OUTOFMEMORY;
}
diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c
index e510e4d..d2fd9af 100644
--- a/src/openvpnmsica/openvpnmsica.c
+++ b/src/openvpnmsica/openvpnmsica.c
@@ -165,7 +165,7 @@
pAdapterAdresses =
(PIP_ADAPTER_ADDRESSES)malloc(ulAdapterAdressesSize);
if (pAdapterAdresses == NULL)
{
- msg(M_NONFATAL, "%s: malloc(%u) failed", __FUNCTION__,
ulAdapterAdressesSize);
+ msg(M_NONFATAL, "%s: malloc(%lu) failed", __FUNCTION__,
ulAdapterAdressesSize);
uiResult = ERROR_OUTOFMEMORY;
goto cleanup_pAdapterList;
}
@@ -208,7 +208,7 @@
szAdaptersTail = szAdapters;
if (szAdapters == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__,
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__,
adapter_count * (38 /*GUID*/ + 1 /*separator/terminator*/) *
sizeof(WCHAR));
uiResult = ERROR_OUTOFMEMORY;
goto cleanup_pAdapterAdresses;
@@ -220,7 +220,7 @@
szAdaptersActiveTail = szAdaptersActive;
if (szAdaptersActive == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__,
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__,
adapter_count * (38 /*GUID*/ + 1 /*separator/terminator*/) *
sizeof(WCHAR));
uiResult = ERROR_OUTOFMEMORY;
goto cleanup_szAdapters;
@@ -405,7 +405,7 @@
szPath = (LPWSTR)malloc((++dwPathSize) * sizeof(WCHAR));
if (szPath == NULL)
{
- msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, dwPathSize *
sizeof(WCHAR));
+ msg(M_FATAL, "%s: malloc(%zu) failed", __FUNCTION__, dwPathSize *
sizeof(WCHAR));
uiResult = ERROR_OUTOFMEMORY;
goto cleanup_MsiCreateRecord;
}
diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index 82b24f4..026d5aa 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -311,7 +311,7 @@
* Same format as error messages (3 line string) with error = 0 in
* 0x%08x format, PID on line 2 and a description "Process ID" on line 3
*/
- swprintf(buf, _countof(buf), L"0x%08x\n0x%08x\n%ls", 0, pid, msg);
+ swprintf(buf, _countof(buf), L"0x%08x\n0x%08lx\n%ls", 0, pid, msg);
WritePipeAsync(pipe, buf, (DWORD)(wcslen(buf) * 2), count, events);
}
@@ -380,7 +380,7 @@
if (!argv)
{
swprintf(errmsg, capacity,
- L"Cannot validate options: CommandLineToArgvW failed with
error = 0x%08x",
+ L"Cannot validate options: CommandLineToArgvW failed with
error = 0x%08lx",
GetLastError());
goto out;
}
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1960?usp=email
To unsubscribe, or for help writing mail filters, visit
http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7f910599f0f4005f06a88a93b40417ffa37022a8
Gerrit-Change-Number: 1960
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel