Merge pull request #4334 from bluca/gcc_fix

Problem: build fails with gcc 12
This commit is contained in:
Luca Boccassi 2022-01-18 20:17:32 +00:00 committed by GitHub
commit a01d259db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 11 deletions

View File

@ -244,7 +244,7 @@ EXAMPLE
// in case of error.
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
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));
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) {
// Subsequent frames in message contain event values
zmq_msg_init (&msg);
@ -274,8 +279,8 @@ get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **
return -1; // Interrupted, presumably
assert (zmq_msg_more (&msg));
if (value_ && value_ + i)
memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_));
if (value && *value)
memcpy (&(*value)[i], zmq_msg_data (&msg), sizeof (uint64_t));
zmq_msg_close (&msg);
}

View File

@ -396,17 +396,19 @@ void test_monitor_versioned_stats (bind_function_t bind_function_,
for (int i = 0; i < pulls_count; ++i) {
char *push_local_address = NULL;
char *push_remote_address = NULL;
uint64_t queue_stat[2];
uint64_t *queue_stat = NULL;
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_LEN (expected_prefix_, push_remote_address,
strlen (expected_prefix_));
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 (0, queue_stat[1]);
free (push_local_address);
free (push_remote_address);
free (queue_stat);
}
// Close client and server

View File

@ -207,7 +207,7 @@ int expect_monitor_event_multiple (void *server_mon_,
}
static int64_t get_monitor_event_internal_v2 (void *monitor_,
uint64_t *value_,
uint64_t **value_,
char **local_address_,
char **remote_address_,
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));
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) {
// Subsequent frames in message contain event values
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_EQUAL_UINT (sizeof (uint64_t), zmq_msg_size (&msg));
if (value_ && value_ + i)
memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_));
if (value_ && *value_)
memcpy (&(*value_)[i], zmq_msg_data (&msg), sizeof (uint64_t));
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_,
uint64_t *value_,
uint64_t **value_,
char **local_address_,
char **remote_address_,
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_,
uint64_t *value_,
uint64_t **value_,
char **local_address_,
char **remote_address_)
{

View File

@ -67,7 +67,7 @@ int expect_monitor_event_multiple (void *server_mon_,
bool optional_ = false);
int64_t get_monitor_event_v2 (void *monitor_,
uint64_t *value_,
uint64_t **value_,
char **local_address_,
char **remote_address_);