This is an automated email from the ASF dual-hosted git repository.
jdanek pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push:
new a175b5ee2 PROTON-2772: add printf format arg annotations to satisfy
MSVC (#419)
a175b5ee2 is described below
commit a175b5ee28949a982f60022f927bd457873cb1fd
Author: Jiri Daněk <[email protected]>
AuthorDate: Wed Jan 10 14:38:33 2024 +0100
PROTON-2772: add printf format arg annotations to satisfy MSVC (#419)
---
CMakeLists.txt | 8 +++++---
c/src/core/codec.c | 4 ++--
c/src/core/dispatcher.c | 4 ++--
c/src/core/encoder.c | 2 +-
c/src/core/engine.c | 6 +++---
c/src/core/message.c | 4 ++--
c/src/core/transport.c | 8 ++++----
c/src/core/value_dump.c | 2 +-
c/src/proactor/win_iocp.cpp | 2 +-
c/src/reactor/io/windows/iocp.c | 4 ++--
c/src/ssl/schannel.cpp | 28 ++++++++++++++--------------
11 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 214e078e3..8d66e2279 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ set (COMMON_WARNING_GNU "-Wall -pedantic-errors")
set (COMMON_WARNING_Clang "-Wall -pedantic")
string (JOIN " " COMMON_WARNING_MSVC "/W4" "/analyze"
# disabled warnings /wd
+ "/wd26812" # The enum type 'pcontext_type_t' is unscoped. Prefer 'enum
class' over 'enum' (Enum.3).
"/wd4090" # 'function': different 'const' qualifiers
"/wd4100" # 'argv': unreferenced formal parameter
"/wd4127" # conditional expression is constant
@@ -206,15 +207,16 @@ string (JOIN " " COMMON_WARNING_MSVC "/W4" "/analyze"
"/wd6244" # Local declaration of 'buf' hides previous declaration at line
'33'
"/wd6246" # Local declaration of 'type' hides declaration of the same name
in outer scope.
"/wd6308" # 'realloc' might return null pointer: assigning null pointer to
'a->addresses', which is passed as an argument to 'realloc', will cause the
original memory block to be leaked.
- "/wd6328" # Size mismatch: 'unsigned __int64' passed as _Param_(2) when
'int' is required in call to 'iocp_log'.
"/wd6336" # Arithmetic operator has precedence over question operator, use
parentheses to clarify intent.
- "/wd6340" # Mismatch on sign: 'unsigned char' passed as _Param_(5) when some
signed type is required in call to 'pn_logger_logf'.
"/wd6385" # Reading invalid data from 'conn->rbuffers'.
"/wd6386" # Buffer overrun while writing to 'nargv': the writable size is
'_Param_(1)*_Param_(2)' bytes, but '16' bytes might be written.
"/wd6387" # 'rbytes' could be '0': this does not adhere to the
specification for the function 'memcpy'.
+
# warnings as error /we
- "/we28251" # Inconsistent annotation for function: this instance has an error
"/we26819" # Unannotated fallthrough between switch labels
+ "/we28251" # Inconsistent annotation for function: this instance has an error
+ "/we6328" # Size mismatch: 'unsigned __int64' passed as _Param_(2) when
'int' is required in call to 'iocp_log'.
+ "/we6340" # Mismatch on sign: 'unsigned char' passed as _Param_(5) when some
signed type is required in call to 'pn_logger_logf'.
)
set (CC_WARNING_GNU "-Wno-unused-parameter -Wstrict-prototypes -Wvla
-Wsign-compare -Wwrite-strings -Wimplicit-fallthrough=3")
diff --git a/c/src/core/codec.c b/c/src/core/codec.c
index 513a994cc..c058bb6b5 100644
--- a/c/src/core/codec.c
+++ b/c/src/core/codec.c
@@ -1498,8 +1498,8 @@ void pn_data_dump(pn_data_t *data)
pn_fixed_string_t str = pn_fixed_string(buf, sizeof(buf));
pni_inspect_atom((pn_atom_t *) &node->atom, &str);
pn_fixed_string_terminate(&str);
- printf("Node %i: prev=%" PN_ZI ", next=%" PN_ZI ", parent=%" PN_ZI ",
down=%" PN_ZI
- ", children=%" PN_ZI ", type=%s (%s)\n",
+ printf("Node %u: prev=%" PN_ZU ", next=%" PN_ZU ", parent=%" PN_ZU ",
down=%" PN_ZU
+ ", children=%" PN_ZU ", type=%s (%s)\n",
i + 1, (size_t) node->prev,
(size_t) node->next,
(size_t) node->parent,
diff --git a/c/src/core/dispatcher.c b/c/src/core/dispatcher.c
index c7ed79a67..d96422e89 100644
--- a/c/src/core/dispatcher.c
+++ b/c/src/core/dispatcher.c
@@ -30,12 +30,12 @@
int pni_bad_frame(pn_transport_t *transport, uint8_t frame_type, uint16_t
channel, pn_bytes_t payload) {
- PN_LOG(&transport->logger, PN_SUBSYSTEM_AMQP, PN_LEVEL_ERROR, "Error
dispatching frame: type: %d: Unknown performative", frame_type);
+ PN_LOG(&transport->logger, PN_SUBSYSTEM_AMQP, PN_LEVEL_ERROR, "Error
dispatching frame: type: %u: Unknown performative", frame_type);
return PN_ERR;
}
int pni_bad_frame_type(pn_transport_t *transport, uint8_t frame_type, uint16_t
channel, pn_bytes_t payload) {
- PN_LOG(&transport->logger, PN_SUBSYSTEM_AMQP, PN_LEVEL_ERROR, "Error
dispatching frame: Unknown frame type: %d", frame_type);
+ PN_LOG(&transport->logger, PN_SUBSYSTEM_AMQP, PN_LEVEL_ERROR, "Error
dispatching frame: Unknown frame type: %u", frame_type);
return PN_ERR;
}
diff --git a/c/src/core/encoder.c b/c/src/core/encoder.c
index cd0b5fb35..97af8de16 100644
--- a/c/src/core/encoder.c
+++ b/c/src/core/encoder.c
@@ -78,7 +78,7 @@ static uint8_t pn_type2code(pn_encoder_t *encoder, pn_type_t
type)
case PN_MAP: return PNE_MAP32;
case PN_DESCRIBED: return PNE_DESCRIPTOR;
default:
- return pn_error_format(pni_encoder_error(encoder), PN_ERR, "not a value
type: %u\n", type);
+ return pn_error_format(pni_encoder_error(encoder), PN_ERR, "not a value
type: %d\n", type);
}
}
diff --git a/c/src/core/engine.c b/c/src/core/engine.c
index 8110a85e5..faf096812 100644
--- a/c/src/core/engine.c
+++ b/c/src/core/engine.c
@@ -1642,9 +1642,9 @@ void pn_delivery_dump(pn_delivery_t *d)
char tag[1024];
pn_bytes_t bytes = d->tag;
pn_quote_data(tag, 1024, bytes.start, bytes.size);
- printf("{tag=%s, local.type=%" PRIu64 ", remote.type=%" PRIu64 ",
local.settled=%u, "
- "remote.settled=%u, updated=%u, current=%u, writable=%u, readable=%u,
"
- "work=%u}",
+ printf("{tag=%s, local.type=%" PRIu64 ", remote.type=%" PRIu64 ",
local.settled=%d, "
+ "remote.settled=%d, updated=%d, current=%d, writable=%d, readable=%d,
"
+ "work=%d}",
tag, d->local.type, d->remote.type, d->local.settled,
d->remote.settled, d->updated, pn_delivery_current(d),
pn_delivery_writable(d), pn_delivery_readable(d), d->work);
diff --git a/c/src/core/message.c b/c/src/core/message.c
index 304d91b41..6c4975c00 100644
--- a/c/src/core/message.c
+++ b/c/src/core/message.c
@@ -180,7 +180,7 @@ void pn_message_inspect(void *obj, pn_fixed_string_t *dst)
}
if (msg->priority != HEADER_PRIORITY_DEFAULT) {
- pn_fixed_string_addf(dst, "priority=%i, ", msg->priority);
+ pn_fixed_string_addf(dst, "priority=%u, ", msg->priority);
comma = true;
}
@@ -268,7 +268,7 @@ void pn_message_inspect(void *obj, pn_fixed_string_t *dst)
}
if (msg->group_sequence) {
- pn_fixed_string_addf(dst, "group_sequence=%" PRIi32 ", ",
msg->group_sequence);
+ pn_fixed_string_addf(dst, "group_sequence=%" PRIu32 ", ",
msg->group_sequence);
comma = true;
}
diff --git a/c/src/core/transport.c b/c/src/core/transport.c
index 1536f4274..10adaa3a6 100644
--- a/c/src/core/transport.c
+++ b/c/src/core/transport.c
@@ -1115,7 +1115,7 @@ int pn_do_begin(pn_transport_t *transport, uint8_t
frame_type, uint16_t channel,
if (channel > transport->channel_max) {
pn_do_error(transport,
"amqp:connection:framing-error",
- "remote channel %d is above negotiated channel_max %d.",
+ "remote channel %u is above negotiated channel_max %u.",
channel,
transport->channel_max
);
@@ -1128,7 +1128,7 @@ int pn_do_begin(pn_transport_t *transport, uint8_t
frame_type, uint16_t channel,
if (ssn == 0) {
pn_do_error(transport,
"amqp:invalid-field",
- "begin reply to unknown channel %d.",
+ "begin reply to unknown channel %u.",
remote_channel
);
return PN_ARG_ERR;
@@ -1956,7 +1956,7 @@ static int pni_process_ssn_setup(pn_transport_t
*transport, pn_endpoint_t *endpo
if (!(endpoint->state & PN_LOCAL_UNINIT) && state->local_channel ==
(uint16_t) -1)
{
if (! pni_map_local_channel(ssn)) {
- pn_logger_logf(&transport->logger, PN_SUBSYSTEM_AMQP,
PN_LEVEL_WARNING, "unable to find an open available channel within limit of
%d", transport->channel_max );
+ pn_logger_logf(&transport->logger, PN_SUBSYSTEM_AMQP,
PN_LEVEL_WARNING, "unable to find an open available channel within limit of
%u", transport->channel_max );
return PN_ERR;
}
state->incoming_window = pni_session_incoming_window(ssn);
@@ -2017,7 +2017,7 @@ static int pni_process_link_setup(pn_transport_t
*transport, pn_endpoint_t *endp
!(endpoint->state & PN_LOCAL_UNINIT) && state->local_handle ==
(uint32_t) -1)
{
if (! pni_map_local_handle(link)) {
- pn_logger_logf(&transport->logger, PN_SUBSYSTEM_AMQP,
PN_LEVEL_WARNING, "unable to find an open available handle within limit of %d",
ssn_state->remote_handle_max );
+ pn_logger_logf(&transport->logger, PN_SUBSYSTEM_AMQP,
PN_LEVEL_WARNING, "unable to find an open available handle within limit of %u",
ssn_state->remote_handle_max );
return PN_ERR;
}
const pn_distribution_mode_t dist_mode = (pn_distribution_mode_t)
link->source.distribution_mode;
diff --git a/c/src/core/value_dump.c b/c/src/core/value_dump.c
index 9a5af81e3..971441b23 100644
--- a/c/src/core/value_dump.c
+++ b/c/src/core/value_dump.c
@@ -467,7 +467,7 @@ void pn_value_dump_array(uint32_t count, pn_bytes_t value,
pn_fixed_string_t *ou
pn_value_dump_nondescribed_value(type, evalue, output);
if (type_isspecial(type)) {
if (count>1) {
- pn_fixed_string_addf(output, ", ...(%d more)]", count-1);
+ pn_fixed_string_addf(output, ", ...(%u more)]", count-1);
} else {
pn_fixed_string_addf(output, "]");
}
diff --git a/c/src/proactor/win_iocp.cpp b/c/src/proactor/win_iocp.cpp
index c71cd76d0..6f67ed204 100644
--- a/c/src/proactor/win_iocp.cpp
+++ b/c/src/proactor/win_iocp.cpp
@@ -1429,7 +1429,7 @@ static void drain_zombie_completions(iocp_t *iocp)
break;
int rv = pni_iocp_wait_one(iocp, deadline - now, NULL);
if (rv < 0) {
- iocp_log("unexpected IOCP failure on Proton IO shutdown %d\n",
GetLastError());
+ iocp_log("unexpected IOCP failure on Proton IO shutdown %lu\n",
GetLastError());
break;
}
now = pn_proactor_now_64();
diff --git a/c/src/reactor/io/windows/iocp.c b/c/src/reactor/io/windows/iocp.c
index ff7f70ff3..95e1b9847 100644
--- a/c/src/reactor/io/windows/iocp.c
+++ b/c/src/reactor/io/windows/iocp.c
@@ -1012,7 +1012,7 @@ static void drain_zombie_completions(iocp_t *iocp)
break;
int rv = pni_iocp_wait_one(iocp, deadline - now, NULL);
if (rv < 0) {
- iocp_log("unexpected IOCP failure on Proton IO shutdown %d\n",
GetLastError());
+ iocp_log("unexpected IOCP failure on Proton IO shutdown %lu\n",
GetLastError());
break;
}
now = pn_i_now();
@@ -1165,7 +1165,7 @@ void pni_iocp_finalize(void *obj)
iocp->completion_port = NULL;
if (pn_list_size(externals) && iocp->iocp_trace)
- iocp_log("%d external sockets not closed and removed from Proton IOCP
control\n", pn_list_size(externals));
+ iocp_log("%zu external sockets not closed and removed from Proton IOCP
control\n", pn_list_size(externals));
// Now safe to free everything that might be touched by a former async
operation.
pn_free(externals);
diff --git a/c/src/ssl/schannel.cpp b/c/src/ssl/schannel.cpp
index b2e1cefb1..e517cf9de 100644
--- a/c/src/ssl/schannel.cpp
+++ b/c/src/ssl/schannel.cpp
@@ -997,7 +997,7 @@ static void ssl_encrypt(pn_transport_t *transport, char
*app_data, size_t count)
ssl->sc_out_count = buffs[0].cbBuffer + buffs[1].cbBuffer +
buffs[2].cbBuffer;
ssl->network_outp = ssl->sc_outbuf;
ssl->network_out_pending = ssl->sc_out_count;
- ssl_log(transport, PN_LEVEL_TRACE, "ssl_encrypt %d network bytes",
ssl->network_out_pending);
+ ssl_log(transport, PN_LEVEL_TRACE, "ssl_encrypt %zu network bytes",
ssl->network_out_pending);
}
// Returns true if decryption succeeded (even for empty content)
@@ -1100,7 +1100,7 @@ static void client_handshake_init(pn_transport_t
*transport)
ssl->network_out_pending = ssl->sc_out_count;
// the token is the whole quantity to send
ssl->network_outp = ssl->sc_outbuf;
- ssl_log(transport, PN_LEVEL_TRACE, "Sending client hello %d bytes",
ssl->network_out_pending);
+ ssl_log(transport, PN_LEVEL_TRACE, "Sending client hello %zu bytes",
ssl->network_out_pending);
} else {
ssl_log_error_status(status, "InitializeSecurityContext failed");
ssl_failed(transport, 0);
@@ -1166,7 +1166,7 @@ static void client_handshake( pn_transport_t* transport) {
// the token is the whole quantity to send
ssl->network_out_pending = ssl->sc_out_count;
ssl->network_outp = ssl->sc_outbuf;
- ssl_log(transport, PN_LEVEL_DEBUG, "client handshake token %d bytes",
ssl->network_out_pending);
+ ssl_log(transport, PN_LEVEL_DEBUG, "client handshake token %zu bytes",
ssl->network_out_pending);
break;
case SEC_E_OK:
@@ -1177,7 +1177,7 @@ static void client_handshake( pn_transport_t* transport) {
// the token is the whole quantity to send
ssl->network_out_pending = ssl->sc_out_count;
ssl->network_outp = ssl->sc_outbuf;
- ssl_log(transport, PN_LEVEL_DEBUG, "client shutdown token %d bytes",
ssl->network_out_pending);
+ ssl_log(transport, PN_LEVEL_DEBUG, "client shutdown token %zu bytes",
ssl->network_out_pending);
} else {
ssl->state = SSL_CLOSED;
}
@@ -1226,7 +1226,7 @@ static void client_handshake( pn_transport_t* transport) {
ssl->state = RUNNING;
ssl->max_data_size = max - ssl->sc_sizes.cbHeader -
ssl->sc_sizes.cbTrailer;
- ssl_log(transport, PN_LEVEL_DEBUG, "client handshake successful %d max
record size", max);
+ ssl_log(transport, PN_LEVEL_DEBUG, "client handshake successful %zu max
record size", max);
break;
case SEC_I_CONTEXT_EXPIRED:
@@ -1335,7 +1335,7 @@ static void server_handshake(pn_transport_t* transport)
// the token is the whole quantity to send
ssl->network_out_pending = ssl->sc_out_count;
ssl->network_outp = ssl->sc_outbuf;
- ssl_log(transport, PN_LEVEL_DEBUG, "server shutdown token %d bytes",
ssl->network_out_pending);
+ ssl_log(transport, PN_LEVEL_DEBUG, "server shutdown token %zu bytes",
ssl->network_out_pending);
} else {
ssl->state = SSL_CLOSED;
}
@@ -1375,7 +1375,7 @@ static void server_handshake(pn_transport_t* transport)
ssl->state = RUNNING;
ssl->max_data_size = max - ssl->sc_sizes.cbHeader -
ssl->sc_sizes.cbTrailer;
- ssl_log(transport, PN_LEVEL_DEBUG, "server handshake successful %d max
record size", max);
+ ssl_log(transport, PN_LEVEL_DEBUG, "server handshake successful %zu max
record size", max);
break;
case SEC_E_ALGORITHM_MISMATCH:
@@ -1398,7 +1398,7 @@ static void server_handshake(pn_transport_t* transport)
// the token is the whole quantity to send
ssl->network_out_pending = ssl->sc_out_count;
ssl->network_outp = ssl->sc_outbuf;
- ssl_log(transport, PN_LEVEL_DEBUG, "server handshake token %d bytes",
ssl->network_out_pending);
+ ssl_log(transport, PN_LEVEL_DEBUG, "server handshake token %zu bytes",
ssl->network_out_pending);
}
if (token_buffs[1].BufferType == SECBUFFER_EXTRA && token_buffs[1].cbBuffer
> 0 &&
@@ -1432,7 +1432,7 @@ static bool grow_inbuf2(pn_transport_t *transport, size_t
minimum_size) {
if (max_frame != 0) {
if (old_capacity >= max_frame) {
// already big enough
- ssl_log(transport, PN_LEVEL_ERROR, "Application expecting %d bytes (>
negotiated maximum frame)", new_capacity);
+ ssl_log(transport, PN_LEVEL_ERROR, "Application expecting %zu bytes (>
negotiated maximum frame)", new_capacity);
ssl_failed(transport, "TLS: transport maximum frame size error");
return false;
}
@@ -1441,7 +1441,7 @@ static bool grow_inbuf2(pn_transport_t *transport, size_t
minimum_size) {
size_t extra_bytes = new_capacity - pn_buffer_size(ssl->inbuf2);
int err = pn_buffer_ensure(ssl->inbuf2, extra_bytes);
if (err) {
- ssl_log(transport, PN_LEVEL_ERROR, "TLS memory allocation failed for %d
bytes", max_frame);
+ ssl_log(transport, PN_LEVEL_ERROR, "TLS memory allocation failed for %u
bytes", max_frame);
ssl_failed(transport, "TLS memory allocation failed");
return false;
}
@@ -1627,7 +1627,7 @@ static void read_closed(pn_transport_t *transport,
unsigned int layer, ssize_t e
static ssize_t process_input_ssl(pn_transport_t *transport, unsigned int
layer, const char *input_data, size_t available)
{
pni_ssl_t *ssl = transport->ssl;
- ssl_log( transport, PN_LEVEL_TRACE, "process_input_ssl( data size=%d
)",available );
+ ssl_log( transport, PN_LEVEL_TRACE, "process_input_ssl( data size=%zu
)",available );
ssize_t consumed = 0;
ssize_t forwarded = 0;
bool new_app_input;
@@ -1704,7 +1704,7 @@ static ssize_t process_input_ssl(pn_transport_t
*transport, unsigned int layer,
rewind_sc_inbuf(ssl);
}
}
- ssl_log(transport, PN_LEVEL_TRACE, "Next decryption, %d left over",
available);
+ ssl_log(transport, PN_LEVEL_TRACE, "Next decryption, %zu left over",
available);
}
}
@@ -1769,7 +1769,7 @@ static ssize_t process_output_ssl( pn_transport_t
*transport, unsigned int layer
{
pni_ssl_t *ssl = transport->ssl;
if (!ssl) return PN_EOS;
- ssl_log( transport, PN_LEVEL_TRACE, "process_output_ssl( max_len=%d
)",max_len );
+ ssl_log( transport, PN_LEVEL_TRACE, "process_output_ssl( max_len=%zu
)",max_len );
ssize_t written = 0;
ssize_t total_app_bytes = 0;
@@ -1808,7 +1808,7 @@ static ssize_t process_output_ssl( pn_transport_t
*transport, unsigned int layer
if (app_bytes > 0) {
app_outp += app_bytes;
remaining -= app_bytes;
- ssl_log( transport, PN_LEVEL_TRACE, "Gathered %d bytes from app to
send to peer", app_bytes );
+ ssl_log( transport, PN_LEVEL_TRACE, "Gathered %zd bytes from app to
send to peer", app_bytes );
} else {
if (app_bytes < 0) {
ssl_log(transport, PN_LEVEL_WARNING, "Application layer closed its
output, error=%d (%d bytes pending send)",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]