@@ -9,9 +9,6 @@
<id>constParameterCallback</id>
</suppress>
<suppress>
- <id>invalidPrintfArgType_uint</id>
- </suppress>
- <suppress>
<id>unusedFunction</id>
</suppress>
<suppress>
@@ -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>
@@ -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;
}
@@ -89,7 +89,7 @@
};
#ifndef N_DHCP_ADDR
-#define N_DHCP_ADDR 4
+#define N_DHCP_ADDR 4u
#endif
#ifndef N_SEARCH_LIST_LEN
@@ -1305,7 +1305,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;
}
@@ -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);
@@ -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;
}
}
@@ -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;
@@ -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));
@@ -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);
}
@@ -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;
}
@@ -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);
}
@@ -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];
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}