mirror of
https://github.com/zeromq/libzmq.git
synced 2025-05-03 15:58:27 +02:00
Problem: build fails with gcc 12
Solution: change test_monitor and example
This commit is contained in:
parent
f03391640b
commit
176d72cc9b
@ -244,7 +244,7 @@ EXAMPLE
|
|||||||
// in case of error.
|
// in case of error.
|
||||||
|
|
||||||
static uint64_t
|
static uint64_t
|
||||||
get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **remote_address)
|
get_monitor_event (void *monitor, uint64_t **value, char **local_address, char **remote_address)
|
||||||
{
|
{
|
||||||
// First frame in message contains event number
|
// First frame in message contains event number
|
||||||
zmq_msg_t msg;
|
zmq_msg_t msg;
|
||||||
@ -267,6 +267,11 @@ get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **
|
|||||||
memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count));
|
memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count));
|
||||||
zmq_msg_close (&msg);
|
zmq_msg_close (&msg);
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
*value = (uint64_t *) malloc (value_count * sizeof (uint64_t));
|
||||||
|
assert (*value);
|
||||||
|
}
|
||||||
|
|
||||||
for (uint64_t i = 0; i < value_count; ++i) {
|
for (uint64_t i = 0; i < value_count; ++i) {
|
||||||
// Subsequent frames in message contain event values
|
// Subsequent frames in message contain event values
|
||||||
zmq_msg_init (&msg);
|
zmq_msg_init (&msg);
|
||||||
@ -274,8 +279,8 @@ get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **
|
|||||||
return -1; // Interrupted, presumably
|
return -1; // Interrupted, presumably
|
||||||
assert (zmq_msg_more (&msg));
|
assert (zmq_msg_more (&msg));
|
||||||
|
|
||||||
if (value_ && value_ + i)
|
if (value && *value)
|
||||||
memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_));
|
memcpy (&(*value)[i], zmq_msg_data (&msg), sizeof (uint64_t));
|
||||||
zmq_msg_close (&msg);
|
zmq_msg_close (&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,17 +396,19 @@ void test_monitor_versioned_stats (bind_function_t bind_function_,
|
|||||||
for (int i = 0; i < pulls_count; ++i) {
|
for (int i = 0; i < pulls_count; ++i) {
|
||||||
char *push_local_address = NULL;
|
char *push_local_address = NULL;
|
||||||
char *push_remote_address = NULL;
|
char *push_remote_address = NULL;
|
||||||
uint64_t queue_stat[2];
|
uint64_t *queue_stat = NULL;
|
||||||
int64_t event = get_monitor_event_v2 (
|
int64_t event = get_monitor_event_v2 (
|
||||||
push_mon, queue_stat, &push_local_address, &push_remote_address);
|
push_mon, &queue_stat, &push_local_address, &push_remote_address);
|
||||||
TEST_ASSERT_EQUAL_STRING (server_endpoint, push_local_address);
|
TEST_ASSERT_EQUAL_STRING (server_endpoint, push_local_address);
|
||||||
TEST_ASSERT_EQUAL_STRING_LEN (expected_prefix_, push_remote_address,
|
TEST_ASSERT_EQUAL_STRING_LEN (expected_prefix_, push_remote_address,
|
||||||
strlen (expected_prefix_));
|
strlen (expected_prefix_));
|
||||||
TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_PIPES_STATS, event);
|
TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_PIPES_STATS, event);
|
||||||
|
TEST_ASSERT_NOT_NULL (queue_stat);
|
||||||
TEST_ASSERT_EQUAL_INT (i == 0 ? 0 : send_hwm, queue_stat[0]);
|
TEST_ASSERT_EQUAL_INT (i == 0 ? 0 : send_hwm, queue_stat[0]);
|
||||||
TEST_ASSERT_EQUAL_INT (0, queue_stat[1]);
|
TEST_ASSERT_EQUAL_INT (0, queue_stat[1]);
|
||||||
free (push_local_address);
|
free (push_local_address);
|
||||||
free (push_remote_address);
|
free (push_remote_address);
|
||||||
|
free (queue_stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close client and server
|
// Close client and server
|
||||||
|
@ -207,7 +207,7 @@ int expect_monitor_event_multiple (void *server_mon_,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
||||||
uint64_t *value_,
|
uint64_t **value_,
|
||||||
char **local_address_,
|
char **local_address_,
|
||||||
char **remote_address_,
|
char **remote_address_,
|
||||||
int recv_flag_)
|
int recv_flag_)
|
||||||
@ -239,6 +239,12 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
|||||||
memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count));
|
memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count));
|
||||||
zmq_msg_close (&msg);
|
zmq_msg_close (&msg);
|
||||||
|
|
||||||
|
if (value_) {
|
||||||
|
*value_ =
|
||||||
|
(uint64_t *) malloc ((size_t) value_count * sizeof (uint64_t));
|
||||||
|
TEST_ASSERT_NOT_NULL (*value_);
|
||||||
|
}
|
||||||
|
|
||||||
for (uint64_t i = 0; i < value_count; ++i) {
|
for (uint64_t i = 0; i < value_count; ++i) {
|
||||||
// Subsequent frames in message contain event values
|
// Subsequent frames in message contain event values
|
||||||
zmq_msg_init (&msg);
|
zmq_msg_init (&msg);
|
||||||
@ -249,8 +255,8 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
|||||||
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
||||||
TEST_ASSERT_EQUAL_UINT (sizeof (uint64_t), zmq_msg_size (&msg));
|
TEST_ASSERT_EQUAL_UINT (sizeof (uint64_t), zmq_msg_size (&msg));
|
||||||
|
|
||||||
if (value_ && value_ + i)
|
if (value_ && *value_)
|
||||||
memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_));
|
memcpy (&(*value_)[i], zmq_msg_data (&msg), sizeof (uint64_t));
|
||||||
zmq_msg_close (&msg);
|
zmq_msg_close (&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +272,7 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int64_t get_monitor_event_with_timeout_v2 (void *monitor_,
|
static int64_t get_monitor_event_with_timeout_v2 (void *monitor_,
|
||||||
uint64_t *value_,
|
uint64_t **value_,
|
||||||
char **local_address_,
|
char **local_address_,
|
||||||
char **remote_address_,
|
char **remote_address_,
|
||||||
int timeout_)
|
int timeout_)
|
||||||
@ -299,7 +305,7 @@ static int64_t get_monitor_event_with_timeout_v2 (void *monitor_,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t get_monitor_event_v2 (void *monitor_,
|
int64_t get_monitor_event_v2 (void *monitor_,
|
||||||
uint64_t *value_,
|
uint64_t **value_,
|
||||||
char **local_address_,
|
char **local_address_,
|
||||||
char **remote_address_)
|
char **remote_address_)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ int expect_monitor_event_multiple (void *server_mon_,
|
|||||||
bool optional_ = false);
|
bool optional_ = false);
|
||||||
|
|
||||||
int64_t get_monitor_event_v2 (void *monitor_,
|
int64_t get_monitor_event_v2 (void *monitor_,
|
||||||
uint64_t *value_,
|
uint64_t **value_,
|
||||||
char **local_address_,
|
char **local_address_,
|
||||||
char **remote_address_);
|
char **remote_address_);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user