mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 18:40:27 +01:00
Problem: use of C-style casts
Solution: use static_cast/reinterpret_cast instead
This commit is contained in:
parent
a83c57d0bb
commit
cd954e207d
@ -118,7 +118,8 @@ zmq::session_base_t::session_base_t (class io_thread_t *io_thread_,
|
||||
_wss_hostname (NULL)
|
||||
{
|
||||
if (options_.wss_hostname.length () > 0) {
|
||||
_wss_hostname = (char *) malloc (options_.wss_hostname.length () + 1);
|
||||
_wss_hostname =
|
||||
static_cast<char *> (malloc (options_.wss_hostname.length () + 1));
|
||||
assert (_wss_hostname);
|
||||
strcpy (_wss_hostname, options_.wss_hostname.c_str ());
|
||||
}
|
||||
|
@ -1777,98 +1777,98 @@ int zmq::socket_base_t::monitor (const char *endpoint_,
|
||||
void zmq::socket_base_t::event_connected (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, zmq::fd_t fd_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) fd_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (fd_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_CONNECTED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_connect_delayed (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_CONNECT_DELAYED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_connect_retried (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int interval_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) interval_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (interval_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_CONNECT_RETRIED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_listening (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, zmq::fd_t fd_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) fd_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (fd_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_LISTENING);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_bind_failed (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_BIND_FAILED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_accepted (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, zmq::fd_t fd_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) fd_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (fd_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_ACCEPTED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_accept_failed (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_ACCEPT_FAILED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_closed (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, zmq::fd_t fd_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) fd_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (fd_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_CLOSED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_close_failed (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_CLOSE_FAILED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_disconnected (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, zmq::fd_t fd_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) fd_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (fd_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_DISCONNECTED);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_handshake_failed_no_detail (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_handshake_failed_protocol (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_handshake_failed_auth (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_HANDSHAKE_FAILED_AUTH);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::event_handshake_succeeded (
|
||||
const endpoint_uri_pair_t &endpoint_uri_pair_, int err_)
|
||||
{
|
||||
uint64_t values[1] = {(uint64_t) err_};
|
||||
uint64_t values[1] = {static_cast<uint64_t> (err_)};
|
||||
event (endpoint_uri_pair_, values, 1, ZMQ_EVENT_HANDSHAKE_SUCCEEDED);
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ const sockaddr *zmq::tipc_address_t::addr () const
|
||||
|
||||
socklen_t zmq::tipc_address_t::addrlen () const
|
||||
{
|
||||
return (socklen_t) sizeof address;
|
||||
return static_cast<socklen_t> (sizeof address);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -153,7 +153,8 @@ zmq::fd_t zmq::tipc_connecter_t::connect ()
|
||||
#else
|
||||
socklen_t len = sizeof (err);
|
||||
#endif
|
||||
int rc = getsockopt (_s, SOL_SOCKET, SO_ERROR, (char *) &err, &len);
|
||||
int rc = getsockopt (_s, SOL_SOCKET, SO_ERROR,
|
||||
reinterpret_cast<char *> (&err), &len);
|
||||
if (rc == -1)
|
||||
err = errno;
|
||||
if (err != 0) {
|
||||
|
@ -111,7 +111,8 @@ int zmq::tipc_listener_t::set_local_address (const char *addr_)
|
||||
if (sl == 0)
|
||||
goto error;
|
||||
|
||||
_address = tipc_address_t ((struct sockaddr *) &ss, sl);
|
||||
_address =
|
||||
tipc_address_t (reinterpret_cast<struct sockaddr *> (&ss), sl);
|
||||
}
|
||||
|
||||
|
||||
@ -156,7 +157,8 @@ zmq::fd_t zmq::tipc_listener_t::accept ()
|
||||
#ifdef ZMQ_HAVE_VXWORKS
|
||||
fd_t sock = ::accept (_s, (struct sockaddr *) &ss, (int *) &ss_len);
|
||||
#else
|
||||
fd_t sock = ::accept (_s, (struct sockaddr *) &ss, &ss_len);
|
||||
fd_t sock =
|
||||
::accept (_s, reinterpret_cast<struct sockaddr *> (&ss), &ss_len);
|
||||
#endif
|
||||
if (sock == -1) {
|
||||
errno_assert (errno == EAGAIN || errno == EWOULDBLOCK
|
||||
|
@ -69,7 +69,7 @@ int zmq::ws_decoder_t::opcode_ready (unsigned char const *)
|
||||
if (!final)
|
||||
return -1; // non final messages are not supported
|
||||
|
||||
_opcode = (zmq::ws_protocol_t::opcode_t) (_tmpbuf[0] & 0xF);
|
||||
_opcode = static_cast<zmq::ws_protocol_t::opcode_t> (_tmpbuf[0] & 0xF);
|
||||
|
||||
_msg_flags = 0;
|
||||
|
||||
@ -101,7 +101,7 @@ int zmq::ws_decoder_t::size_first_byte_ready (unsigned char const *read_from_)
|
||||
if (is_masked != _must_mask) // wrong mask value
|
||||
return -1;
|
||||
|
||||
_size = (uint64_t) (_tmpbuf[0] & 0x7F);
|
||||
_size = static_cast<uint64_t> (_tmpbuf[0] & 0x7F);
|
||||
|
||||
if (_size < 126) {
|
||||
if (_must_mask)
|
||||
@ -260,7 +260,8 @@ int zmq::ws_decoder_t::message_ready (unsigned char const *)
|
||||
if (_must_mask) {
|
||||
int mask_index = _opcode == ws_protocol_t::opcode_binary ? 1 : 0;
|
||||
|
||||
unsigned char *data = (unsigned char *) _in_progress.data ();
|
||||
unsigned char *data =
|
||||
static_cast<unsigned char *> (_in_progress.data ());
|
||||
for (size_t i = 0; i < _size; ++i, mask_index++)
|
||||
data[i] = data[i] ^ _mask[mask_index % 4];
|
||||
}
|
||||
|
@ -63,11 +63,11 @@ void zmq::ws_encoder_t::message_ready ()
|
||||
size++; // TODO: check if binary
|
||||
|
||||
if (size <= 125)
|
||||
_tmp_buf[offset++] |= (unsigned char) (size & 127);
|
||||
_tmp_buf[offset++] |= static_cast<unsigned char> (size & 127);
|
||||
else if (size <= 0xFFFF) {
|
||||
_tmp_buf[offset++] |= 126;
|
||||
_tmp_buf[offset++] = (unsigned char) ((size >> 8) & 0xFF);
|
||||
_tmp_buf[offset++] = (unsigned char) (size & 0xFF);
|
||||
_tmp_buf[offset++] = static_cast<unsigned char> ((size >> 8) & 0xFF);
|
||||
_tmp_buf[offset++] = static_cast<unsigned char> (size & 0xFF);
|
||||
} else {
|
||||
_tmp_buf[offset++] |= 127;
|
||||
put_uint64 (_tmp_buf + offset, size);
|
||||
@ -106,8 +106,10 @@ void zmq::ws_encoder_t::size_ready ()
|
||||
_masked_msg.init_size (size);
|
||||
|
||||
int mask_index = 1; // TODO: check if binary message
|
||||
unsigned char *dest = (unsigned char *) _masked_msg.data ();
|
||||
unsigned char *src = (unsigned char *) in_progress ()->data ();
|
||||
unsigned char *dest =
|
||||
static_cast<unsigned char *> (_masked_msg.data ());
|
||||
unsigned char *src =
|
||||
static_cast<unsigned char *> (in_progress ()->data ());
|
||||
for (size_t i = 0; i < in_progress ()->size (); ++i, mask_index++)
|
||||
dest[i] = src[i] ^ _mask[mask_index % 4];
|
||||
|
||||
|
@ -131,7 +131,7 @@ void zmq::ws_engine_t::start_ws_handshake ()
|
||||
assert (false);
|
||||
|
||||
unsigned char nonce[16];
|
||||
int *p = (int *) nonce;
|
||||
int *p = reinterpret_cast<int *> (nonce);
|
||||
|
||||
// The nonce doesn't have to be secure one, it is just use to avoid proxy cache
|
||||
*p = zmq::generate_random ();
|
||||
@ -143,16 +143,16 @@ void zmq::ws_engine_t::start_ws_handshake ()
|
||||
encode_base64 (nonce, 16, _websocket_key, MAX_HEADER_VALUE_LENGTH);
|
||||
assert (size > 0);
|
||||
|
||||
size = snprintf ((char *) _write_buffer, WS_BUFFER_SIZE,
|
||||
"GET %s HTTP/1.1\r\n"
|
||||
"Host: %s\r\n"
|
||||
"Upgrade: websocket\r\n"
|
||||
"Connection: Upgrade\r\n"
|
||||
"Sec-WebSocket-Key: %s\r\n"
|
||||
"Sec-WebSocket-Protocol: %s\r\n"
|
||||
"Sec-WebSocket-Version: 13\r\n\r\n",
|
||||
_address.path (), _address.host (), _websocket_key,
|
||||
protocol);
|
||||
size = snprintf (
|
||||
reinterpret_cast<char *> (_write_buffer), WS_BUFFER_SIZE,
|
||||
"GET %s HTTP/1.1\r\n"
|
||||
"Host: %s\r\n"
|
||||
"Upgrade: websocket\r\n"
|
||||
"Connection: Upgrade\r\n"
|
||||
"Sec-WebSocket-Key: %s\r\n"
|
||||
"Sec-WebSocket-Protocol: %s\r\n"
|
||||
"Sec-WebSocket-Version: 13\r\n\r\n",
|
||||
_address.path (), _address.host (), _websocket_key, protocol);
|
||||
assert (size > 0 && size < WS_BUFFER_SIZE);
|
||||
_outpos = _write_buffer;
|
||||
_outsize = size;
|
||||
@ -278,7 +278,7 @@ bool zmq::ws_engine_t::server_handshake ()
|
||||
_insize = nbytes;
|
||||
|
||||
while (_insize > 0) {
|
||||
char c = (char) *_inpos;
|
||||
char c = static_cast<char> (*_inpos);
|
||||
|
||||
switch (_server_handshake_state) {
|
||||
case handshake_initial:
|
||||
@ -391,7 +391,7 @@ bool zmq::ws_engine_t::server_handshake ()
|
||||
_server_handshake_state = handshake_error;
|
||||
break;
|
||||
default:
|
||||
_header_name[0] = (char) c;
|
||||
_header_name[0] = c;
|
||||
_header_name_position = 1;
|
||||
_server_handshake_state = header_field_name;
|
||||
break;
|
||||
@ -493,7 +493,8 @@ bool zmq::ws_engine_t::server_handshake ()
|
||||
_websocket_accept[accept_key_len] = '\0';
|
||||
|
||||
int written =
|
||||
snprintf ((char *) _write_buffer, WS_BUFFER_SIZE,
|
||||
snprintf (reinterpret_cast<char *> (_write_buffer),
|
||||
WS_BUFFER_SIZE,
|
||||
"HTTP/1.1 101 Switching Protocols\r\n"
|
||||
"Upgrade: websocket\r\n"
|
||||
"Connection: Upgrade\r\n"
|
||||
@ -547,7 +548,7 @@ bool zmq::ws_engine_t::client_handshake ()
|
||||
_insize = nbytes;
|
||||
|
||||
while (_insize > 0) {
|
||||
char c = (char) *_inpos;
|
||||
char c = static_cast<char> (*_inpos);
|
||||
|
||||
switch (_client_handshake_state) {
|
||||
case client_handshake_initial:
|
||||
@ -769,7 +770,7 @@ bool zmq::ws_engine_t::client_handshake ()
|
||||
_client_handshake_state = client_handshake_error;
|
||||
break;
|
||||
default:
|
||||
_header_name[0] = (char) c;
|
||||
_header_name[0] = c;
|
||||
_header_name_position = 1;
|
||||
_client_handshake_state = client_header_field_name;
|
||||
break;
|
||||
|
@ -109,7 +109,7 @@ void test_app_meta_reqrep ()
|
||||
rc = zmq_msg_init_size (&msg, 1);
|
||||
TEST_ASSERT_EQUAL_INT (0, rc);
|
||||
|
||||
char *data = (char *) zmq_msg_data (&msg);
|
||||
char *data = static_cast<char *> (zmq_msg_data (&msg));
|
||||
data[0] = 1;
|
||||
|
||||
rc = zmq_msg_send (&msg, req_sock, 0);
|
||||
@ -123,7 +123,7 @@ void test_app_meta_reqrep ()
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING ("hello", zmq_msg_gets (&msg, "X-hello"));
|
||||
TEST_ASSERT_EQUAL_STRING ("primary", zmq_msg_gets (&msg, "X-connection"));
|
||||
char *bindata = (char *) zmq_msg_gets (&msg, "X-bin");
|
||||
char *bindata = const_cast<char *> (zmq_msg_gets (&msg, "X-bin"));
|
||||
TEST_ASSERT_NOT_NULL (bindata);
|
||||
uint8_t rawdata[4];
|
||||
void *ret = zmq_z85_decode (rawdata, bindata);
|
||||
|
@ -97,7 +97,7 @@ void test_routing_id ()
|
||||
zmq_msg_t msg;
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init_size (&msg, 1));
|
||||
|
||||
char *data = (char *) zmq_msg_data (&msg);
|
||||
char *data = static_cast<char *> (zmq_msg_data (&msg));
|
||||
data[0] = 2;
|
||||
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_set_routing_id (&msg, routing_id));
|
||||
|
@ -124,7 +124,7 @@ struct poller_test_data_t
|
||||
void run_poller (void *data_)
|
||||
{
|
||||
struct poller_test_data_t *poller_test_data =
|
||||
(struct poller_test_data_t *) data_;
|
||||
static_cast<struct poller_test_data_t *> (data_);
|
||||
|
||||
void *socket =
|
||||
zmq_socket (poller_test_data->ctx, poller_test_data->socket_type);
|
||||
|
@ -68,7 +68,7 @@ void test_disconnect_inproc ()
|
||||
zmq_msg_t msg;
|
||||
zmq_msg_init (&msg);
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, pub_socket, 0));
|
||||
char *buffer = (char *) zmq_msg_data (&msg);
|
||||
char *buffer = static_cast<char *> (zmq_msg_data (&msg));
|
||||
|
||||
if (buffer[0] == 0) {
|
||||
TEST_ASSERT_TRUE (isSubscribed);
|
||||
|
@ -60,8 +60,8 @@ static int get_monitor_event (void *monitor_)
|
||||
}
|
||||
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
||||
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint16_t event = *(uint16_t *) (data);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
uint16_t event = *reinterpret_cast<uint16_t *> (data);
|
||||
|
||||
// Second frame in message contains event address
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
|
||||
|
@ -236,10 +236,8 @@ void test_simultaneous_connect_bind_threads ()
|
||||
|
||||
// Spawn all threads as simultaneously as possible
|
||||
for (unsigned int i = 0; i < no_of_times; ++i) {
|
||||
threads[i * 2 + 0] =
|
||||
zmq_threadstart (&simult_conn, (void *) thr_args[i]);
|
||||
threads[i * 2 + 1] =
|
||||
zmq_threadstart (&simult_bind, (void *) thr_args[i]);
|
||||
threads[i * 2 + 0] = zmq_threadstart (&simult_conn, thr_args[i]);
|
||||
threads[i * 2 + 1] = zmq_threadstart (&simult_bind, thr_args[i]);
|
||||
}
|
||||
|
||||
// Close all threads
|
||||
|
@ -52,8 +52,8 @@ static int get_monitor_event (void *monitor_)
|
||||
}
|
||||
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
||||
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint16_t event = *(uint16_t *) (data);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
uint16_t event = *reinterpret_cast<uint16_t *> (data);
|
||||
|
||||
// Second frame in message contains event address
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
|
||||
|
@ -80,7 +80,7 @@ void *g_workers_pkts_out = NULL;
|
||||
|
||||
static void client_task (void *db_)
|
||||
{
|
||||
struct thread_data *databag = (struct thread_data *) db_;
|
||||
struct thread_data *databag = static_cast<struct thread_data *> (db_);
|
||||
// Endpoint socket gets random port to avoid test failing when port in use
|
||||
void *endpoint = zmq_socket (get_test_context (), ZMQ_PAIR);
|
||||
TEST_ASSERT_NOT_NULL (endpoint);
|
||||
@ -373,16 +373,16 @@ void check_proxy_stats (void *control_proxy_)
|
||||
if (is_verbose) {
|
||||
printf (
|
||||
"frontend: pkts_in=%lu bytes_in=%lu pkts_out=%lu bytes_out=%lu\n",
|
||||
(unsigned long int) total_stats.frontend.msg_in,
|
||||
(unsigned long int) total_stats.frontend.bytes_in,
|
||||
(unsigned long int) total_stats.frontend.msg_out,
|
||||
(unsigned long int) total_stats.frontend.bytes_out);
|
||||
static_cast<unsigned long int> (total_stats.frontend.msg_in),
|
||||
static_cast<unsigned long int> (total_stats.frontend.bytes_in),
|
||||
static_cast<unsigned long int> (total_stats.frontend.msg_out),
|
||||
static_cast<unsigned long int> (total_stats.frontend.bytes_out));
|
||||
printf (
|
||||
"backend: pkts_in=%lu bytes_in=%lu pkts_out=%lu bytes_out=%lu\n",
|
||||
(unsigned long int) total_stats.backend.msg_in,
|
||||
(unsigned long int) total_stats.backend.bytes_in,
|
||||
(unsigned long int) total_stats.backend.msg_out,
|
||||
(unsigned long int) total_stats.backend.bytes_out);
|
||||
static_cast<unsigned long int> (total_stats.backend.msg_in),
|
||||
static_cast<unsigned long int> (total_stats.backend.bytes_in),
|
||||
static_cast<unsigned long int> (total_stats.backend.msg_out),
|
||||
static_cast<unsigned long int> (total_stats.backend.bytes_out));
|
||||
|
||||
printf ("clients sent out %d requests\n",
|
||||
zmq_atomic_counter_value (g_clients_pkts_out));
|
||||
|
@ -83,7 +83,7 @@ static void lower_hwm (void *skt_)
|
||||
|
||||
static void publisher_thread_main (void *pvoid_)
|
||||
{
|
||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||
proxy_hwm_cfg_t *cfg = static_cast<proxy_hwm_cfg_t *> (pvoid_);
|
||||
|
||||
void *pubsocket = zmq_socket (cfg->context, ZMQ_XPUB);
|
||||
assert (pubsocket);
|
||||
@ -138,7 +138,7 @@ static void publisher_thread_main (void *pvoid_)
|
||||
|
||||
static void subscriber_thread_main (void *pvoid_)
|
||||
{
|
||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||
proxy_hwm_cfg_t *cfg = static_cast<proxy_hwm_cfg_t *> (pvoid_);
|
||||
|
||||
void *subsocket = zmq_socket (cfg->context, ZMQ_SUB);
|
||||
assert (subsocket);
|
||||
@ -266,7 +266,7 @@ bool check_proxy_stats (void *control_proxy_)
|
||||
|
||||
static void proxy_stats_asker_thread_main (void *pvoid_)
|
||||
{
|
||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||
proxy_hwm_cfg_t *cfg = static_cast<proxy_hwm_cfg_t *> (pvoid_);
|
||||
|
||||
|
||||
// CONTROL REQ
|
||||
@ -318,7 +318,7 @@ static void proxy_stats_asker_thread_main (void *pvoid_)
|
||||
|
||||
static void proxy_thread_main (void *pvoid_)
|
||||
{
|
||||
proxy_hwm_cfg_t *cfg = (proxy_hwm_cfg_t *) pvoid_;
|
||||
proxy_hwm_cfg_t *cfg = static_cast<proxy_hwm_cfg_t *> (pvoid_);
|
||||
int rc;
|
||||
|
||||
|
||||
|
@ -241,7 +241,8 @@ fd_t connect_vanilla_socket (char *my_endpoint_)
|
||||
#endif
|
||||
|
||||
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
rc = connect (s, (struct sockaddr *) &ip4addr, sizeof (ip4addr));
|
||||
rc = connect (s, reinterpret_cast<struct sockaddr *> (&ip4addr),
|
||||
sizeof (ip4addr));
|
||||
TEST_ASSERT_GREATER_THAN_INT (-1, rc);
|
||||
return s;
|
||||
}
|
||||
@ -348,7 +349,7 @@ template <size_t N> void send_command (fd_t s_, char (&command_)[N])
|
||||
} else {
|
||||
send (s_, "\x06");
|
||||
uint64_t len = host_to_network (N);
|
||||
send_all (s_, (char *) &len, 8);
|
||||
send_all (s_, reinterpret_cast<char *> (&len), 8);
|
||||
}
|
||||
send_all (s_, command_, N);
|
||||
}
|
||||
@ -411,7 +412,7 @@ void recv_all (fd_t fd_, uint8_t *data_, socket_size_t len_)
|
||||
{
|
||||
socket_size_t received = 0;
|
||||
while (received < len_) {
|
||||
int res = recv (fd_, (char *) data_, len_, 0);
|
||||
int res = recv (fd_, reinterpret_cast<char *> (data_), len_, 0);
|
||||
TEST_ASSERT_GREATER_THAN_INT (0, res);
|
||||
|
||||
data_ += res;
|
||||
|
@ -190,10 +190,10 @@ static int get_monitor_event (void *monitor_, int *value_, char **address_)
|
||||
return -1; // Interruped, presumably
|
||||
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
||||
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint16_t event = *(uint16_t *) (data);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
uint16_t event = *reinterpret_cast<uint16_t *> (data);
|
||||
if (value_)
|
||||
*value_ = *(uint32_t *) (data + 2);
|
||||
*value_ = *reinterpret_cast<uint32_t *> (data + 2);
|
||||
zmq_msg_close (&msg);
|
||||
|
||||
// Second frame in message contains event address
|
||||
@ -203,9 +203,9 @@ static int get_monitor_event (void *monitor_, int *value_, char **address_)
|
||||
TEST_ASSERT_FALSE (zmq_msg_more (&msg));
|
||||
|
||||
if (address_) {
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*address_ = (char *) malloc (size + 1);
|
||||
*address_ = static_cast<char *> (malloc (size + 1));
|
||||
memcpy (*address_, data, size);
|
||||
*address_[size] = 0;
|
||||
}
|
||||
@ -302,7 +302,8 @@ void test_vanilla_socket ()
|
||||
#endif
|
||||
|
||||
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
rc = connect (s, (struct sockaddr *) &ip4addr, sizeof (ip4addr));
|
||||
rc = connect (s, reinterpret_cast<struct sockaddr *> (&ip4addr),
|
||||
sizeof (ip4addr));
|
||||
TEST_ASSERT_GREATER_THAN (-1, rc);
|
||||
// send anonymous ZMTP/1.0 greeting
|
||||
send (s, "\x01\x00", 2, 0);
|
||||
|
@ -185,7 +185,8 @@ void test_vanilla_socket ()
|
||||
#endif
|
||||
|
||||
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
rc = connect (s, (struct sockaddr *) &ip4addr, sizeof ip4addr);
|
||||
rc = connect (s, reinterpret_cast<struct sockaddr *> (&ip4addr),
|
||||
sizeof ip4addr);
|
||||
TEST_ASSERT_GREATER_THAN_INT (-1, rc);
|
||||
// send anonymous ZMTP/1.0 greeting
|
||||
send (s, "\x01\x00", 2, 0);
|
||||
|
@ -211,7 +211,8 @@ void test_plain_vanilla_socket ()
|
||||
#endif
|
||||
|
||||
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
rc = connect (s, (struct sockaddr *) &ip4addr, sizeof (ip4addr));
|
||||
rc = connect (s, reinterpret_cast<struct sockaddr *> (&ip4addr),
|
||||
sizeof (ip4addr));
|
||||
TEST_ASSERT_GREATER_THAN_INT (-1, rc);
|
||||
// send anonymous ZMTP/1.0 greeting
|
||||
send (s, "\x01\x00", 2, 0);
|
||||
|
@ -130,7 +130,7 @@ void test_pull_fair_queue_in (const char *bind_address_)
|
||||
for (size_t peer = 0; peer < services; ++peer) {
|
||||
TEST_ASSERT_EQUAL_INT (
|
||||
2, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, pull, 0)));
|
||||
const char *str = (const char *) zmq_msg_data (&msg);
|
||||
const char *str = static_cast<const char *> (zmq_msg_data (&msg));
|
||||
first_half -= str[0];
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT (0, first_half);
|
||||
@ -139,7 +139,7 @@ void test_pull_fair_queue_in (const char *bind_address_)
|
||||
for (size_t peer = 0; peer < services; ++peer) {
|
||||
TEST_ASSERT_EQUAL_INT (
|
||||
2, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, pull, 0)));
|
||||
const char *str = (const char *) zmq_msg_data (&msg);
|
||||
const char *str = static_cast<const char *> (zmq_msg_data (&msg));
|
||||
second_half -= str[0];
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT (0, second_half);
|
||||
|
@ -168,7 +168,8 @@ void test_stream_disconnect ()
|
||||
zmq_msg_recv (&data_frame, sockets[SERVER], 0));
|
||||
|
||||
// Make sure payload matches what we expect.
|
||||
const char *const data = (const char *) zmq_msg_data (&data_frame);
|
||||
const char *const data =
|
||||
static_cast<const char *> (zmq_msg_data (&data_frame));
|
||||
const size_t size = zmq_msg_size (&data_frame);
|
||||
// 0-length frame is a disconnection notification. The server
|
||||
// should receive it as the last step in the dialogue.
|
||||
@ -222,7 +223,8 @@ void test_stream_disconnect ()
|
||||
TEST_ASSERT_GREATER_THAN_INT (0, zmq_msg_size (&data_frame));
|
||||
|
||||
// Make sure payload matches what we expect.
|
||||
const char *const data = (const char *) zmq_msg_data (&data_frame);
|
||||
const char *const data =
|
||||
static_cast<const char *> (zmq_msg_data (&data_frame));
|
||||
const size_t size = zmq_msg_size (&data_frame);
|
||||
TEST_ASSERT_EQUAL_INT (strlen (dialog[step].text), size);
|
||||
TEST_ASSERT_EQUAL_STRING_LEN (dialog[step].text, data, size);
|
||||
|
@ -48,10 +48,10 @@ static int get_monitor_event (void *monitor_, int *value_, char **address_)
|
||||
return -1; // Interruped, presumably
|
||||
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
||||
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint16_t event = *(uint16_t *) (data);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
uint16_t event = *reinterpret_cast<uint16_t *> (data);
|
||||
if (value_)
|
||||
*value_ = *(uint32_t *) (data + 2);
|
||||
*value_ = *reinterpret_cast<uint32_t *> (data + 2);
|
||||
|
||||
// Second frame in message contains event address
|
||||
zmq_msg_init (&msg);
|
||||
@ -60,9 +60,9 @@ static int get_monitor_event (void *monitor_, int *value_, char **address_)
|
||||
TEST_ASSERT_TRUE (!zmq_msg_more (&msg));
|
||||
|
||||
if (address_) {
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*address_ = (char *) malloc (size + 1);
|
||||
*address_ = static_cast<char *> (malloc (size + 1));
|
||||
memcpy (*address_, data, size);
|
||||
*address_[size] = 0;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void tearDown ()
|
||||
void handler (int timer_id_, void *arg_)
|
||||
{
|
||||
(void) timer_id_; // Stop 'unused' compiler warnings
|
||||
*((bool *) arg_) = true;
|
||||
*(static_cast<bool *> (arg_)) = true;
|
||||
}
|
||||
|
||||
int sleep_and_execute (void *timers_)
|
||||
|
@ -119,7 +119,7 @@ void test_client_server (pre_allocate_sock_fun_t pre_allocate_sock_fun_)
|
||||
zmq_msg_t msg;
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init_size (&msg, 1));
|
||||
|
||||
char *data = (char *) zmq_msg_data (&msg);
|
||||
char *data = static_cast<char *> (zmq_msg_data (&msg));
|
||||
data[0] = 1;
|
||||
|
||||
int rc = zmq_msg_send (&msg, sc, ZMQ_SNDMORE);
|
||||
@ -141,7 +141,7 @@ void test_client_server (pre_allocate_sock_fun_t pre_allocate_sock_fun_)
|
||||
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init_size (&msg, 1));
|
||||
|
||||
data = (char *) zmq_msg_data (&msg);
|
||||
data = static_cast<char *> (zmq_msg_data (&msg));
|
||||
data[0] = 2;
|
||||
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_set_routing_id (&msg, routing_id));
|
||||
@ -227,7 +227,8 @@ void pre_allocate_sock_ipc_int (void *zmq_socket_, const char *path_)
|
||||
// TODO check return value of unlink
|
||||
unlink (path_);
|
||||
|
||||
setup_socket_and_set_fd (zmq_socket_, AF_UNIX, 0, (struct sockaddr *) &addr,
|
||||
setup_socket_and_set_fd (zmq_socket_, AF_UNIX, 0,
|
||||
reinterpret_cast<struct sockaddr *> (&addr),
|
||||
sizeof (struct sockaddr_un));
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,8 @@ int is_ipv6_available ()
|
||||
if (rc != 0)
|
||||
ipv6 = 0;
|
||||
else {
|
||||
rc = bind (fd, (struct sockaddr *) &test_addr, sizeof (test_addr));
|
||||
rc = bind (fd, reinterpret_cast<struct sockaddr *> (&test_addr),
|
||||
sizeof (test_addr));
|
||||
if (rc != 0)
|
||||
ipv6 = 0;
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ static int get_monitor_event_internal (void *monitor_,
|
||||
}
|
||||
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
||||
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint16_t event = *(uint16_t *) (data);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
uint16_t event = *reinterpret_cast<uint16_t *> (data);
|
||||
if (value_)
|
||||
memcpy (value_, data + 2, sizeof (uint32_t));
|
||||
|
||||
@ -61,9 +61,9 @@ static int get_monitor_event_internal (void *monitor_,
|
||||
TEST_ASSERT_FALSE (zmq_msg_more (&msg));
|
||||
|
||||
if (address_) {
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*address_ = (char *) malloc (size + 1);
|
||||
*address_ = static_cast<char *> (malloc (size + 1));
|
||||
memcpy (*address_, data, size);
|
||||
(*address_)[size] = 0;
|
||||
}
|
||||
@ -246,9 +246,9 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
||||
TEST_ASSERT_TRUE (zmq_msg_more (&msg));
|
||||
|
||||
if (local_address_) {
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*local_address_ = (char *) malloc (size + 1);
|
||||
*local_address_ = static_cast<char *> (malloc (size + 1));
|
||||
memcpy (*local_address_, data, size);
|
||||
(*local_address_)[size] = 0;
|
||||
}
|
||||
@ -260,9 +260,9 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
||||
TEST_ASSERT_TRUE (!zmq_msg_more (&msg));
|
||||
|
||||
if (remote_address_) {
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*remote_address_ = (char *) malloc (size + 1);
|
||||
*remote_address_ = static_cast<char *> (malloc (size + 1));
|
||||
memcpy (*remote_address_, data, size);
|
||||
(*remote_address_)[size] = 0;
|
||||
}
|
||||
@ -328,7 +328,8 @@ void expect_monitor_event_v2 (void *monitor_,
|
||||
if (event != expected_event_) {
|
||||
pos += snprintf (pos, sizeof buf - (pos - buf),
|
||||
"Expected monitor event %llx, but received %llx\n",
|
||||
(long long) expected_event_, (long long) event);
|
||||
static_cast<long long> (expected_event_),
|
||||
static_cast<long long> (event));
|
||||
failed = true;
|
||||
}
|
||||
if (expected_local_address_
|
||||
|
@ -44,7 +44,7 @@ void socket_config_null_server (void *server_, void *server_secret_)
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
||||
server_, ZMQ_ZAP_DOMAIN, test_zap_domain, strlen (test_zap_domain)));
|
||||
#ifdef ZMQ_ZAP_ENFORCE_DOMAIN
|
||||
int required = server_secret_ ? *(int *) server_secret_ : 0;
|
||||
int required = server_secret_ ? *static_cast<int *> (server_secret_) : 0;
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (server_, ZMQ_ZAP_ENFORCE_DOMAIN,
|
||||
&required, sizeof (int)));
|
||||
#else
|
||||
|
@ -165,7 +165,7 @@ static void internal_manage_test_sockets (void *socket_, bool add_)
|
||||
fprintf (stderr,
|
||||
"WARNING: Forced closure of %i sockets, this is an "
|
||||
"implementation error unless the test case failed\n",
|
||||
(int) test_socket_count);
|
||||
static_cast<int> (test_socket_count));
|
||||
test_socket_count = 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ void tearDown ()
|
||||
|
||||
int getlen (const zmq::generic_mtrie_t<int>::prefix_t &data_)
|
||||
{
|
||||
return (int) strlen (reinterpret_cast<const char *> (data_));
|
||||
return static_cast<int> (strlen (reinterpret_cast<const char *> (data_)));
|
||||
}
|
||||
|
||||
void test_create ()
|
||||
@ -303,7 +303,8 @@ void test_add_multiple_reverse ()
|
||||
|
||||
zmq::generic_mtrie_t<int> mtrie;
|
||||
for (int i = 2; i >= 0; --i) {
|
||||
add_indexed_expect_unique (mtrie, pipes, names, (size_t) i);
|
||||
add_indexed_expect_unique (mtrie, pipes, names,
|
||||
static_cast<size_t> (i));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user