6227
|
1 Patch for GCC12 |
|
2 diff --git a/doc/zmq_socket_monitor_versioned.txt b/doc/zmq_socket_monitor_versioned.txt |
|
3 index 5339f404a4..e71dd3544d 100644 |
|
4 --- a/doc/zmq_socket_monitor_versioned.txt |
|
5 +++ b/doc/zmq_socket_monitor_versioned.txt |
|
6 @@ -244,7 +244,7 @@ EXAMPLE |
|
7 // in case of error. |
|
8 |
|
9 static uint64_t |
|
10 -get_monitor_event (void *monitor, uint64_t *value, char **local_address, char **remote_address) |
|
11 +get_monitor_event (void *monitor, uint64_t **value, char **local_address, char **remote_address) |
|
12 { |
|
13 // First frame in message contains event number |
|
14 zmq_msg_t msg; |
|
15 @@ -267,6 +267,11 @@ get_monitor_event (void *monitor, uint64_t *value, char **local_address, char ** |
|
16 memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count)); |
|
17 zmq_msg_close (&msg); |
|
18 |
|
19 + if (value) { |
|
20 + *value = (uint64_t *) malloc (value_count * sizeof (uint64_t)); |
|
21 + assert (*value); |
|
22 + } |
|
23 + |
|
24 for (uint64_t i = 0; i < value_count; ++i) { |
|
25 // Subsequent frames in message contain event values |
|
26 zmq_msg_init (&msg); |
|
27 @@ -274,8 +279,8 @@ get_monitor_event (void *monitor, uint64_t *value, char **local_address, char ** |
|
28 return -1; // Interrupted, presumably |
|
29 assert (zmq_msg_more (&msg)); |
|
30 |
|
31 - if (value_ && value_ + i) |
|
32 - memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_)); |
|
33 + if (value && *value) |
|
34 + memcpy (&(*value)[i], zmq_msg_data (&msg), sizeof (uint64_t)); |
|
35 zmq_msg_close (&msg); |
|
36 } |
|
37 |
|
38 diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp |
|
39 index b9309e6df3..7398dbd8d0 100644 |
|
40 --- a/tests/test_monitor.cpp |
|
41 +++ b/tests/test_monitor.cpp |
|
42 @@ -396,17 +396,19 @@ void test_monitor_versioned_stats (bind_function_t bind_function_, |
|
43 for (int i = 0; i < pulls_count; ++i) { |
|
44 char *push_local_address = NULL; |
|
45 char *push_remote_address = NULL; |
|
46 - uint64_t queue_stat[2]; |
|
47 + uint64_t *queue_stat = NULL; |
|
48 int64_t event = get_monitor_event_v2 ( |
|
49 - push_mon, queue_stat, &push_local_address, &push_remote_address); |
|
50 + push_mon, &queue_stat, &push_local_address, &push_remote_address); |
|
51 TEST_ASSERT_EQUAL_STRING (server_endpoint, push_local_address); |
|
52 TEST_ASSERT_EQUAL_STRING_LEN (expected_prefix_, push_remote_address, |
|
53 strlen (expected_prefix_)); |
|
54 TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_PIPES_STATS, event); |
|
55 + TEST_ASSERT_NOT_NULL (queue_stat); |
|
56 TEST_ASSERT_EQUAL_INT (i == 0 ? 0 : send_hwm, queue_stat[0]); |
|
57 TEST_ASSERT_EQUAL_INT (0, queue_stat[1]); |
|
58 free (push_local_address); |
|
59 free (push_remote_address); |
|
60 + free (queue_stat); |
|
61 } |
|
62 |
|
63 // Close client and server |
|
64 diff --git a/tests/testutil_monitoring.cpp b/tests/testutil_monitoring.cpp |
|
65 index 06406270a0..8668caee83 100644 |
|
66 --- a/tests/testutil_monitoring.cpp |
|
67 +++ b/tests/testutil_monitoring.cpp |
|
68 @@ -207,7 +207,7 @@ int expect_monitor_event_multiple (void *server_mon_, |
|
69 } |
|
70 |
|
71 static int64_t get_monitor_event_internal_v2 (void *monitor_, |
|
72 - uint64_t *value_, |
|
73 + uint64_t **value_, |
|
74 char **local_address_, |
|
75 char **remote_address_, |
|
76 int recv_flag_) |
|
77 @@ -239,6 +239,12 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_, |
|
78 memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count)); |
|
79 zmq_msg_close (&msg); |
|
80 |
|
81 + if (value_) { |
|
82 + *value_ = |
|
83 + (uint64_t *) malloc ((size_t) value_count * sizeof (uint64_t)); |
|
84 + TEST_ASSERT_NOT_NULL (*value_); |
|
85 + } |
|
86 + |
|
87 for (uint64_t i = 0; i < value_count; ++i) { |
|
88 // Subsequent frames in message contain event values |
|
89 zmq_msg_init (&msg); |
|
90 @@ -249,8 +255,8 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_, |
|
91 TEST_ASSERT_TRUE (zmq_msg_more (&msg)); |
|
92 TEST_ASSERT_EQUAL_UINT (sizeof (uint64_t), zmq_msg_size (&msg)); |
|
93 |
|
94 - if (value_ && value_ + i) |
|
95 - memcpy (value_ + i, zmq_msg_data (&msg), sizeof (*value_)); |
|
96 + if (value_ && *value_) |
|
97 + memcpy (&(*value_)[i], zmq_msg_data (&msg), sizeof (uint64_t)); |
|
98 zmq_msg_close (&msg); |
|
99 } |
|
100 |
|
101 @@ -266,7 +272,7 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_, |
|
102 } |
|
103 |
|
104 static int64_t get_monitor_event_with_timeout_v2 (void *monitor_, |
|
105 - uint64_t *value_, |
|
106 + uint64_t **value_, |
|
107 char **local_address_, |
|
108 char **remote_address_, |
|
109 int timeout_) |
|
110 @@ -299,7 +305,7 @@ static int64_t get_monitor_event_with_timeout_v2 (void *monitor_, |
|
111 } |
|
112 |
|
113 int64_t get_monitor_event_v2 (void *monitor_, |
|
114 - uint64_t *value_, |
|
115 + uint64_t **value_, |
|
116 char **local_address_, |
|
117 char **remote_address_) |
|
118 { |
|
119 diff --git a/tests/testutil_monitoring.hpp b/tests/testutil_monitoring.hpp |
|
120 index a69db29015..eb6817d3c1 100644 |
|
121 --- a/tests/testutil_monitoring.hpp |
|
122 +++ b/tests/testutil_monitoring.hpp |
|
123 @@ -67,7 +67,7 @@ int expect_monitor_event_multiple (void *server_mon_, |
|
124 bool optional_ = false); |
|
125 |
|
126 int64_t get_monitor_event_v2 (void *monitor_, |
|
127 - uint64_t *value_, |
|
128 + uint64_t **value_, |
|
129 char **local_address_, |
|
130 char **remote_address_); |
|
131 |
|
132 |