mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-19 08:46:44 +01:00
Problem: C-style casts used
Solution: replace by C++-style casts
This commit is contained in:
parent
d002eb5578
commit
4e616f30dd
@ -75,7 +75,7 @@ struct blob_t
|
||||
|
||||
// Creates a blob_t of a given size, with uninitialized content.
|
||||
explicit blob_t (const size_t size) :
|
||||
data_ ((unsigned char *) malloc (size)),
|
||||
data_ (static_cast<unsigned char *> (malloc (size))),
|
||||
size_ (size),
|
||||
owned_ (true)
|
||||
{
|
||||
@ -85,7 +85,7 @@ struct blob_t
|
||||
// Creates a blob_t of a given size, an initializes content by copying
|
||||
// from another buffer.
|
||||
blob_t (const unsigned char *const data, const size_t size) :
|
||||
data_ ((unsigned char *) malloc (size)),
|
||||
data_ (static_cast<unsigned char *> (malloc (size))),
|
||||
size_ (size),
|
||||
owned_ (true)
|
||||
{
|
||||
@ -124,7 +124,7 @@ struct blob_t
|
||||
void set_deep_copy (blob_t const &other)
|
||||
{
|
||||
clear ();
|
||||
data_ = (unsigned char *) malloc (other.size_);
|
||||
data_ = static_cast<unsigned char *> (malloc (other.size_));
|
||||
size_ = other.size_;
|
||||
owned_ = true;
|
||||
memcpy (data_, other.data_, size_);
|
||||
@ -134,7 +134,7 @@ struct blob_t
|
||||
void set (const unsigned char *const data, const size_t size)
|
||||
{
|
||||
clear ();
|
||||
data_ = (unsigned char *) malloc (size);
|
||||
data_ = static_cast<unsigned char *> (malloc (size));
|
||||
size_ = size;
|
||||
owned_ = true;
|
||||
memcpy (data_, data, size_);
|
||||
|
@ -156,7 +156,7 @@ uint64_t zmq::clock_t::now_us ()
|
||||
// Convert the tick number into the number of seconds
|
||||
// since the system was started.
|
||||
double ticks_div = ticksPerSecond.QuadPart / 1000000.0;
|
||||
return (uint64_t) (tick.QuadPart / ticks_div);
|
||||
return static_cast<uint64_t> (tick.QuadPart / ticks_div);
|
||||
|
||||
#elif defined HAVE_CLOCK_GETTIME \
|
||||
&& (defined CLOCK_MONOTONIC || defined ZMQ_HAVE_VXWORKS)
|
||||
|
11
src/ctx.cpp
11
src/ctx.cpp
@ -290,7 +290,8 @@ bool zmq::ctx_t::start ()
|
||||
int ios = io_thread_count;
|
||||
opt_sync.unlock ();
|
||||
slot_count = mazmq + ios + 2;
|
||||
slots = (i_mailbox **) malloc (sizeof (i_mailbox *) * slot_count);
|
||||
slots =
|
||||
static_cast<i_mailbox **> (malloc (sizeof (i_mailbox *) * slot_count));
|
||||
if (!slots) {
|
||||
errno = ENOMEM;
|
||||
goto fail;
|
||||
@ -311,7 +312,8 @@ bool zmq::ctx_t::start ()
|
||||
reaper->start ();
|
||||
|
||||
// Create I/O thread objects and launch them.
|
||||
for (int32_t i = (int32_t) slot_count - 1; i >= (int32_t) 2; i--) {
|
||||
for (int32_t i = static_cast<int32_t> (slot_count) - 1;
|
||||
i >= static_cast<int32_t> (2); i--) {
|
||||
slots[i] = NULL;
|
||||
}
|
||||
|
||||
@ -331,7 +333,8 @@ bool zmq::ctx_t::start ()
|
||||
}
|
||||
|
||||
// In the unused part of the slot array, create a list of empty slots.
|
||||
for (int32_t i = (int32_t) slot_count - 1; i >= (int32_t) ios + 2; i--) {
|
||||
for (int32_t i = static_cast<int32_t> (slot_count) - 1;
|
||||
i >= static_cast<int32_t> (ios) + 2; i--) {
|
||||
empty_slots.push_back (i);
|
||||
}
|
||||
|
||||
@ -377,7 +380,7 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
|
||||
empty_slots.pop_back ();
|
||||
|
||||
// Generate new unique socket ID.
|
||||
int sid = ((int) max_socket_id.add (1)) + 1;
|
||||
int sid = (static_cast<int> (max_socket_id.add (1))) + 1;
|
||||
|
||||
// Create the socket and register its mailbox.
|
||||
socket_base_t *s = socket_base_t::create (type_, this, slot, sid);
|
||||
|
@ -176,7 +176,7 @@ int zmq::curve_client_t::produce_initiate (msg_t *msg_)
|
||||
{
|
||||
const size_t metadata_length = basic_properties_len ();
|
||||
unsigned char *metadata_plaintext =
|
||||
(unsigned char *) malloc (metadata_length);
|
||||
static_cast<unsigned char *> (malloc (metadata_length));
|
||||
alloc_assert (metadata_plaintext);
|
||||
|
||||
add_basic_properties (metadata_plaintext, metadata_length);
|
||||
@ -217,10 +217,11 @@ int zmq::curve_client_t::process_ready (const uint8_t *msg_data,
|
||||
const size_t clen = (msg_size - 14) + crypto_box_BOXZEROBYTES;
|
||||
|
||||
uint8_t ready_nonce[crypto_box_NONCEBYTES];
|
||||
uint8_t *ready_plaintext = (uint8_t *) malloc (crypto_box_ZEROBYTES + clen);
|
||||
uint8_t *ready_plaintext =
|
||||
static_cast<uint8_t *> (malloc (crypto_box_ZEROBYTES + clen));
|
||||
alloc_assert (ready_plaintext);
|
||||
uint8_t *ready_box =
|
||||
(uint8_t *) malloc (crypto_box_BOXZEROBYTES + 16 + clen);
|
||||
static_cast<uint8_t *> (malloc (crypto_box_BOXZEROBYTES + 16 + clen));
|
||||
alloc_assert (ready_box);
|
||||
|
||||
memset (ready_box, 0, crypto_box_BOXZEROBYTES);
|
||||
|
@ -164,11 +164,11 @@ struct curve_client_tools_t
|
||||
return -1;
|
||||
|
||||
uint8_t initiate_nonce[crypto_box_NONCEBYTES];
|
||||
uint8_t *initiate_box =
|
||||
(uint8_t *) malloc (crypto_box_BOXZEROBYTES + 144 + metadata_length);
|
||||
uint8_t *initiate_box = static_cast<uint8_t *> (
|
||||
malloc (crypto_box_BOXZEROBYTES + 144 + metadata_length));
|
||||
alloc_assert (initiate_box);
|
||||
uint8_t *initiate_plaintext =
|
||||
(uint8_t *) malloc (crypto_box_ZEROBYTES + 128 + metadata_length);
|
||||
uint8_t *initiate_plaintext = static_cast<uint8_t *> (
|
||||
malloc (crypto_box_ZEROBYTES + 128 + metadata_length));
|
||||
alloc_assert (initiate_plaintext);
|
||||
|
||||
// Create Box [C + vouch + metadata](C'->S')
|
||||
|
@ -430,7 +430,7 @@ int zmq::curve_server_t::produce_ready (msg_t *msg_)
|
||||
uint8_t ready_nonce[crypto_box_NONCEBYTES];
|
||||
|
||||
uint8_t *ready_plaintext =
|
||||
(uint8_t *) malloc (crypto_box_ZEROBYTES + metadata_length);
|
||||
static_cast<uint8_t *> (malloc (crypto_box_ZEROBYTES + metadata_length));
|
||||
alloc_assert (ready_plaintext);
|
||||
|
||||
// Create Box [metadata](S'->C')
|
||||
@ -443,8 +443,8 @@ int zmq::curve_server_t::produce_ready (msg_t *msg_)
|
||||
memcpy (ready_nonce, "CurveZMQREADY---", 16);
|
||||
put_uint64 (ready_nonce + 16, cn_nonce);
|
||||
|
||||
uint8_t *ready_box =
|
||||
(uint8_t *) malloc (crypto_box_BOXZEROBYTES + 16 + metadata_length);
|
||||
uint8_t *ready_box = static_cast<uint8_t *> (
|
||||
malloc (crypto_box_BOXZEROBYTES + 16 + metadata_length));
|
||||
alloc_assert (ready_box);
|
||||
|
||||
int rc = crypto_box_afternm (ready_box, ready_plaintext, mlen, ready_nonce,
|
||||
|
@ -295,7 +295,8 @@ int zmq::dish_session_t::push_msg (msg_t *msg_)
|
||||
goto has_group;
|
||||
|
||||
// Set the message group
|
||||
rc = msg_->set_group ((char *) group_msg.data (), group_msg.size ());
|
||||
rc = msg_->set_group (static_cast<char *> (group_msg.data ()),
|
||||
group_msg.size ());
|
||||
errno_assert (rc == 0);
|
||||
|
||||
// We set the group, so we don't need the group_msg anymore
|
||||
@ -328,7 +329,7 @@ int zmq::dish_session_t::pull_msg (msg_t *msg_)
|
||||
if (!msg_->is_join () && !msg_->is_leave ())
|
||||
return rc;
|
||||
else {
|
||||
int group_length = (int) strlen (msg_->group ());
|
||||
int group_length = static_cast<int> (strlen (msg_->group ()));
|
||||
|
||||
msg_t command;
|
||||
int offset;
|
||||
@ -346,7 +347,7 @@ int zmq::dish_session_t::pull_msg (msg_t *msg_)
|
||||
}
|
||||
|
||||
command.set_flags (msg_t::command);
|
||||
char *command_data = (char *) command.data ();
|
||||
char *command_data = static_cast<char *> (command.data ());
|
||||
|
||||
// Copy the group
|
||||
memcpy (command_data + offset, msg_->group (), group_length);
|
||||
|
@ -179,7 +179,7 @@ void zmq::dist_t::distribute (msg_t *msg_)
|
||||
|
||||
// Add matching-1 references to the message. We already hold one reference,
|
||||
// that's why -1.
|
||||
msg_->add_refs ((int) matching - 1);
|
||||
msg_->add_refs (static_cast<int> (matching) - 1);
|
||||
|
||||
// Push copy of the message to each matching pipe.
|
||||
int failed = 0;
|
||||
|
@ -60,7 +60,7 @@ template <typename T> class encoder_base_t : public i_encoder
|
||||
next (NULL),
|
||||
new_msg_flag (false),
|
||||
bufsize (bufsize_),
|
||||
buf ((unsigned char *) malloc (bufsize_)),
|
||||
buf (static_cast<unsigned char *> (malloc (bufsize_))),
|
||||
in_progress (NULL)
|
||||
{
|
||||
alloc_assert (buf);
|
||||
@ -146,7 +146,7 @@ template <typename T> class encoder_base_t : public i_encoder
|
||||
step_t next_,
|
||||
bool new_msg_flag_)
|
||||
{
|
||||
write_pos = (unsigned char *) write_pos_;
|
||||
write_pos = static_cast<unsigned char *> (write_pos_);
|
||||
to_write = to_write_;
|
||||
next = next_;
|
||||
new_msg_flag = new_msg_flag_;
|
||||
|
@ -219,8 +219,8 @@ void zmq::win_error (char *buffer_, size_t buffer_size_)
|
||||
#else
|
||||
DWORD rc = FormatMessageA (
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode,
|
||||
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), buffer_, (DWORD) buffer_size_,
|
||||
NULL);
|
||||
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), buffer_,
|
||||
static_cast<DWORD> (buffer_size_), NULL);
|
||||
#endif
|
||||
zmq_assert (rc);
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ void zmq::generic_mtrie_t<T>::rm_helper (value_t *pipe_,
|
||||
// Adjust the buffer.
|
||||
if (buffsize_ >= maxbuffsize_) {
|
||||
maxbuffsize_ = buffsize_ + 256;
|
||||
*buff_ = (unsigned char *) realloc (*buff_, maxbuffsize_);
|
||||
*buff_ = static_cast<unsigned char *> (realloc (*buff_, maxbuffsize_));
|
||||
alloc_assert (*buff_);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
zmq::io_thread_t::io_thread_t (ctx_t *ctx_, uint32_t tid_) :
|
||||
object_t (ctx_, tid_),
|
||||
mailbox_handle ((poller_t::handle_t) NULL)
|
||||
mailbox_handle (static_cast<poller_t::handle_t> (NULL))
|
||||
{
|
||||
poller = new (std::nothrow) poller_t (*ctx_);
|
||||
alloc_assert (poller);
|
||||
|
50
src/ip.cpp
50
src/ip.cpp
@ -135,8 +135,8 @@ void zmq::enable_ipv4_mapping (fd_t s_)
|
||||
#else
|
||||
int flag = 0;
|
||||
#endif
|
||||
int rc =
|
||||
setsockopt (s_, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flag, sizeof (flag));
|
||||
int rc = setsockopt (s_, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
reinterpret_cast<char *> (&flag), sizeof (flag));
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
#else
|
||||
@ -156,7 +156,8 @@ int zmq::get_peer_ip_address (fd_t sockfd_, std::string &ip_addr_)
|
||||
#else
|
||||
socklen_t addrlen = sizeof ss;
|
||||
#endif
|
||||
rc = getpeername (sockfd_, (struct sockaddr *) &ss, &addrlen);
|
||||
rc = getpeername (sockfd_, reinterpret_cast<struct sockaddr *> (&ss),
|
||||
&addrlen);
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
if (rc == SOCKET_ERROR) {
|
||||
const int last_error = WSAGetLastError ();
|
||||
@ -173,8 +174,8 @@ int zmq::get_peer_ip_address (fd_t sockfd_, std::string &ip_addr_)
|
||||
#endif
|
||||
|
||||
char host[NI_MAXHOST];
|
||||
rc = getnameinfo ((struct sockaddr *) &ss, addrlen, host, sizeof host, NULL,
|
||||
0, NI_NUMERICHOST);
|
||||
rc = getnameinfo (reinterpret_cast<struct sockaddr *> (&ss), addrlen, host,
|
||||
sizeof host, NULL, 0, NI_NUMERICHOST);
|
||||
if (rc != 0)
|
||||
return 0;
|
||||
|
||||
@ -187,7 +188,7 @@ int zmq::get_peer_ip_address (fd_t sockfd_, std::string &ip_addr_)
|
||||
} u;
|
||||
|
||||
u.sa_stor = ss;
|
||||
return (int) u.sa.sa_family;
|
||||
return static_cast<int> (u.sa.sa_family);
|
||||
}
|
||||
|
||||
void zmq::set_ip_type_of_service (fd_t s_, int iptos)
|
||||
@ -311,8 +312,9 @@ void zmq::shutdown_network ()
|
||||
static void tune_socket (const SOCKET socket)
|
||||
{
|
||||
BOOL tcp_nodelay = 1;
|
||||
int rc = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY,
|
||||
(char *) &tcp_nodelay, sizeof tcp_nodelay);
|
||||
int rc =
|
||||
setsockopt (socket, IPPROTO_TCP, TCP_NODELAY,
|
||||
reinterpret_cast<char *> (&tcp_nodelay), sizeof tcp_nodelay);
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
|
||||
zmq::tcp_tune_loopback_fast_path (socket);
|
||||
@ -415,7 +417,8 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
// Set SO_REUSEADDR and TCP_NODELAY on listening socket.
|
||||
BOOL so_reuseaddr = 1;
|
||||
int rc = setsockopt (listener, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *) &so_reuseaddr, sizeof so_reuseaddr);
|
||||
reinterpret_cast<char *> (&so_reuseaddr),
|
||||
sizeof so_reuseaddr);
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
|
||||
tune_socket (listener);
|
||||
@ -441,12 +444,14 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
}
|
||||
|
||||
// Bind listening socket to signaler port.
|
||||
rc = bind (listener, (const struct sockaddr *) &addr, sizeof addr);
|
||||
rc = bind (listener, reinterpret_cast<const struct sockaddr *> (&addr),
|
||||
sizeof addr);
|
||||
|
||||
if (rc != SOCKET_ERROR && signaler_port == 0) {
|
||||
// Retrieve ephemeral port number
|
||||
int addrlen = sizeof addr;
|
||||
rc = getsockname (listener, (struct sockaddr *) &addr, &addrlen);
|
||||
rc = getsockname (listener, reinterpret_cast<struct sockaddr *> (&addr),
|
||||
&addrlen);
|
||||
}
|
||||
|
||||
// Listen for incoming connections.
|
||||
@ -455,7 +460,8 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
|
||||
// Connect writer to the listener.
|
||||
if (rc != SOCKET_ERROR)
|
||||
rc = connect (*w_, (struct sockaddr *) &addr, sizeof addr);
|
||||
rc = connect (*w_, reinterpret_cast<struct sockaddr *> (&addr),
|
||||
sizeof addr);
|
||||
|
||||
// Accept connection from writer.
|
||||
if (rc != SOCKET_ERROR)
|
||||
@ -466,22 +472,26 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
if (*r_ != INVALID_SOCKET) {
|
||||
size_t dummy_size =
|
||||
1024 * 1024; // 1M to overload default receive buffer
|
||||
unsigned char *dummy = (unsigned char *) malloc (dummy_size);
|
||||
unsigned char *dummy =
|
||||
static_cast<unsigned char *> (malloc (dummy_size));
|
||||
wsa_assert (dummy);
|
||||
|
||||
int still_to_send = (int) dummy_size;
|
||||
int still_to_recv = (int) dummy_size;
|
||||
int still_to_send = static_cast<int> (dummy_size);
|
||||
int still_to_recv = static_cast<int> (dummy_size);
|
||||
while (still_to_send || still_to_recv) {
|
||||
int nbytes;
|
||||
if (still_to_send > 0) {
|
||||
nbytes =
|
||||
::send (*w_, (char *) (dummy + dummy_size - still_to_send),
|
||||
still_to_send, 0);
|
||||
nbytes = ::send (
|
||||
*w_,
|
||||
reinterpret_cast<char *> (dummy + dummy_size - still_to_send),
|
||||
still_to_send, 0);
|
||||
wsa_assert (nbytes != SOCKET_ERROR);
|
||||
still_to_send -= nbytes;
|
||||
}
|
||||
nbytes = ::recv (*r_, (char *) (dummy + dummy_size - still_to_recv),
|
||||
still_to_recv, 0);
|
||||
nbytes = ::recv (
|
||||
*r_,
|
||||
reinterpret_cast<char *> (dummy + dummy_size - still_to_recv),
|
||||
still_to_recv, 0);
|
||||
wsa_assert (nbytes != SOCKET_ERROR);
|
||||
still_to_recv -= nbytes;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ int zmq::ip_resolver_t::resolve (ip_addr_t *ip_addr_, const char *name_)
|
||||
port = 0;
|
||||
} else {
|
||||
// Parse the port number (0 is not a valid port).
|
||||
port = (uint16_t) atoi (port_str.c_str ());
|
||||
port = static_cast<uint16_t> (atoi (port_str.c_str ()));
|
||||
if (port == 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@ -239,7 +239,7 @@ int zmq::ip_resolver_t::resolve (ip_addr_t *ip_addr_, const char *name_)
|
||||
if (isalpha (if_str.at (0))) {
|
||||
zone_id = do_if_nametoindex (if_str.c_str ());
|
||||
} else {
|
||||
zone_id = (uint32_t) atoi (if_str.c_str ());
|
||||
zone_id = static_cast<uint32_t> (atoi (if_str.c_str ()));
|
||||
}
|
||||
|
||||
if (zone_id == 0) {
|
||||
@ -557,7 +557,7 @@ int zmq::ip_resolver_t::get_interface_name (unsigned long index,
|
||||
#ifdef ZMQ_HAVE_WINDOWS_UWP
|
||||
char *buffer = (char *) malloc (1024);
|
||||
#else
|
||||
char *buffer = (char *) malloc (IF_MAX_STRING_SIZE);
|
||||
char *buffer = static_cast<char *> (malloc (IF_MAX_STRING_SIZE));
|
||||
#endif
|
||||
alloc_assert (buffer);
|
||||
|
||||
@ -582,7 +582,7 @@ int zmq::ip_resolver_t::wchar_to_utf8 (const WCHAR *src, char **dest) const
|
||||
int buffer_len =
|
||||
WideCharToMultiByte (CP_UTF8, 0, src, -1, NULL, 0, NULL, 0);
|
||||
|
||||
char *buffer = (char *) malloc (buffer_len);
|
||||
char *buffer = static_cast<char *> (malloc (buffer_len));
|
||||
alloc_assert (buffer);
|
||||
|
||||
rc = WideCharToMultiByte (CP_UTF8, 0, src, -1, buffer, buffer_len, NULL, 0);
|
||||
@ -608,7 +608,7 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
|
||||
unsigned long out_buf_len = sizeof (IP_ADAPTER_ADDRESSES);
|
||||
|
||||
do {
|
||||
addresses = (IP_ADAPTER_ADDRESSES *) malloc (out_buf_len);
|
||||
addresses = static_cast<IP_ADAPTER_ADDRESSES *> (malloc (out_buf_len));
|
||||
alloc_assert (addresses);
|
||||
|
||||
rc =
|
||||
|
@ -209,14 +209,14 @@ void zmq::mechanism_t::make_command_with_basic_properties (
|
||||
const int rc = msg_->init_size (command_size);
|
||||
errno_assert (rc == 0);
|
||||
|
||||
unsigned char *ptr = (unsigned char *) msg_->data ();
|
||||
unsigned char *ptr = static_cast<unsigned char *> (msg_->data ());
|
||||
|
||||
// Add prefix
|
||||
memcpy (ptr, prefix_, prefix_len_);
|
||||
ptr += prefix_len_;
|
||||
|
||||
add_basic_properties (ptr, command_size
|
||||
- (ptr - (unsigned char *) msg_->data ()));
|
||||
add_basic_properties (
|
||||
ptr, command_size - (ptr - static_cast<unsigned char *> (msg_->data ())));
|
||||
}
|
||||
|
||||
int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
|
||||
@ -251,7 +251,8 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
|
||||
if (name == ZMTP_PROPERTY_IDENTITY && options.recv_routing_id)
|
||||
set_peer_routing_id (value, value_length);
|
||||
else if (name == ZMTP_PROPERTY_SOCKET_TYPE) {
|
||||
if (!check_socket_type ((const char *) value, value_length)) {
|
||||
if (!check_socket_type (reinterpret_cast<const char *> (value),
|
||||
value_length)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ zmq::mechanism_base_t::mechanism_base_t (session_base_t *const session_,
|
||||
|
||||
int zmq::mechanism_base_t::check_basic_command_structure (msg_t *msg_)
|
||||
{
|
||||
if (msg_->size () <= 1 || msg_->size () <= ((uint8_t *) msg_->data ())[0]) {
|
||||
if (msg_->size () <= 1
|
||||
|| msg_->size () <= (static_cast<uint8_t *> (msg_->data ()))[0]) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED);
|
||||
|
@ -88,7 +88,7 @@ int zmq::msg_t::init_size (size_t size_)
|
||||
u.vsm.metadata = NULL;
|
||||
u.vsm.type = type_vsm;
|
||||
u.vsm.flags = 0;
|
||||
u.vsm.size = (unsigned char) size_;
|
||||
u.vsm.size = static_cast<unsigned char> (size_);
|
||||
u.vsm.group[0] = '\0';
|
||||
u.vsm.routing_id = 0;
|
||||
} else {
|
||||
@ -99,7 +99,8 @@ int zmq::msg_t::init_size (size_t size_)
|
||||
u.lmsg.routing_id = 0;
|
||||
u.lmsg.content = NULL;
|
||||
if (sizeof (content_t) + size_ > size_)
|
||||
u.lmsg.content = (content_t *) malloc (sizeof (content_t) + size_);
|
||||
u.lmsg.content =
|
||||
static_cast<content_t *> (malloc (sizeof (content_t) + size_));
|
||||
if (unlikely (!u.lmsg.content)) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
@ -163,7 +164,7 @@ int zmq::msg_t::init_data (void *data_,
|
||||
u.lmsg.flags = 0;
|
||||
u.lmsg.group[0] = '\0';
|
||||
u.lmsg.routing_id = 0;
|
||||
u.lmsg.content = (content_t *) malloc (sizeof (content_t));
|
||||
u.lmsg.content = static_cast<content_t *> (malloc (sizeof (content_t)));
|
||||
if (!u.lmsg.content) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
|
@ -75,7 +75,8 @@ int zmq::do_getsockopt (void *const optval_,
|
||||
}
|
||||
memcpy (optval_, value_, value_len_);
|
||||
// TODO why is the remaining memory null-ed?
|
||||
memset ((char *) optval_ + value_len_, 0, *optvallen_ - value_len_);
|
||||
memset (static_cast<char *> (optval_) + value_len_, 0,
|
||||
*optvallen_ - value_len_);
|
||||
*optvallen_ = value_len_;
|
||||
return 0;
|
||||
}
|
||||
@ -89,7 +90,8 @@ static int do_getsockopt_curve_key (void *const optval_,
|
||||
memcpy (optval_, curve_key_, CURVE_KEYSIZE);
|
||||
return 0;
|
||||
} else if (*optvallen_ == CURVE_KEYSIZE_Z85 + 1) {
|
||||
zmq_z85_encode ((char *) optval_, curve_key_, CURVE_KEYSIZE);
|
||||
zmq_z85_encode (static_cast<char *> (optval_), curve_key_,
|
||||
CURVE_KEYSIZE);
|
||||
return 0;
|
||||
}
|
||||
return sockopt_invalid ();
|
||||
@ -148,7 +150,7 @@ do_setsockopt_string_allow_empty_strict (const void *const optval_,
|
||||
out_value_->clear ();
|
||||
return 0;
|
||||
} else if (optval_ != NULL && optvallen_ > 0 && optvallen_ <= max_len_) {
|
||||
out_value_->assign ((const char *) optval_, optvallen_);
|
||||
out_value_->assign (static_cast<const char *> (optval_), optvallen_);
|
||||
return 0;
|
||||
}
|
||||
return sockopt_invalid ();
|
||||
@ -163,7 +165,7 @@ do_setsockopt_string_allow_empty_relaxed (const void *const optval_,
|
||||
// TODO use either do_setsockopt_string_allow_empty_relaxed or
|
||||
// do_setsockopt_string_allow_empty_strict everywhere
|
||||
if (optvallen_ > 0 && optvallen_ <= max_len_) {
|
||||
out_value_->assign ((const char *) optval_, optvallen_);
|
||||
out_value_->assign (static_cast<const char *> (optval_), optvallen_);
|
||||
return 0;
|
||||
}
|
||||
return sockopt_invalid ();
|
||||
@ -312,7 +314,7 @@ int zmq::options_t::setsockopt (int option_,
|
||||
case ZMQ_ROUTING_ID:
|
||||
// Routing id is any binary string from 1 to 255 octets
|
||||
if (optvallen_ > 0 && optvallen_ < 256) {
|
||||
routing_id_size = (unsigned char) optvallen_;
|
||||
routing_id_size = static_cast<unsigned char> (optvallen_);
|
||||
memcpy (routing_id, optval_, routing_id_size);
|
||||
return 0;
|
||||
}
|
||||
@ -529,7 +531,8 @@ int zmq::options_t::setsockopt (int option_,
|
||||
mechanism = ZMQ_NULL;
|
||||
return 0;
|
||||
} else if (optvallen_ > 0 && optvallen_ < 256 && optval_ != NULL) {
|
||||
plain_username.assign ((const char *) optval_, optvallen_);
|
||||
plain_username.assign (static_cast<const char *> (optval_),
|
||||
optvallen_);
|
||||
as_server = 0;
|
||||
mechanism = ZMQ_PLAIN;
|
||||
return 0;
|
||||
@ -541,7 +544,8 @@ int zmq::options_t::setsockopt (int option_,
|
||||
mechanism = ZMQ_NULL;
|
||||
return 0;
|
||||
} else if (optvallen_ > 0 && optvallen_ < 256 && optval_ != NULL) {
|
||||
plain_password.assign ((const char *) optval_, optvallen_);
|
||||
plain_password.assign (static_cast<const char *> (optval_),
|
||||
optvallen_);
|
||||
as_server = 0;
|
||||
mechanism = ZMQ_PLAIN;
|
||||
return 0;
|
||||
@ -662,7 +666,7 @@ int zmq::options_t::setsockopt (int option_,
|
||||
// Convert this to deciseconds from milliseconds
|
||||
value = value / 100;
|
||||
if (is_int && value >= 0 && value <= 6553) {
|
||||
heartbeat_ttl = (uint16_t) value;
|
||||
heartbeat_ttl = static_cast<uint16_t> (value);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
@ -764,7 +768,7 @@ int zmq::options_t::getsockopt (int option_,
|
||||
size_t *optvallen_) const
|
||||
{
|
||||
bool is_int = (*optvallen_ == sizeof (int));
|
||||
int *value = (int *) optval_;
|
||||
int *value = static_cast<int *> (optval_);
|
||||
#if defined(ZMQ_ACT_MILITANT)
|
||||
bool malformed = true; // Did caller pass a bad option value?
|
||||
#endif
|
||||
@ -786,7 +790,7 @@ int zmq::options_t::getsockopt (int option_,
|
||||
|
||||
case ZMQ_AFFINITY:
|
||||
if (*optvallen_ == sizeof (uint64_t)) {
|
||||
*((uint64_t *) optval_) = affinity;
|
||||
*(static_cast<uint64_t *> (optval_)) = affinity;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
@ -882,7 +886,7 @@ int zmq::options_t::getsockopt (int option_,
|
||||
|
||||
case ZMQ_MAXMSGSIZE:
|
||||
if (*optvallen_ == sizeof (int64_t)) {
|
||||
*((int64_t *) optval_) = maxmsgsize;
|
||||
*(static_cast<int64_t *> (optval_)) = maxmsgsize;
|
||||
*optvallen_ = sizeof (int64_t);
|
||||
return 0;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ void zmq::own_t::process_term (int linger_)
|
||||
// Send termination request to all owned objects.
|
||||
for (owned_t::iterator it = owned.begin (); it != owned.end (); ++it)
|
||||
send_term (*it, linger_);
|
||||
register_term_acks ((int) owned.size ());
|
||||
register_term_acks (static_cast<int> (owned.size ()));
|
||||
owned.clear ();
|
||||
|
||||
// Start termination process and check whether by chance we cannot
|
||||
|
@ -301,7 +301,7 @@ void zmq::pipe_t::process_hiccup (void *pipe_)
|
||||
|
||||
// Plug in the new outpipe.
|
||||
zmq_assert (pipe_);
|
||||
outpipe = (upipe_t *) pipe_;
|
||||
outpipe = static_cast<upipe_t *> (pipe_);
|
||||
out_active = true;
|
||||
|
||||
// If appropriate, notify the user about the hiccup.
|
||||
|
@ -241,7 +241,7 @@ int zmq::plain_server_t::produce_error (msg_t *msg_) const
|
||||
zmq_assert (rc == 0);
|
||||
char *msg_data = static_cast<char *> (msg_->data ());
|
||||
memcpy (msg_data, "\5ERROR", 6);
|
||||
msg_data[6] = (char) status_code.length ();
|
||||
msg_data[6] = static_cast<char> (status_code.length ());
|
||||
memcpy (msg_data + 7, status_code.c_str (), status_code.length ());
|
||||
return 0;
|
||||
}
|
||||
|
@ -132,5 +132,5 @@ void zmq::worker_poller_base_t::check_thread ()
|
||||
|
||||
void zmq::worker_poller_base_t::worker_routine (void *arg_)
|
||||
{
|
||||
((worker_poller_base_t *) arg_)->loop ();
|
||||
(static_cast<worker_poller_base_t *> (arg_))->loop ();
|
||||
}
|
||||
|
@ -215,11 +215,11 @@ int zmq::radio_session_t::push_msg (msg_t *msg_)
|
||||
|
||||
// Set the msg type to either JOIN or LEAVE
|
||||
if (data_size >= 5 && memcmp (command_data, "\4JOIN", 5) == 0) {
|
||||
group_length = (int) data_size - 5;
|
||||
group_length = static_cast<int> (data_size) - 5;
|
||||
group = command_data + 5;
|
||||
rc = join_leave_msg.init_join ();
|
||||
} else if (data_size >= 6 && memcmp (command_data, "\5LEAVE", 6) == 0) {
|
||||
group_length = (int) data_size - 6;
|
||||
group_length = static_cast<int> (data_size) - 6;
|
||||
group = command_data + 6;
|
||||
rc = join_leave_msg.init_leave ();
|
||||
}
|
||||
@ -252,7 +252,7 @@ int zmq::radio_session_t::pull_msg (msg_t *msg_)
|
||||
return rc;
|
||||
|
||||
const char *group = pending_msg.group ();
|
||||
int length = (int) strlen (group);
|
||||
int length = static_cast<int> (strlen (group));
|
||||
|
||||
// First frame is the group
|
||||
rc = msg_->init_size (length);
|
||||
|
@ -49,18 +49,18 @@
|
||||
void zmq::seed_random ()
|
||||
{
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
int pid = (int) GetCurrentProcessId ();
|
||||
int pid = static_cast<int> (GetCurrentProcessId ());
|
||||
#else
|
||||
int pid = (int) getpid ();
|
||||
#endif
|
||||
srand ((unsigned int) (clock_t::now_us () + pid));
|
||||
srand (static_cast<unsigned int> (clock_t::now_us () + pid));
|
||||
}
|
||||
|
||||
uint32_t zmq::generate_random ()
|
||||
{
|
||||
// Compensate for the fact that rand() returns signed integer.
|
||||
uint32_t low = (uint32_t) rand ();
|
||||
uint32_t high = (uint32_t) rand ();
|
||||
uint32_t low = static_cast<uint32_t> (rand ());
|
||||
uint32_t high = static_cast<uint32_t> (rand ());
|
||||
high <<= (sizeof (int) * 8 - 1);
|
||||
return high | low;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ int zmq::raw_decoder_t::decode (const uint8_t *data_,
|
||||
size_t &bytes_used_)
|
||||
{
|
||||
int rc =
|
||||
in_progress.init ((unsigned char *) data_, size_,
|
||||
in_progress.init (const_cast<unsigned char *> (data_), size_,
|
||||
shared_message_memory_allocator::call_dec_ref,
|
||||
allocator.buffer (), allocator.provide_content ());
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
zmq::reaper_t::reaper_t (class ctx_t *ctx_, uint32_t tid_) :
|
||||
object_t (ctx_, tid_),
|
||||
mailbox_handle ((poller_t::handle_t) NULL),
|
||||
mailbox_handle (static_cast<poller_t::handle_t> (NULL)),
|
||||
poller (NULL),
|
||||
sockets (0),
|
||||
terminating (false)
|
||||
|
@ -82,7 +82,8 @@ int zmq::req_t::xsend (msg_t *msg_)
|
||||
request_id++;
|
||||
|
||||
// Copy request id before sending (see issue #1695 for details).
|
||||
uint32_t *request_id_copy = (uint32_t *) malloc (sizeof (uint32_t));
|
||||
uint32_t *request_id_copy =
|
||||
static_cast<uint32_t *> (malloc (sizeof (uint32_t)));
|
||||
zmq_assert (request_id_copy);
|
||||
|
||||
*request_id_copy = request_id;
|
||||
|
@ -212,8 +212,8 @@ int zmq::router_t::xsend (msg_t *msg_)
|
||||
// Find the pipe associated with the routing id stored in the prefix.
|
||||
// If there's no such pipe just silently ignore the message, unless
|
||||
// router_mandatory is set.
|
||||
blob_t routing_id ((unsigned char *) msg_->data (), msg_->size (),
|
||||
zmq::reference_tag_t ());
|
||||
blob_t routing_id (static_cast<unsigned char *> (msg_->data ()),
|
||||
msg_->size (), zmq::reference_tag_t ());
|
||||
outpipes_t::iterator it = outpipes.find (routing_id);
|
||||
|
||||
if (it != outpipes.end ()) {
|
||||
@ -498,7 +498,8 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
|
||||
routing_id.set (buf, sizeof buf);
|
||||
msg.close ();
|
||||
} else {
|
||||
routing_id.set ((unsigned char *) msg.data (), msg.size ());
|
||||
routing_id.set (static_cast<unsigned char *> (msg.data ()),
|
||||
msg.size ());
|
||||
outpipes_t::iterator it = outpipes.find (routing_id);
|
||||
msg.close ();
|
||||
|
||||
|
@ -295,7 +295,7 @@ void zmq::select_t::loop ()
|
||||
{
|
||||
while (true) {
|
||||
// Execute any due timers.
|
||||
int timeout = (int) execute_timers ();
|
||||
int timeout = static_cast<int> (execute_timers ());
|
||||
|
||||
cleanup_retired ();
|
||||
|
||||
@ -316,8 +316,8 @@ void zmq::select_t::loop ()
|
||||
#if defined ZMQ_HAVE_OSX
|
||||
struct timeval tv = {(long) (timeout / 1000), timeout % 1000 * 1000};
|
||||
#else
|
||||
struct timeval tv = {(long) (timeout / 1000),
|
||||
(long) (timeout % 1000 * 1000)};
|
||||
struct timeval tv = {static_cast<long> (timeout / 1000),
|
||||
static_cast<long> (timeout % 1000 * 1000)};
|
||||
#endif
|
||||
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
@ -577,14 +577,15 @@ u_short zmq::select_t::determine_fd_family (fd_t fd_)
|
||||
int type;
|
||||
int type_length = sizeof (int);
|
||||
|
||||
int rc =
|
||||
getsockopt (fd_, SOL_SOCKET, SO_TYPE, (char *) &type, &type_length);
|
||||
int rc = getsockopt (fd_, SOL_SOCKET, SO_TYPE,
|
||||
reinterpret_cast<char *> (&type), &type_length);
|
||||
|
||||
if (rc == 0) {
|
||||
if (type == SOCK_DGRAM)
|
||||
return AF_INET;
|
||||
else {
|
||||
rc = getsockname (fd_, (sockaddr *) &addr, &addr_size);
|
||||
rc = getsockname (fd_, reinterpret_cast<sockaddr *> (&addr),
|
||||
&addr_size);
|
||||
|
||||
// AF_INET and AF_INET6 can be mixed in select
|
||||
// TODO: If proven otherwise, should simply return addr.sa_family
|
||||
|
@ -143,7 +143,8 @@ zmq::signaler_t::~signaler_t ()
|
||||
if (w != retired_fd) {
|
||||
const struct linger so_linger = {1, 0};
|
||||
int rc = setsockopt (w, SOL_SOCKET, SO_LINGER,
|
||||
(const char *) &so_linger, sizeof so_linger);
|
||||
reinterpret_cast<const char *> (&so_linger),
|
||||
sizeof so_linger);
|
||||
// Only check shutdown if WSASTARTUP was previously done
|
||||
if (rc == 0 || WSAGetLastError () != WSANOTINITIALISED) {
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
@ -187,7 +188,8 @@ void zmq::signaler_t::send ()
|
||||
#elif defined ZMQ_HAVE_WINDOWS
|
||||
unsigned char dummy = 0;
|
||||
while (true) {
|
||||
int nbytes = ::send (w, (char *) &dummy, sizeof (dummy), 0);
|
||||
int nbytes =
|
||||
::send (w, reinterpret_cast<char *> (&dummy), sizeof (dummy), 0);
|
||||
wsa_assert (nbytes != SOCKET_ERROR);
|
||||
if (unlikely (nbytes == SOCKET_ERROR))
|
||||
continue;
|
||||
@ -319,7 +321,8 @@ void zmq::signaler_t::recv ()
|
||||
#else
|
||||
unsigned char dummy;
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
int nbytes = ::recv (r, (char *) &dummy, sizeof (dummy), 0);
|
||||
int nbytes =
|
||||
::recv (r, reinterpret_cast<char *> (&dummy), sizeof (dummy), 0);
|
||||
wsa_assert (nbytes != SOCKET_ERROR);
|
||||
#elif defined ZMQ_HAVE_VXWORKS
|
||||
ssize_t nbytes = ::recv (r, (char *) &dummy, sizeof (dummy), 0);
|
||||
@ -359,7 +362,8 @@ int zmq::signaler_t::recv_failable ()
|
||||
#else
|
||||
unsigned char dummy;
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
int nbytes = ::recv (r, (char *) &dummy, sizeof (dummy), 0);
|
||||
int nbytes =
|
||||
::recv (r, reinterpret_cast<char *> (&dummy), sizeof (dummy), 0);
|
||||
if (nbytes == SOCKET_ERROR) {
|
||||
const int last_error = WSAGetLastError ();
|
||||
if (last_error == WSAEWOULDBLOCK) {
|
||||
|
@ -196,7 +196,7 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_,
|
||||
ctx_terminated (false),
|
||||
destroyed (false),
|
||||
poller (NULL),
|
||||
handle ((poller_t::handle_t) NULL),
|
||||
handle (static_cast<poller_t::handle_t> (NULL)),
|
||||
last_tsc (0),
|
||||
ticks (0),
|
||||
rcvmore (false),
|
||||
@ -410,8 +410,8 @@ int zmq::socket_base_t::getsockopt (int option_,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return do_getsockopt<fd_t> (optval_, optvallen_,
|
||||
((mailbox_t *) mailbox)->get_fd ());
|
||||
return do_getsockopt<fd_t> (
|
||||
optval_, optvallen_, (static_cast<mailbox_t *> (mailbox))->get_fd ());
|
||||
}
|
||||
|
||||
if (option_ == ZMQ_EVENTS) {
|
||||
@ -462,7 +462,7 @@ void zmq::socket_base_t::add_signaler (signaler_t *s_)
|
||||
zmq_assert (thread_safe);
|
||||
|
||||
scoped_lock_t sync_lock (sync);
|
||||
((mailbox_safe_t *) mailbox)->add_signaler (s_);
|
||||
(static_cast<mailbox_safe_t *> (mailbox))->add_signaler (s_);
|
||||
}
|
||||
|
||||
void zmq::socket_base_t::remove_signaler (signaler_t *s_)
|
||||
@ -470,7 +470,7 @@ void zmq::socket_base_t::remove_signaler (signaler_t *s_)
|
||||
zmq_assert (thread_safe);
|
||||
|
||||
scoped_lock_t sync_lock (sync);
|
||||
((mailbox_safe_t *) mailbox)->remove_signaler (s_);
|
||||
(static_cast<mailbox_safe_t *> (mailbox))->remove_signaler (s_);
|
||||
}
|
||||
|
||||
int zmq::socket_base_t::bind (const char *addr_)
|
||||
@ -1146,7 +1146,7 @@ int zmq::socket_base_t::send (msg_t *msg_, int flags_)
|
||||
return -1;
|
||||
}
|
||||
if (timeout > 0) {
|
||||
timeout = (int) (end - clock.now_ms ());
|
||||
timeout = static_cast<int> (end - clock.now_ms ());
|
||||
if (timeout <= 0) {
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
@ -1241,7 +1241,7 @@ int zmq::socket_base_t::recv (msg_t *msg_, int flags_)
|
||||
}
|
||||
block = true;
|
||||
if (timeout > 0) {
|
||||
timeout = (int) (end - clock.now_ms ());
|
||||
timeout = static_cast<int> (end - clock.now_ms ());
|
||||
if (timeout <= 0) {
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
@ -1259,7 +1259,7 @@ int zmq::socket_base_t::close ()
|
||||
|
||||
// Remove all existing signalers for thread safe sockets
|
||||
if (thread_safe)
|
||||
((mailbox_safe_t *) mailbox)->clear_signalers ();
|
||||
(static_cast<mailbox_safe_t *> (mailbox))->clear_signalers ();
|
||||
|
||||
// Mark the socket as dead
|
||||
tag = 0xdeadbeef;
|
||||
@ -1291,7 +1291,7 @@ void zmq::socket_base_t::start_reaping (poller_t *poller_)
|
||||
fd_t fd;
|
||||
|
||||
if (!thread_safe)
|
||||
fd = ((mailbox_t *) mailbox)->get_fd ();
|
||||
fd = (static_cast<mailbox_t *> (mailbox))->get_fd ();
|
||||
else {
|
||||
scoped_optional_lock_t sync_lock (thread_safe ? &sync : NULL);
|
||||
|
||||
@ -1300,7 +1300,8 @@ void zmq::socket_base_t::start_reaping (poller_t *poller_)
|
||||
|
||||
// Add signaler to the safe mailbox
|
||||
fd = reaper_signaler->get_fd ();
|
||||
((mailbox_safe_t *) mailbox)->add_signaler (reaper_signaler);
|
||||
(static_cast<mailbox_safe_t *> (mailbox))
|
||||
->add_signaler (reaper_signaler);
|
||||
|
||||
// Send a signal to make sure reaper handle existing commands
|
||||
reaper_signaler->send ();
|
||||
@ -1394,7 +1395,7 @@ void zmq::socket_base_t::process_term (int linger_)
|
||||
// Ask all attached pipes to terminate.
|
||||
for (pipes_t::size_type i = 0; i != pipes.size (); ++i)
|
||||
pipes[i]->terminate (false);
|
||||
register_term_acks ((int) pipes.size ());
|
||||
register_term_acks (static_cast<int> (pipes.size ()));
|
||||
|
||||
// Continue the termination process immediately.
|
||||
own_t::process_term (linger_);
|
||||
@ -1730,10 +1731,10 @@ void zmq::socket_base_t::monitor_event (int event_,
|
||||
// Send event in first frame
|
||||
zmq_msg_t msg;
|
||||
zmq_msg_init_size (&msg, 6);
|
||||
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
|
||||
uint8_t *data = static_cast<uint8_t *> (zmq_msg_data (&msg));
|
||||
// Avoid dereferencing uint32_t on unaligned address
|
||||
uint16_t event = (uint16_t) event_;
|
||||
uint32_t value = (uint32_t) value_;
|
||||
uint16_t event = static_cast<uint16_t> (event_);
|
||||
uint32_t value = static_cast<uint32_t> (value_);
|
||||
memcpy (data + 0, &event, sizeof (event));
|
||||
memcpy (data + 2, &value, sizeof (value));
|
||||
zmq_sendmsg (monitor_socket, &msg, ZMQ_SNDMORE);
|
||||
|
@ -630,8 +630,8 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_,
|
||||
} else if (timeout_ < 0)
|
||||
ptimeout = NULL;
|
||||
else {
|
||||
timeout.tv_sec = (long) ((end - now) / 1000);
|
||||
timeout.tv_usec = (long) ((end - now) % 1000 * 1000);
|
||||
timeout.tv_sec = static_cast<long> ((end - now) / 1000);
|
||||
timeout.tv_usec = static_cast<long> ((end - now) % 1000 * 1000);
|
||||
ptimeout = &timeout;
|
||||
}
|
||||
|
||||
@ -643,14 +643,17 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_,
|
||||
// We just need to copy fd_count elements of fd_array.
|
||||
// We gain huge memcpy() improvement if number of used SOCKETs is much lower than FD_SETSIZE.
|
||||
memcpy (&inset, &pollset_in,
|
||||
(char *) (pollset_in.fd_array + pollset_in.fd_count)
|
||||
- (char *) &pollset_in);
|
||||
reinterpret_cast<char *> (pollset_in.fd_array
|
||||
+ pollset_in.fd_count)
|
||||
- reinterpret_cast<char *> (&pollset_in));
|
||||
memcpy (&outset, &pollset_out,
|
||||
(char *) (pollset_out.fd_array + pollset_out.fd_count)
|
||||
- (char *) &pollset_out);
|
||||
reinterpret_cast<char *> (pollset_out.fd_array
|
||||
+ pollset_out.fd_count)
|
||||
- reinterpret_cast<char *> (&pollset_out));
|
||||
memcpy (&errset, &pollset_err,
|
||||
(char *) (pollset_err.fd_array + pollset_err.fd_count)
|
||||
- (char *) &pollset_err);
|
||||
reinterpret_cast<char *> (pollset_err.fd_array
|
||||
+ pollset_err.fd_count)
|
||||
- reinterpret_cast<char *> (&pollset_err));
|
||||
int rc = select (0, &inset, &outset, &errset, ptimeout);
|
||||
if (unlikely (rc == SOCKET_ERROR)) {
|
||||
errno = zmq::wsa_error_to_errno (WSAGetLastError ());
|
||||
|
@ -64,7 +64,7 @@ void zmq::socks_greeting_encoder_t::encode (const socks_greeting_t &greeting_)
|
||||
uint8_t *ptr = buf;
|
||||
|
||||
*ptr++ = 0x05;
|
||||
*ptr++ = (uint8_t) greeting_.num_methods;
|
||||
*ptr++ = static_cast<uint8_t> (greeting_.num_methods);
|
||||
for (uint8_t i = 0; i < greeting_.num_methods; i++)
|
||||
*ptr++ = greeting_.methods[i];
|
||||
|
||||
@ -179,7 +179,7 @@ void zmq::socks_request_encoder_t::encode (const socks_request_t &req)
|
||||
ptr += 16;
|
||||
} else {
|
||||
*ptr++ = 0x03;
|
||||
*ptr++ = (unsigned char) req.hostname.size ();
|
||||
*ptr++ = static_cast<unsigned char> (req.hostname.size ());
|
||||
memcpy (ptr, req.hostname.c_str (), req.hostname.size ());
|
||||
ptr += req.hostname.size ();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ zmq::socks_connecter_t::socks_connecter_t (class io_thread_t *io_thread_,
|
||||
proxy_addr (proxy_addr_),
|
||||
status (unplugged),
|
||||
s (retired_fd),
|
||||
handle ((handle_t) NULL),
|
||||
handle (static_cast<handle_t> (NULL)),
|
||||
handle_valid (false),
|
||||
delayed_start (delayed_start_),
|
||||
timer_started (false),
|
||||
@ -178,7 +178,7 @@ void zmq::socks_connecter_t::out_event ()
|
||||
|| status == sending_greeting || status == sending_request);
|
||||
|
||||
if (status == waiting_for_proxy_connection) {
|
||||
const int rc = (int) check_proxy_connection ();
|
||||
const int rc = static_cast<int> (check_proxy_connection ());
|
||||
if (rc == -1)
|
||||
error ();
|
||||
else {
|
||||
@ -394,7 +394,8 @@ zmq::fd_t zmq::socks_connecter_t::check_proxy_connection ()
|
||||
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);
|
||||
|
||||
// Assert if the error was caused by 0MQ bug.
|
||||
// Networking problems are OK. No need to assert.
|
||||
@ -468,7 +469,7 @@ int zmq::socks_connecter_t::parse_address (const std::string &address_,
|
||||
// Separate the hostname/port.
|
||||
const std::string port_str = address_.substr (idx + 1);
|
||||
// Parse the port number (0 is not a valid port).
|
||||
port_ = (uint16_t) atoi (port_str.c_str ());
|
||||
port_ = static_cast<uint16_t> (atoi (port_str.c_str ()));
|
||||
if (port_ == 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
|
@ -108,7 +108,8 @@ int zmq::stream_t::xsend (msg_t *msg_)
|
||||
if (msg_->flags () & msg_t::more) {
|
||||
// Find the pipe associated with the routing id stored in the prefix.
|
||||
// If there's no such pipe return an error
|
||||
blob_t routing_id ((unsigned char *) msg_->data (), msg_->size ());
|
||||
blob_t routing_id (static_cast<unsigned char *> (msg_->data ()),
|
||||
msg_->size ());
|
||||
outpipes_t::iterator it = outpipes.find (routing_id);
|
||||
|
||||
if (it != outpipes.end ()) {
|
||||
@ -302,7 +303,8 @@ void zmq::stream_t::identify_peer (pipe_t *pipe_)
|
||||
put_uint32 (buffer + 1, next_integral_routing_id++);
|
||||
routing_id.set (buffer, sizeof buffer);
|
||||
memcpy (options.routing_id, routing_id.data (), routing_id.size ());
|
||||
options.routing_id_size = (unsigned char) routing_id.size ();
|
||||
options.routing_id_size =
|
||||
static_cast<unsigned char> (routing_id.size ());
|
||||
}
|
||||
pipe_->set_router_socket_routing_id (routing_id);
|
||||
// Add the record into output pipes lookup table
|
||||
|
@ -67,7 +67,7 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_,
|
||||
const std::string &endpoint_) :
|
||||
s (fd_),
|
||||
as_server (false),
|
||||
handle ((handle_t) NULL),
|
||||
handle (static_cast<handle_t> (NULL)),
|
||||
inpos (NULL),
|
||||
insize (0),
|
||||
decoder (NULL),
|
||||
@ -378,7 +378,7 @@ void zmq::stream_engine_t::out_event ()
|
||||
outpos = NULL;
|
||||
outsize = encoder->encode (&outpos, 0);
|
||||
|
||||
while (outsize < (size_t) out_batch_size) {
|
||||
while (outsize < static_cast<size_t> (out_batch_size)) {
|
||||
if ((this->*next_msg) (&tx_msg) == -1)
|
||||
break;
|
||||
encoder->load_msg (&tx_msg);
|
||||
@ -753,7 +753,7 @@ int zmq::stream_engine_t::process_routing_id_msg (msg_t *msg_)
|
||||
// ZMQ 2.x peers receive published messages.
|
||||
int rc = subscription.init_size (1);
|
||||
errno_assert (rc == 0);
|
||||
*(unsigned char *) subscription.data () = 1;
|
||||
*static_cast<unsigned char *> (subscription.data ()) = 1;
|
||||
rc = session->push_msg (&subscription);
|
||||
errno_assert (rc == 0);
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ bool zmq::stream_engine_t::init_properties (properties_t &properties)
|
||||
|
||||
// Private property to support deprecated SRCFD
|
||||
std::ostringstream stream;
|
||||
stream << (int) s;
|
||||
stream << static_cast<int> (s);
|
||||
std::string fd_string = stream.str ();
|
||||
properties.ZMQ_MAP_INSERT_OR_EMPLACE (std::string ("__fd"),
|
||||
ZMQ_MOVE (fd_string));
|
||||
@ -1045,7 +1045,8 @@ int zmq::stream_engine_t::produce_ping_message (msg_t *msg_)
|
||||
memcpy (msg_->data (), "\4PING", 5);
|
||||
|
||||
uint16_t ttl_val = htons (options.heartbeat_ttl);
|
||||
memcpy (((uint8_t *) msg_->data ()) + 5, &ttl_val, sizeof (ttl_val));
|
||||
memcpy ((static_cast<uint8_t *> (msg_->data ())) + 5, &ttl_val,
|
||||
sizeof (ttl_val));
|
||||
|
||||
rc = mechanism->encode (msg_);
|
||||
next_msg = &stream_engine_t::pull_and_encode;
|
||||
@ -1074,7 +1075,8 @@ int zmq::stream_engine_t::process_heartbeat_message (msg_t *msg_)
|
||||
if (memcmp (msg_->data (), "\4PING", 5) == 0) {
|
||||
uint16_t remote_heartbeat_ttl;
|
||||
// Get the remote heartbeat TTL to setup the timer
|
||||
memcpy (&remote_heartbeat_ttl, (uint8_t *) msg_->data () + 5, 2);
|
||||
memcpy (&remote_heartbeat_ttl,
|
||||
static_cast<uint8_t *> (msg_->data ()) + 5, 2);
|
||||
remote_heartbeat_ttl = ntohs (remote_heartbeat_ttl);
|
||||
// The remote heartbeat is in 10ths of a second
|
||||
// so we multiply it by 100 to get the timer interval in ms.
|
||||
@ -1096,8 +1098,8 @@ int zmq::stream_engine_t::process_heartbeat_message (msg_t *msg_)
|
||||
pong_msg.set_flags (msg_t::command);
|
||||
memcpy (pong_msg.data (), "\4PONG", 5);
|
||||
if (context_len > 0)
|
||||
memcpy (((uint8_t *) pong_msg.data ()) + 5,
|
||||
((uint8_t *) msg_->data ()) + 7, context_len);
|
||||
memcpy ((static_cast<uint8_t *> (pong_msg.data ())) + 5,
|
||||
(static_cast<uint8_t *> (msg_->data ())) + 7, context_len);
|
||||
|
||||
next_msg = &stream_engine_t::produce_pong_message;
|
||||
out_event ();
|
||||
@ -1108,12 +1110,12 @@ int zmq::stream_engine_t::process_heartbeat_message (msg_t *msg_)
|
||||
|
||||
int zmq::stream_engine_t::process_command_message (msg_t *msg_)
|
||||
{
|
||||
uint8_t cmd_name_size = *((uint8_t *) msg_->data ());
|
||||
uint8_t cmd_name_size = *(static_cast<uint8_t *> (msg_->data ()));
|
||||
// Malformed command
|
||||
if (msg_->size () < cmd_name_size + sizeof (cmd_name_size))
|
||||
return -1;
|
||||
|
||||
uint8_t *cmd_name = ((uint8_t *) msg_->data ()) + 1;
|
||||
uint8_t *cmd_name = (static_cast<uint8_t *> (msg_->data ())) + 1;
|
||||
if (cmd_name_size == 4
|
||||
&& (memcmp (cmd_name, "PING", cmd_name_size) == 0
|
||||
|| memcmp (cmd_name, "PONG", cmd_name_size) == 0))
|
||||
|
@ -58,7 +58,7 @@ int zmq::sub_t::xsetsockopt (int option_,
|
||||
msg_t msg;
|
||||
int rc = msg.init_size (optvallen_ + 1);
|
||||
errno_assert (rc == 0);
|
||||
unsigned char *data = (unsigned char *) msg.data ();
|
||||
unsigned char *data = static_cast<unsigned char *> (msg.data ());
|
||||
*data = (option_ == ZMQ_SUBSCRIBE);
|
||||
// We explicitly allow a NULL subscription with size zero
|
||||
if (optvallen_) {
|
||||
|
27
src/tcp.cpp
27
src/tcp.cpp
@ -54,8 +54,8 @@ int zmq::tune_tcp_socket (fd_t s_)
|
||||
// so using Nagle wouldn't improve throughput in anyway, but it would
|
||||
// hurt latency.
|
||||
int nodelay = 1;
|
||||
int rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELAY, (char *) &nodelay,
|
||||
sizeof (int));
|
||||
int rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELAY,
|
||||
reinterpret_cast<char *> (&nodelay), sizeof (int));
|
||||
tcp_assert_tuning_error (s_, rc);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
@ -72,16 +72,18 @@ int zmq::tune_tcp_socket (fd_t s_)
|
||||
|
||||
int zmq::set_tcp_send_buffer (fd_t sockfd_, int bufsize_)
|
||||
{
|
||||
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_SNDBUF,
|
||||
(char *) &bufsize_, sizeof bufsize_);
|
||||
const int rc =
|
||||
setsockopt (sockfd_, SOL_SOCKET, SO_SNDBUF,
|
||||
reinterpret_cast<char *> (&bufsize_), sizeof bufsize_);
|
||||
tcp_assert_tuning_error (sockfd_, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int zmq::set_tcp_receive_buffer (fd_t sockfd_, int bufsize_)
|
||||
{
|
||||
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_RCVBUF,
|
||||
(char *) &bufsize_, sizeof bufsize_);
|
||||
const int rc =
|
||||
setsockopt (sockfd_, SOL_SOCKET, SO_RCVBUF,
|
||||
reinterpret_cast<char *> (&bufsize_), sizeof bufsize_);
|
||||
tcp_assert_tuning_error (sockfd_, rc);
|
||||
return rc;
|
||||
}
|
||||
@ -184,8 +186,9 @@ int zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
|
||||
#if defined(ZMQ_HAVE_WINDOWS) && defined(TCP_MAXRT)
|
||||
// msdn says it's supported in >= Vista, >= Windows Server 2003
|
||||
timeout_ /= 1000; // in seconds
|
||||
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_MAXRT, (char *) &timeout_,
|
||||
sizeof (timeout_));
|
||||
int rc =
|
||||
setsockopt (sockfd_, IPPROTO_TCP, TCP_MAXRT,
|
||||
reinterpret_cast<char *> (&timeout_), sizeof (timeout_));
|
||||
tcp_assert_tuning_error (sockfd_, rc);
|
||||
return rc;
|
||||
// FIXME: should be ZMQ_HAVE_TCP_USER_TIMEOUT
|
||||
@ -203,7 +206,7 @@ int zmq::tcp_write (fd_t s_, const void *data_, size_t size_)
|
||||
{
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
|
||||
int nbytes = send (s_, (char *) data_, (int) size_, 0);
|
||||
int nbytes = send (s_, (char *) data_, static_cast<int> (size_), 0);
|
||||
|
||||
// If not a single byte can be written to the socket in non-blocking mode
|
||||
// we'll get an error (this may happen during the speculative write).
|
||||
@ -255,7 +258,8 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
|
||||
{
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
|
||||
const int rc = recv (s_, (char *) data_, (int) size_, 0);
|
||||
const int rc =
|
||||
recv (s_, static_cast<char *> (data_), static_cast<int> (size_), 0);
|
||||
|
||||
// If not a single byte can be read from the socket in non-blocking mode
|
||||
// we'll get an error (this may happen during the speculative read).
|
||||
@ -307,7 +311,8 @@ void zmq::tcp_assert_tuning_error (zmq::fd_t s_, int rc_)
|
||||
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);
|
||||
|
||||
// Assert if the error was caused by 0MQ bug.
|
||||
// Networking problems are OK. No need to assert.
|
||||
|
@ -61,10 +61,11 @@ zmq::tcp_address_t::tcp_address_t (const sockaddr *sa, socklen_t sa_len) :
|
||||
|
||||
memset (&address, 0, sizeof (address));
|
||||
memset (&source_address, 0, sizeof (source_address));
|
||||
if (sa->sa_family == AF_INET && sa_len >= (socklen_t) sizeof (address.ipv4))
|
||||
if (sa->sa_family == AF_INET
|
||||
&& sa_len >= static_cast<socklen_t> (sizeof (address.ipv4)))
|
||||
memcpy (&address.ipv4, sa, sizeof (address.ipv4));
|
||||
else if (sa->sa_family == AF_INET6
|
||||
&& sa_len >= (socklen_t) sizeof (address.ipv6))
|
||||
&& sa_len >= static_cast<socklen_t> (sizeof (address.ipv6)))
|
||||
memcpy (&address.ipv6, sa, sizeof (address.ipv6));
|
||||
}
|
||||
|
||||
@ -151,9 +152,9 @@ const sockaddr *zmq::tcp_address_t::addr () const
|
||||
socklen_t zmq::tcp_address_t::addrlen () const
|
||||
{
|
||||
if (address.generic.sa_family == AF_INET6)
|
||||
return (socklen_t) sizeof (address.ipv6);
|
||||
return static_cast<socklen_t> (sizeof (address.ipv6));
|
||||
else
|
||||
return (socklen_t) sizeof (address.ipv4);
|
||||
return static_cast<socklen_t> (sizeof (address.ipv4));
|
||||
}
|
||||
|
||||
const sockaddr *zmq::tcp_address_t::src_addr () const
|
||||
@ -164,9 +165,9 @@ const sockaddr *zmq::tcp_address_t::src_addr () const
|
||||
socklen_t zmq::tcp_address_t::src_addrlen () const
|
||||
{
|
||||
if (address.family () == AF_INET6)
|
||||
return (socklen_t) sizeof (source_address.ipv6);
|
||||
return static_cast<socklen_t> (sizeof (source_address.ipv6));
|
||||
else
|
||||
return (socklen_t) sizeof (source_address.ipv4);
|
||||
return static_cast<socklen_t> (sizeof (source_address.ipv4));
|
||||
}
|
||||
|
||||
bool zmq::tcp_address_t::has_src_addr () const
|
||||
@ -291,15 +292,17 @@ bool zmq::tcp_address_mask_t::match_address (const struct sockaddr *ss,
|
||||
const uint8_t *our_bytes, *their_bytes;
|
||||
if (ss->sa_family == AF_INET6) {
|
||||
zmq_assert (ss_len == sizeof (struct sockaddr_in6));
|
||||
their_bytes = (const uint8_t *) &(
|
||||
((const struct sockaddr_in6 *) ss)->sin6_addr);
|
||||
our_bytes = (const uint8_t *) &address.ipv6.sin6_addr;
|
||||
their_bytes = reinterpret_cast<const uint8_t *> (&(
|
||||
(reinterpret_cast<const struct sockaddr_in6 *> (ss))->sin6_addr));
|
||||
our_bytes =
|
||||
reinterpret_cast<const uint8_t *> (&address.ipv6.sin6_addr);
|
||||
mask = sizeof (struct in6_addr) * 8;
|
||||
} else {
|
||||
zmq_assert (ss_len == sizeof (struct sockaddr_in));
|
||||
their_bytes =
|
||||
(const uint8_t *) &(((const struct sockaddr_in *) ss)->sin_addr);
|
||||
our_bytes = (const uint8_t *) &address.ipv4.sin_addr;
|
||||
their_bytes = reinterpret_cast<const uint8_t *> (
|
||||
&((reinterpret_cast<const struct sockaddr_in *> (ss))->sin_addr));
|
||||
our_bytes =
|
||||
reinterpret_cast<const uint8_t *> (&address.ipv4.sin_addr);
|
||||
mask = sizeof (struct in_addr) * 8;
|
||||
}
|
||||
if (address_mask < mask)
|
||||
|
@ -69,7 +69,7 @@ zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
|
||||
io_object_t (io_thread_),
|
||||
addr (addr_),
|
||||
s (retired_fd),
|
||||
handle ((handle_t) NULL),
|
||||
handle (static_cast<handle_t> (NULL)),
|
||||
delayed_start (delayed_start_),
|
||||
connect_timer_started (false),
|
||||
reconnect_timer_started (false),
|
||||
@ -166,7 +166,7 @@ void zmq::tcp_connecter_t::out_event ()
|
||||
void zmq::tcp_connecter_t::rm_handle ()
|
||||
{
|
||||
rm_fd (handle);
|
||||
handle = (handle_t) NULL;
|
||||
handle = static_cast<handle_t> (NULL);
|
||||
}
|
||||
|
||||
void zmq::tcp_connecter_t::timer_event (int id_)
|
||||
@ -325,8 +325,8 @@ int zmq::tcp_connecter_t::open ()
|
||||
// using the same source port on the client.
|
||||
int flag = 1;
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (const char *) &flag,
|
||||
sizeof (int));
|
||||
rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR,
|
||||
reinterpret_cast<const char *> (&flag), sizeof (int));
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
#elif defined ZMQ_HAVE_VXWORKS
|
||||
rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &flag,
|
||||
@ -383,7 +383,8 @@ zmq::fd_t zmq::tcp_connecter_t::connect ()
|
||||
socklen_t len = sizeof err;
|
||||
#endif
|
||||
|
||||
const int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char *) &err, &len);
|
||||
const int rc = getsockopt (s, SOL_SOCKET, SO_ERROR,
|
||||
reinterpret_cast<char *> (&err), &len);
|
||||
|
||||
// Assert if the error was caused by 0MQ bug.
|
||||
// Networking problems are OK. No need to assert.
|
||||
|
@ -66,7 +66,7 @@ zmq::tcp_listener_t::tcp_listener_t (io_thread_t *io_thread_,
|
||||
own_t (io_thread_, options_),
|
||||
io_object_t (io_thread_),
|
||||
s (retired_fd),
|
||||
handle ((handle_t) NULL),
|
||||
handle (static_cast<handle_t> (NULL)),
|
||||
socket (socket_)
|
||||
{
|
||||
}
|
||||
@ -87,7 +87,7 @@ void zmq::tcp_listener_t::process_plug ()
|
||||
void zmq::tcp_listener_t::process_term (int linger_)
|
||||
{
|
||||
rm_fd (handle);
|
||||
handle = (handle_t) NULL;
|
||||
handle = static_cast<handle_t> (NULL);
|
||||
close ();
|
||||
own_t::process_term (linger_);
|
||||
}
|
||||
@ -157,14 +157,14 @@ int zmq::tcp_listener_t::get_address (std::string &addr_)
|
||||
#else
|
||||
socklen_t sl = sizeof (ss);
|
||||
#endif
|
||||
int rc = getsockname (s, (struct sockaddr *) &ss, &sl);
|
||||
int rc = getsockname (s, reinterpret_cast<struct sockaddr *> (&ss), &sl);
|
||||
|
||||
if (rc != 0) {
|
||||
addr_.clear ();
|
||||
return rc;
|
||||
}
|
||||
|
||||
tcp_address_t addr ((struct sockaddr *) &ss, sl);
|
||||
tcp_address_t addr (reinterpret_cast<struct sockaddr *> (&ss), sl);
|
||||
return addr.to_string (addr_);
|
||||
}
|
||||
|
||||
@ -236,8 +236,8 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
|
||||
// Allow reusing of the address.
|
||||
int flag = 1;
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
rc = setsockopt (s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (const char *) &flag,
|
||||
sizeof (int));
|
||||
rc = setsockopt (s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
|
||||
reinterpret_cast<const char *> (&flag), sizeof (int));
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
#elif defined ZMQ_HAVE_VXWORKS
|
||||
rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &flag, sizeof (int));
|
||||
@ -302,7 +302,8 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
|
||||
#if defined ZMQ_HAVE_SOCK_CLOEXEC && defined HAVE_ACCEPT4
|
||||
fd_t sock = ::accept4 (s, (struct sockaddr *) &ss, &ss_len, SOCK_CLOEXEC);
|
||||
#else
|
||||
fd_t sock = ::accept (s, (struct sockaddr *) &ss, &ss_len);
|
||||
fd_t sock =
|
||||
::accept (s, reinterpret_cast<struct sockaddr *> (&ss), &ss_len);
|
||||
#endif
|
||||
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
|
@ -146,7 +146,7 @@ long zmq::timers_t::timeout ()
|
||||
// Live timer, lets return the timeout
|
||||
if (cancelled_it == cancelled_timers.end ()) {
|
||||
if (it->first > now)
|
||||
return (long) (it->first - now);
|
||||
return static_cast<long> (it->first - now);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
19
src/trie.cpp
19
src/trie.cpp
@ -74,7 +74,8 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
|
||||
unsigned char oldc = min;
|
||||
trie_t *oldp = next.node;
|
||||
count = (min < c ? c - min : min - c) + 1;
|
||||
next.table = (trie_t **) malloc (sizeof (trie_t *) * count);
|
||||
next.table =
|
||||
static_cast<trie_t **> (malloc (sizeof (trie_t *) * count));
|
||||
alloc_assert (next.table);
|
||||
for (unsigned short i = 0; i != count; ++i)
|
||||
next.table[i] = 0;
|
||||
@ -84,8 +85,8 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
|
||||
// The new character is above the current character range.
|
||||
unsigned short old_count = count;
|
||||
count = c - min + 1;
|
||||
next.table = (trie_t **) realloc ((void *) next.table,
|
||||
sizeof (trie_t *) * count);
|
||||
next.table = static_cast<trie_t **> (
|
||||
realloc ((void *) next.table, sizeof (trie_t *) * count));
|
||||
zmq_assert (next.table);
|
||||
for (unsigned short i = old_count; i != count; i++)
|
||||
next.table[i] = NULL;
|
||||
@ -93,8 +94,8 @@ bool zmq::trie_t::add (unsigned char *prefix_, size_t size_)
|
||||
// The new character is below the current character range.
|
||||
unsigned short old_count = count;
|
||||
count = (min + old_count) - c;
|
||||
next.table = (trie_t **) realloc ((void *) next.table,
|
||||
sizeof (trie_t *) * count);
|
||||
next.table = static_cast<trie_t **> (
|
||||
realloc ((void *) next.table, sizeof (trie_t *) * count));
|
||||
zmq_assert (next.table);
|
||||
memmove (next.table + min - c, next.table,
|
||||
old_count * sizeof (trie_t *));
|
||||
@ -200,7 +201,8 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
|
||||
zmq_assert (count > new_min - min);
|
||||
|
||||
count = count - (new_min - min);
|
||||
next.table = (trie_t **) malloc (sizeof (trie_t *) * count);
|
||||
next.table =
|
||||
static_cast<trie_t **> (malloc (sizeof (trie_t *) * count));
|
||||
alloc_assert (next.table);
|
||||
|
||||
memmove (next.table, old_table + (new_min - min),
|
||||
@ -223,7 +225,8 @@ bool zmq::trie_t::rm (unsigned char *prefix_, size_t size_)
|
||||
count = new_count;
|
||||
|
||||
trie_t **old_table = next.table;
|
||||
next.table = (trie_t **) malloc (sizeof (trie_t *) * count);
|
||||
next.table =
|
||||
static_cast<trie_t **> (malloc (sizeof (trie_t *) * count));
|
||||
alloc_assert (next.table);
|
||||
|
||||
memmove (next.table, old_table, sizeof (trie_t *) * count);
|
||||
@ -290,7 +293,7 @@ void zmq::trie_t::apply_helper (unsigned char **buff_,
|
||||
// Adjust the buffer.
|
||||
if (buffsize_ >= maxbuffsize_) {
|
||||
maxbuffsize_ = buffsize_ + 256;
|
||||
*buff_ = (unsigned char *) realloc (*buff_, maxbuffsize_);
|
||||
*buff_ = static_cast<unsigned char *> (realloc (*buff_, maxbuffsize_));
|
||||
zmq_assert (*buff_);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ zmq::udp_engine_t::udp_engine_t (const options_t &options_) :
|
||||
plugged (false),
|
||||
fd (-1),
|
||||
session (NULL),
|
||||
handle ((handle_t) NULL),
|
||||
handle (static_cast<handle_t> (NULL)),
|
||||
address (NULL),
|
||||
options (options_),
|
||||
send_enabled (false),
|
||||
@ -135,8 +135,9 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
}
|
||||
|
||||
int loop = options.multicast_loop;
|
||||
int rc = setsockopt (fd, level, optname, (char *) &loop,
|
||||
sizeof (loop));
|
||||
int rc =
|
||||
setsockopt (fd, level, optname,
|
||||
reinterpret_cast<char *> (&loop), sizeof (loop));
|
||||
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
@ -151,7 +152,8 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
// If a bind interface is provided we tell the
|
||||
// kernel to use it to send multicast packets
|
||||
rc = setsockopt (fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
|
||||
(char *) &bind_if, sizeof (bind_if));
|
||||
reinterpret_cast<char *> (&bind_if),
|
||||
sizeof (bind_if));
|
||||
} else {
|
||||
rc = 0;
|
||||
}
|
||||
@ -160,9 +162,9 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
udp_addr->bind_addr ()->ipv4.sin_addr;
|
||||
|
||||
if (bind_addr.s_addr != INADDR_ANY) {
|
||||
rc =
|
||||
setsockopt (fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
(char *) &bind_addr, sizeof (bind_addr));
|
||||
rc = setsockopt (fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
reinterpret_cast<char *> (&bind_addr),
|
||||
sizeof (bind_addr));
|
||||
} else {
|
||||
rc = 0;
|
||||
}
|
||||
@ -176,7 +178,7 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
}
|
||||
} else {
|
||||
/// XXX fixme ?
|
||||
out_address = (sockaddr *) &raw_address;
|
||||
out_address = reinterpret_cast<sockaddr *> (&raw_address);
|
||||
out_addrlen = sizeof (sockaddr_in);
|
||||
}
|
||||
|
||||
@ -185,8 +187,8 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
|
||||
if (recv_enabled) {
|
||||
int on = 1;
|
||||
int rc =
|
||||
setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on));
|
||||
int rc = setsockopt (fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
reinterpret_cast<char *> (&on), sizeof (on));
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
#else
|
||||
@ -231,8 +233,9 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
mreq.imr_multiaddr = mcast_addr->ipv4.sin_addr;
|
||||
mreq.imr_interface = bind_addr->ipv4.sin_addr;
|
||||
|
||||
rc = setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||
(char *) &mreq, sizeof (mreq));
|
||||
rc =
|
||||
setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||
reinterpret_cast<char *> (&mreq), sizeof (mreq));
|
||||
|
||||
errno_assert (rc == 0);
|
||||
} else if (mcast_addr->family () == AF_INET6) {
|
||||
@ -244,8 +247,9 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
mreq.ipv6mr_multiaddr = mcast_addr->ipv6.sin6_addr;
|
||||
mreq.ipv6mr_interface = iface;
|
||||
|
||||
rc = setsockopt (fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
|
||||
(char *) &mreq, sizeof (mreq));
|
||||
rc =
|
||||
setsockopt (fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
|
||||
reinterpret_cast<char *> (&mreq), sizeof (mreq));
|
||||
|
||||
errno_assert (rc == 0);
|
||||
} else {
|
||||
@ -284,14 +288,14 @@ void zmq::udp_engine_t::sockaddr_to_msg (zmq::msg_t *msg, sockaddr_in *addr)
|
||||
char *name = inet_ntoa (addr->sin_addr);
|
||||
|
||||
char port[6];
|
||||
sprintf (port, "%d", (int) ntohs (addr->sin_port));
|
||||
sprintf (port, "%d", static_cast<int> (ntohs (addr->sin_port)));
|
||||
|
||||
int size =
|
||||
(int) strlen (name) + (int) strlen (port) + 1 + 1; // Colon + NULL
|
||||
int size = static_cast<int> (strlen (name))
|
||||
+ static_cast<int> (strlen (port)) + 1 + 1; // Colon + NULL
|
||||
int rc = msg->init_size (size);
|
||||
errno_assert (rc == 0);
|
||||
msg->set_flags (msg_t::more);
|
||||
char *address = (char *) msg->data ();
|
||||
char *address = static_cast<char *> (msg->data ());
|
||||
|
||||
strcpy (address, name);
|
||||
strcat (address, ":");
|
||||
@ -306,7 +310,7 @@ int zmq::udp_engine_t::resolve_raw_address (char *name_, size_t length_)
|
||||
|
||||
// Find delimiter, cannot use memrchr as it is not supported on windows
|
||||
if (length_ != 0) {
|
||||
int chars_left = (int) length_;
|
||||
int chars_left = static_cast<int> (length_);
|
||||
char *current_char = name_ + length_;
|
||||
do {
|
||||
if (*(--current_char) == ':') {
|
||||
@ -325,7 +329,7 @@ int zmq::udp_engine_t::resolve_raw_address (char *name_, size_t length_)
|
||||
std::string port_str (delimiter + 1, name_ + length_ - delimiter - 1);
|
||||
|
||||
// Parse the port number (0 is not a valid port).
|
||||
uint16_t port = (uint16_t) atoi (port_str.c_str ());
|
||||
uint16_t port = static_cast<uint16_t> (atoi (port_str.c_str ()));
|
||||
if (port == 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@ -358,7 +362,8 @@ void zmq::udp_engine_t::out_event ()
|
||||
size_t size;
|
||||
|
||||
if (options.raw_socket) {
|
||||
rc = resolve_raw_address ((char *) group_msg.data (), group_size);
|
||||
rc = resolve_raw_address (static_cast<char *> (group_msg.data ()),
|
||||
group_size);
|
||||
|
||||
// We discard the message if address is not valid
|
||||
if (rc != 0) {
|
||||
@ -378,7 +383,7 @@ void zmq::udp_engine_t::out_event ()
|
||||
size = group_size + body_size + 1;
|
||||
|
||||
// TODO: check if larger than maximum size
|
||||
out_buffer[0] = (unsigned char) group_size;
|
||||
out_buffer[0] = static_cast<unsigned char> (group_size);
|
||||
memcpy (out_buffer + 1, group_msg.data (), group_size);
|
||||
memcpy (out_buffer + 1 + group_size, body_msg.data (), body_size);
|
||||
}
|
||||
@ -390,8 +395,9 @@ void zmq::udp_engine_t::out_event ()
|
||||
errno_assert (rc == 0);
|
||||
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
rc = sendto (fd, (const char *) out_buffer, (int) size, 0, out_address,
|
||||
(int) out_addrlen);
|
||||
rc = sendto (fd, reinterpret_cast<const char *> (out_buffer),
|
||||
static_cast<int> (size), 0, out_address,
|
||||
static_cast<int> (out_addrlen));
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
#elif defined ZMQ_HAVE_VXWORKS
|
||||
rc = sendto (fd, (caddr_t) out_buffer, size, 0,
|
||||
@ -428,8 +434,9 @@ void zmq::udp_engine_t::in_event ()
|
||||
sockaddr_storage in_address;
|
||||
socklen_t in_addrlen = sizeof (sockaddr_storage);
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
int nbytes = recvfrom (fd, (char *) in_buffer, MAX_UDP_MSG, 0,
|
||||
(sockaddr *) &in_address, &in_addrlen);
|
||||
int nbytes =
|
||||
recvfrom (fd, reinterpret_cast<char *> (in_buffer), MAX_UDP_MSG, 0,
|
||||
reinterpret_cast<sockaddr *> (&in_address), &in_addrlen);
|
||||
const int last_error = WSAGetLastError ();
|
||||
if (nbytes == SOCKET_ERROR) {
|
||||
wsa_assert (last_error == WSAENETDOWN || last_error == WSAENETRESET
|
||||
@ -465,7 +472,7 @@ void zmq::udp_engine_t::in_event ()
|
||||
body_size = nbytes;
|
||||
body_offset = 0;
|
||||
} else {
|
||||
char *group_buffer = (char *) in_buffer + 1;
|
||||
char *group_buffer = reinterpret_cast<char *> (in_buffer) + 1;
|
||||
int group_size = in_buffer[0];
|
||||
|
||||
rc = msg.init_size (group_size);
|
||||
|
@ -70,7 +70,8 @@ int zmq::v1_decoder_t::one_byte_size_ready (unsigned char const *)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (maxmsgsize >= 0 && (int64_t) (*tmpbuf - 1) > maxmsgsize) {
|
||||
if (maxmsgsize >= 0
|
||||
&& static_cast<int64_t> (*tmpbuf - 1) > maxmsgsize) {
|
||||
errno = EMSGSIZE;
|
||||
return -1;
|
||||
}
|
||||
@ -104,7 +105,8 @@ int zmq::v1_decoder_t::eight_byte_size_ready (unsigned char const *)
|
||||
}
|
||||
|
||||
// Message size must not exceed the maximum allowed size.
|
||||
if (maxmsgsize >= 0 && payload_length - 1 > (uint64_t) maxmsgsize) {
|
||||
if (maxmsgsize >= 0
|
||||
&& payload_length - 1 > static_cast<uint64_t> (maxmsgsize)) {
|
||||
errno = EMSGSIZE;
|
||||
return -1;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void zmq::v1_encoder_t::message_ready ()
|
||||
// For longer messages write 0xff escape character followed by 8-byte
|
||||
// message size. In both cases 'flags' field follows.
|
||||
if (size < 255) {
|
||||
tmpbuf[0] = (unsigned char) size;
|
||||
tmpbuf[0] = static_cast<unsigned char> (size);
|
||||
tmpbuf[1] = (in_progress->flags () & msg_t::more);
|
||||
next_step (tmpbuf, 2, &v1_encoder_t::size_ready, false);
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size,
|
||||
// construct message using n bytes from the buffer as storage
|
||||
// increase buffer ref count
|
||||
// if the message will be a large message, pass a valid refcnt memory location as well
|
||||
rc = in_progress.init ((unsigned char *) read_pos,
|
||||
rc = in_progress.init (const_cast<unsigned char *> (read_pos),
|
||||
static_cast<size_t> (msg_size),
|
||||
shared_message_memory_allocator::call_dec_ref,
|
||||
buffer (), provide_content ());
|
||||
|
49
src/wire.hpp
49
src/wire.hpp
@ -49,47 +49,54 @@ inline uint8_t get_uint8 (const unsigned char *buffer_)
|
||||
|
||||
inline void put_uint16 (unsigned char *buffer_, uint16_t value)
|
||||
{
|
||||
buffer_[0] = (unsigned char) (((value) >> 8) & 0xff);
|
||||
buffer_[1] = (unsigned char) (value & 0xff);
|
||||
buffer_[0] = static_cast<unsigned char> (((value) >> 8) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (value & 0xff);
|
||||
}
|
||||
|
||||
inline uint16_t get_uint16 (const unsigned char *buffer_)
|
||||
{
|
||||
return (((uint16_t) buffer_[0]) << 8) | ((uint16_t) buffer_[1]);
|
||||
return ((static_cast<uint16_t> (buffer_[0])) << 8)
|
||||
| (static_cast<uint16_t> (buffer_[1]));
|
||||
}
|
||||
|
||||
inline void put_uint32 (unsigned char *buffer_, uint32_t value)
|
||||
{
|
||||
buffer_[0] = (unsigned char) (((value) >> 24) & 0xff);
|
||||
buffer_[1] = (unsigned char) (((value) >> 16) & 0xff);
|
||||
buffer_[2] = (unsigned char) (((value) >> 8) & 0xff);
|
||||
buffer_[3] = (unsigned char) (value & 0xff);
|
||||
buffer_[0] = static_cast<unsigned char> (((value) >> 24) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (((value) >> 16) & 0xff);
|
||||
buffer_[2] = static_cast<unsigned char> (((value) >> 8) & 0xff);
|
||||
buffer_[3] = static_cast<unsigned char> (value & 0xff);
|
||||
}
|
||||
|
||||
inline uint32_t get_uint32 (const unsigned char *buffer_)
|
||||
{
|
||||
return (((uint32_t) buffer_[0]) << 24) | (((uint32_t) buffer_[1]) << 16)
|
||||
| (((uint32_t) buffer_[2]) << 8) | ((uint32_t) buffer_[3]);
|
||||
return ((static_cast<uint32_t> (buffer_[0])) << 24)
|
||||
| ((static_cast<uint32_t> (buffer_[1])) << 16)
|
||||
| ((static_cast<uint32_t> (buffer_[2])) << 8)
|
||||
| (static_cast<uint32_t> (buffer_[3]));
|
||||
}
|
||||
|
||||
inline void put_uint64 (unsigned char *buffer_, uint64_t value)
|
||||
{
|
||||
buffer_[0] = (unsigned char) (((value) >> 56) & 0xff);
|
||||
buffer_[1] = (unsigned char) (((value) >> 48) & 0xff);
|
||||
buffer_[2] = (unsigned char) (((value) >> 40) & 0xff);
|
||||
buffer_[3] = (unsigned char) (((value) >> 32) & 0xff);
|
||||
buffer_[4] = (unsigned char) (((value) >> 24) & 0xff);
|
||||
buffer_[5] = (unsigned char) (((value) >> 16) & 0xff);
|
||||
buffer_[6] = (unsigned char) (((value) >> 8) & 0xff);
|
||||
buffer_[7] = (unsigned char) (value & 0xff);
|
||||
buffer_[0] = static_cast<unsigned char> (((value) >> 56) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (((value) >> 48) & 0xff);
|
||||
buffer_[2] = static_cast<unsigned char> (((value) >> 40) & 0xff);
|
||||
buffer_[3] = static_cast<unsigned char> (((value) >> 32) & 0xff);
|
||||
buffer_[4] = static_cast<unsigned char> (((value) >> 24) & 0xff);
|
||||
buffer_[5] = static_cast<unsigned char> (((value) >> 16) & 0xff);
|
||||
buffer_[6] = static_cast<unsigned char> (((value) >> 8) & 0xff);
|
||||
buffer_[7] = static_cast<unsigned char> (value & 0xff);
|
||||
}
|
||||
|
||||
inline uint64_t get_uint64 (const unsigned char *buffer_)
|
||||
{
|
||||
return (((uint64_t) buffer_[0]) << 56) | (((uint64_t) buffer_[1]) << 48)
|
||||
| (((uint64_t) buffer_[2]) << 40) | (((uint64_t) buffer_[3]) << 32)
|
||||
| (((uint64_t) buffer_[4]) << 24) | (((uint64_t) buffer_[5]) << 16)
|
||||
| (((uint64_t) buffer_[6]) << 8) | ((uint64_t) buffer_[7]);
|
||||
return ((static_cast<uint64_t> (buffer_[0])) << 56)
|
||||
| ((static_cast<uint64_t> (buffer_[1])) << 48)
|
||||
| ((static_cast<uint64_t> (buffer_[2])) << 40)
|
||||
| ((static_cast<uint64_t> (buffer_[3])) << 32)
|
||||
| ((static_cast<uint64_t> (buffer_[4])) << 24)
|
||||
| ((static_cast<uint64_t> (buffer_[5])) << 16)
|
||||
| ((static_cast<uint64_t> (buffer_[6])) << 8)
|
||||
| (static_cast<uint64_t> (buffer_[7]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ void zmq::xpub_t::xread_activated (pipe_t *pipe_)
|
||||
msg_t sub;
|
||||
while (pipe_->read (&sub)) {
|
||||
// Apply the subscription to the trie
|
||||
unsigned char *const data = (unsigned char *) sub.data ();
|
||||
unsigned char *const data = static_cast<unsigned char *> (sub.data ());
|
||||
const size_t size = sub.size ();
|
||||
metadata_t *metadata = sub.metadata ();
|
||||
if (size > 0 && (*data == 0 || *data == 1)) {
|
||||
@ -183,7 +183,8 @@ int zmq::xpub_t::xsetsockopt (int option_,
|
||||
int rc = welcome_msg.init_size (optvallen_);
|
||||
errno_assert (rc == 0);
|
||||
|
||||
unsigned char *data = (unsigned char *) welcome_msg.data ();
|
||||
unsigned char *data =
|
||||
static_cast<unsigned char *> (welcome_msg.data ());
|
||||
memcpy (data, optval_, optvallen_);
|
||||
} else
|
||||
welcome_msg.init ();
|
||||
@ -232,8 +233,8 @@ int zmq::xpub_t::xsend (msg_t *msg_)
|
||||
|
||||
// For the first part of multi-part message, find the matching pipes.
|
||||
if (!more) {
|
||||
subscriptions.match ((unsigned char *) msg_->data (), msg_->size (),
|
||||
mark_as_matching, this);
|
||||
subscriptions.match (static_cast<unsigned char *> (msg_->data ()),
|
||||
msg_->size (), mark_as_matching, this);
|
||||
// If inverted matching is used, reverse the selection now
|
||||
if (options.invert_matching) {
|
||||
dist.reverse_match ();
|
||||
|
10
src/xsub.cpp
10
src/xsub.cpp
@ -94,7 +94,7 @@ void zmq::xsub_t::xhiccuped (pipe_t *pipe_)
|
||||
int zmq::xsub_t::xsend (msg_t *msg_)
|
||||
{
|
||||
size_t size = msg_->size ();
|
||||
unsigned char *data = (unsigned char *) msg_->data ();
|
||||
unsigned char *data = static_cast<unsigned char *> (msg_->data ());
|
||||
|
||||
if (size > 0 && *data == 1) {
|
||||
// Process subscribe message
|
||||
@ -212,8 +212,8 @@ const zmq::blob_t &zmq::xsub_t::get_credential () const
|
||||
|
||||
bool zmq::xsub_t::match (msg_t *msg_)
|
||||
{
|
||||
bool matching =
|
||||
subscriptions.check ((unsigned char *) msg_->data (), msg_->size ());
|
||||
bool matching = subscriptions.check (
|
||||
static_cast<unsigned char *> (msg_->data ()), msg_->size ());
|
||||
|
||||
return matching ^ options.invert_matching;
|
||||
}
|
||||
@ -222,13 +222,13 @@ void zmq::xsub_t::send_subscription (unsigned char *data_,
|
||||
size_t size_,
|
||||
void *arg_)
|
||||
{
|
||||
pipe_t *pipe = (pipe_t *) arg_;
|
||||
pipe_t *pipe = static_cast<pipe_t *> (arg_);
|
||||
|
||||
// Create the subscription message.
|
||||
msg_t msg;
|
||||
int rc = msg.init_size (size_ + 1);
|
||||
errno_assert (rc == 0);
|
||||
unsigned char *data = (unsigned char *) msg.data ();
|
||||
unsigned char *data = static_cast<unsigned char *> (msg.data ());
|
||||
data[0] = 1;
|
||||
|
||||
// We explicitly allow a NULL subscription with size zero
|
||||
|
157
src/zmq.cpp
157
src/zmq.cpp
@ -144,12 +144,12 @@ void *zmq_ctx_new (void)
|
||||
|
||||
int zmq_ctx_term (void *ctx_)
|
||||
{
|
||||
if (!ctx_ || !((zmq::ctx_t *) ctx_)->check_tag ()) {
|
||||
if (!ctx_ || !(static_cast<zmq::ctx_t *> (ctx_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rc = ((zmq::ctx_t *) ctx_)->terminate ();
|
||||
int rc = (static_cast<zmq::ctx_t *> (ctx_))->terminate ();
|
||||
int en = errno;
|
||||
|
||||
// Shut down only if termination was not interrupted by a signal.
|
||||
@ -163,29 +163,29 @@ int zmq_ctx_term (void *ctx_)
|
||||
|
||||
int zmq_ctx_shutdown (void *ctx_)
|
||||
{
|
||||
if (!ctx_ || !((zmq::ctx_t *) ctx_)->check_tag ()) {
|
||||
if (!ctx_ || !(static_cast<zmq::ctx_t *> (ctx_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
return ((zmq::ctx_t *) ctx_)->shutdown ();
|
||||
return (static_cast<zmq::ctx_t *> (ctx_))->shutdown ();
|
||||
}
|
||||
|
||||
int zmq_ctx_set (void *ctx_, int option_, int optval_)
|
||||
{
|
||||
if (!ctx_ || !((zmq::ctx_t *) ctx_)->check_tag ()) {
|
||||
if (!ctx_ || !(static_cast<zmq::ctx_t *> (ctx_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
return ((zmq::ctx_t *) ctx_)->set (option_, optval_);
|
||||
return (static_cast<zmq::ctx_t *> (ctx_))->set (option_, optval_);
|
||||
}
|
||||
|
||||
int zmq_ctx_get (void *ctx_, int option_)
|
||||
{
|
||||
if (!ctx_ || !((zmq::ctx_t *) ctx_)->check_tag ()) {
|
||||
if (!ctx_ || !(static_cast<zmq::ctx_t *> (ctx_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
return ((zmq::ctx_t *) ctx_)->get (option_);
|
||||
return (static_cast<zmq::ctx_t *> (ctx_))->get (option_);
|
||||
}
|
||||
|
||||
// Stable/legacy context API
|
||||
@ -226,11 +226,11 @@ static zmq::socket_base_t *as_socket_base_t (void *s_)
|
||||
|
||||
void *zmq_socket (void *ctx_, int type_)
|
||||
{
|
||||
if (!ctx_ || !((zmq::ctx_t *) ctx_)->check_tag ()) {
|
||||
if (!ctx_ || !(static_cast<zmq::ctx_t *> (ctx_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return NULL;
|
||||
}
|
||||
zmq::ctx_t *ctx = (zmq::ctx_t *) ctx_;
|
||||
zmq::ctx_t *ctx = static_cast<zmq::ctx_t *> (ctx_);
|
||||
zmq::socket_base_t *s = ctx->create_socket (type_);
|
||||
return (void *) s;
|
||||
}
|
||||
@ -325,7 +325,7 @@ static inline int
|
||||
s_sendmsg (zmq::socket_base_t *s_, zmq_msg_t *msg_, int flags_)
|
||||
{
|
||||
size_t sz = zmq_msg_size (msg_);
|
||||
int rc = s_->send ((zmq::msg_t *) msg_, flags_);
|
||||
int rc = s_->send (reinterpret_cast<zmq::msg_t *> (msg_), flags_);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
|
||||
@ -334,7 +334,7 @@ s_sendmsg (zmq::socket_base_t *s_, zmq_msg_t *msg_, int flags_)
|
||||
size_t max_msgsz = INT_MAX;
|
||||
|
||||
// Truncate returned size to INT_MAX to avoid overflow to negative values
|
||||
return (int) (sz < max_msgsz ? sz : max_msgsz);
|
||||
return static_cast<int> (sz < max_msgsz ? sz : max_msgsz);
|
||||
}
|
||||
|
||||
/* To be deprecated once zmq_msg_send() is stable */
|
||||
@ -376,7 +376,8 @@ int zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_)
|
||||
if (!s)
|
||||
return -1;
|
||||
zmq_msg_t msg;
|
||||
int rc = zmq_msg_init_data (&msg, (void *) buf_, len_, NULL, NULL);
|
||||
int rc =
|
||||
zmq_msg_init_data (&msg, const_cast<void *> (buf_), len_, NULL, NULL);
|
||||
if (rc != 0)
|
||||
return -1;
|
||||
|
||||
@ -440,13 +441,13 @@ int zmq_sendiov (void *s_, iovec *a_, size_t count_, int flags_)
|
||||
|
||||
static int s_recvmsg (zmq::socket_base_t *s_, zmq_msg_t *msg_, int flags_)
|
||||
{
|
||||
int rc = s_->recv ((zmq::msg_t *) msg_, flags_);
|
||||
int rc = s_->recv (reinterpret_cast<zmq::msg_t *> (msg_), flags_);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
|
||||
// Truncate returned size to INT_MAX to avoid overflow to negative values
|
||||
size_t sz = zmq_msg_size (msg_);
|
||||
return (int) (sz < INT_MAX ? sz : INT_MAX);
|
||||
return static_cast<int> (sz < INT_MAX ? sz : INT_MAX);
|
||||
}
|
||||
|
||||
/* To be deprecated once zmq_msg_recv() is stable */
|
||||
@ -558,18 +559,19 @@ int zmq_recviov (void *s_, iovec *a_, size_t *count_, int flags_)
|
||||
|
||||
int zmq_msg_init (zmq_msg_t *msg_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->init ();
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))->init ();
|
||||
}
|
||||
|
||||
int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->init_size (size_);
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))->init_size (size_);
|
||||
}
|
||||
|
||||
int zmq_msg_init_data (
|
||||
zmq_msg_t *msg_, void *data_, size_t size_, zmq_free_fn *ffn_, void *hint_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->init_data (data_, size_, ffn_, hint_);
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))
|
||||
->init_data (data_, size_, ffn_, hint_);
|
||||
}
|
||||
|
||||
int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_)
|
||||
@ -590,22 +592,24 @@ int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_)
|
||||
|
||||
int zmq_msg_close (zmq_msg_t *msg_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->close ();
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))->close ();
|
||||
}
|
||||
|
||||
int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_)
|
||||
{
|
||||
return ((zmq::msg_t *) dest_)->move (*(zmq::msg_t *) src_);
|
||||
return (reinterpret_cast<zmq::msg_t *> (dest_))
|
||||
->move (*reinterpret_cast<zmq::msg_t *> (src_));
|
||||
}
|
||||
|
||||
int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_)
|
||||
{
|
||||
return ((zmq::msg_t *) dest_)->copy (*(zmq::msg_t *) src_);
|
||||
return (reinterpret_cast<zmq::msg_t *> (dest_))
|
||||
->copy (*reinterpret_cast<zmq::msg_t *> (src_));
|
||||
}
|
||||
|
||||
void *zmq_msg_data (zmq_msg_t *msg_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->data ();
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))->data ();
|
||||
}
|
||||
|
||||
size_t zmq_msg_size (const zmq_msg_t *msg_)
|
||||
@ -628,7 +632,7 @@ int zmq_msg_get (const zmq_msg_t *msg_, int property_)
|
||||
case ZMQ_SRCFD:
|
||||
fd_string = zmq_msg_gets (msg_, "__fd");
|
||||
if (fd_string == NULL)
|
||||
return (int) -1;
|
||||
return -1;
|
||||
|
||||
return atoi (fd_string);
|
||||
case ZMQ_SHARED:
|
||||
@ -651,22 +655,23 @@ int zmq_msg_set (zmq_msg_t *, int, int)
|
||||
|
||||
int zmq_msg_set_routing_id (zmq_msg_t *msg_, uint32_t routing_id_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->set_routing_id (routing_id_);
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))
|
||||
->set_routing_id (routing_id_);
|
||||
}
|
||||
|
||||
uint32_t zmq_msg_routing_id (zmq_msg_t *msg_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->get_routing_id ();
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))->get_routing_id ();
|
||||
}
|
||||
|
||||
int zmq_msg_set_group (zmq_msg_t *msg_, const char *group_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->set_group (group_);
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))->set_group (group_);
|
||||
}
|
||||
|
||||
const char *zmq_msg_group (zmq_msg_t *msg_)
|
||||
{
|
||||
return ((zmq::msg_t *) msg_)->group ();
|
||||
return (reinterpret_cast<zmq::msg_t *> (msg_))->group ();
|
||||
}
|
||||
|
||||
// Get message metadata string
|
||||
@ -685,7 +690,7 @@ const char *zmq_msg_gets (const zmq_msg_t *msg_, const char *property_)
|
||||
}
|
||||
}
|
||||
|
||||
// Polling.
|
||||
// Polling.
|
||||
|
||||
#if defined ZMQ_HAVE_POLLER
|
||||
inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
||||
@ -1043,8 +1048,8 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
||||
} else if (timeout_ < 0)
|
||||
ptimeout = NULL;
|
||||
else {
|
||||
timeout.tv_sec = (long) ((end - now) / 1000);
|
||||
timeout.tv_usec = (long) ((end - now) % 1000 * 1000);
|
||||
timeout.tv_sec = static_cast<long> ((end - now) / 1000);
|
||||
timeout.tv_usec = static_cast<long> ((end - now) % 1000 * 1000);
|
||||
ptimeout = &timeout;
|
||||
}
|
||||
|
||||
@ -1056,14 +1061,17 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
||||
// We just need to copy fd_count elements of fd_array.
|
||||
// We gain huge memcpy() improvement if number of used SOCKETs is much lower than FD_SETSIZE.
|
||||
memcpy (&inset, &pollset_in,
|
||||
(char *) (pollset_in.fd_array + pollset_in.fd_count)
|
||||
- (char *) &pollset_in);
|
||||
reinterpret_cast<char *> (pollset_in.fd_array
|
||||
+ pollset_in.fd_count)
|
||||
- reinterpret_cast<char *> (&pollset_in));
|
||||
memcpy (&outset, &pollset_out,
|
||||
(char *) (pollset_out.fd_array + pollset_out.fd_count)
|
||||
- (char *) &pollset_out);
|
||||
reinterpret_cast<char *> (pollset_out.fd_array
|
||||
+ pollset_out.fd_count)
|
||||
- reinterpret_cast<char *> (&pollset_out));
|
||||
memcpy (&errset, &pollset_err,
|
||||
(char *) (pollset_err.fd_array + pollset_err.fd_count)
|
||||
- (char *) &pollset_err);
|
||||
reinterpret_cast<char *> (pollset_err.fd_array
|
||||
+ pollset_err.fd_count)
|
||||
- reinterpret_cast<char *> (&pollset_err));
|
||||
int rc = select (0, &inset, &outset, &errset, ptimeout);
|
||||
if (unlikely (rc == SOCKET_ERROR)) {
|
||||
errno = zmq::wsa_error_to_errno (WSAGetLastError ());
|
||||
@ -1192,7 +1200,8 @@ int zmq_poller_destroy (void **poller_p_)
|
||||
|
||||
static int check_poller (void *const poller_)
|
||||
{
|
||||
if (!poller_ || !((zmq::socket_poller_t *) poller_)->check_tag ()) {
|
||||
if (!poller_
|
||||
|| !(static_cast<zmq::socket_poller_t *> (poller_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
@ -1214,7 +1223,7 @@ static int check_poller_registration_args (void *const poller_, void *const s_)
|
||||
if (-1 == check_poller (poller_))
|
||||
return -1;
|
||||
|
||||
if (!s_ || !((zmq::socket_base_t *) s_)->check_tag ()) {
|
||||
if (!s_ || !(static_cast<zmq::socket_base_t *> (s_))->check_tag ()) {
|
||||
errno = ENOTSOCK;
|
||||
return -1;
|
||||
}
|
||||
@ -1242,9 +1251,9 @@ int zmq_poller_add (void *poller_, void *s_, void *user_data_, short events_)
|
||||
|| -1 == check_events (events_))
|
||||
return -1;
|
||||
|
||||
zmq::socket_base_t *socket = (zmq::socket_base_t *) s_;
|
||||
zmq::socket_base_t *socket = static_cast<zmq::socket_base_t *> (s_);
|
||||
|
||||
return ((zmq::socket_poller_t *) poller_)
|
||||
return (static_cast<zmq::socket_poller_t *> (poller_))
|
||||
->add (socket, user_data_, events_);
|
||||
}
|
||||
|
||||
@ -1257,7 +1266,7 @@ int zmq_poller_add_fd (void *poller_,
|
||||
|| -1 == check_events (events_))
|
||||
return -1;
|
||||
|
||||
return ((zmq::socket_poller_t *) poller_)
|
||||
return (static_cast<zmq::socket_poller_t *> (poller_))
|
||||
->add_fd (fd_, user_data_, events_);
|
||||
}
|
||||
|
||||
@ -1268,9 +1277,10 @@ int zmq_poller_modify (void *poller_, void *s_, short events_)
|
||||
|| -1 == check_events (events_))
|
||||
return -1;
|
||||
|
||||
zmq::socket_base_t *socket = (zmq::socket_base_t *) s_;
|
||||
zmq::socket_base_t *socket = static_cast<zmq::socket_base_t *> (s_);
|
||||
|
||||
return ((zmq::socket_poller_t *) poller_)->modify (socket, events_);
|
||||
return (static_cast<zmq::socket_poller_t *> (poller_))
|
||||
->modify (socket, events_);
|
||||
}
|
||||
|
||||
int zmq_poller_modify_fd (void *poller_, zmq::fd_t fd_, short events_)
|
||||
@ -1279,7 +1289,8 @@ int zmq_poller_modify_fd (void *poller_, zmq::fd_t fd_, short events_)
|
||||
|| -1 == check_events (events_))
|
||||
return -1;
|
||||
|
||||
return ((zmq::socket_poller_t *) poller_)->modify_fd (fd_, events_);
|
||||
return (static_cast<zmq::socket_poller_t *> (poller_))
|
||||
->modify_fd (fd_, events_);
|
||||
}
|
||||
|
||||
int zmq_poller_remove (void *poller_, void *s_)
|
||||
@ -1287,9 +1298,9 @@ int zmq_poller_remove (void *poller_, void *s_)
|
||||
if (-1 == check_poller_registration_args (poller_, s_))
|
||||
return -1;
|
||||
|
||||
zmq::socket_base_t *socket = (zmq::socket_base_t *) s_;
|
||||
zmq::socket_base_t *socket = static_cast<zmq::socket_base_t *> (s_);
|
||||
|
||||
return ((zmq::socket_poller_t *) poller_)->remove (socket);
|
||||
return (static_cast<zmq::socket_poller_t *> (poller_))->remove (socket);
|
||||
}
|
||||
|
||||
int zmq_poller_remove_fd (void *poller_, zmq::fd_t fd_)
|
||||
@ -1297,7 +1308,7 @@ int zmq_poller_remove_fd (void *poller_, zmq::fd_t fd_)
|
||||
if (-1 == check_poller_fd_registration_args (poller_, fd_))
|
||||
return -1;
|
||||
|
||||
return ((zmq::socket_poller_t *) poller_)->remove_fd (fd_);
|
||||
return (static_cast<zmq::socket_poller_t *> (poller_))->remove_fd (fd_);
|
||||
}
|
||||
|
||||
int zmq_poller_wait (void *poller_, zmq_poller_event_t *event_, long timeout_)
|
||||
@ -1331,8 +1342,9 @@ int zmq_poller_wait_all (void *poller_,
|
||||
}
|
||||
|
||||
int rc =
|
||||
((zmq::socket_poller_t *) poller_)
|
||||
->wait ((zmq::socket_poller_t::event_t *) events_, n_events, timeout_);
|
||||
(static_cast<zmq::socket_poller_t *> (poller_))
|
||||
->wait (reinterpret_cast<zmq::socket_poller_t::event_t *> (events_),
|
||||
n_events, timeout_);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1362,11 +1374,11 @@ void *zmq_timers_new (void)
|
||||
int zmq_timers_destroy (void **timers_p_)
|
||||
{
|
||||
void *timers = *timers_p_;
|
||||
if (!timers || !((zmq::timers_t *) timers)->check_tag ()) {
|
||||
if (!timers || !(static_cast<zmq::timers_t *> (timers))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
delete ((zmq::timers_t *) timers);
|
||||
delete (static_cast<zmq::timers_t *> (timers));
|
||||
*timers_p_ = NULL;
|
||||
return 0;
|
||||
}
|
||||
@ -1376,62 +1388,64 @@ int zmq_timers_add (void *timers_,
|
||||
zmq_timer_fn handler_,
|
||||
void *arg_)
|
||||
{
|
||||
if (!timers_ || !((zmq::timers_t *) timers_)->check_tag ()) {
|
||||
if (!timers_ || !(static_cast<zmq::timers_t *> (timers_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ((zmq::timers_t *) timers_)->add (interval_, handler_, arg_);
|
||||
return (static_cast<zmq::timers_t *> (timers_))
|
||||
->add (interval_, handler_, arg_);
|
||||
}
|
||||
|
||||
int zmq_timers_cancel (void *timers_, int timer_id_)
|
||||
{
|
||||
if (!timers_ || !((zmq::timers_t *) timers_)->check_tag ()) {
|
||||
if (!timers_ || !(static_cast<zmq::timers_t *> (timers_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ((zmq::timers_t *) timers_)->cancel (timer_id_);
|
||||
return (static_cast<zmq::timers_t *> (timers_))->cancel (timer_id_);
|
||||
}
|
||||
|
||||
int zmq_timers_set_interval (void *timers_, int timer_id_, size_t interval_)
|
||||
{
|
||||
if (!timers_ || !((zmq::timers_t *) timers_)->check_tag ()) {
|
||||
if (!timers_ || !(static_cast<zmq::timers_t *> (timers_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ((zmq::timers_t *) timers_)->set_interval (timer_id_, interval_);
|
||||
return (static_cast<zmq::timers_t *> (timers_))
|
||||
->set_interval (timer_id_, interval_);
|
||||
}
|
||||
|
||||
int zmq_timers_reset (void *timers_, int timer_id_)
|
||||
{
|
||||
if (!timers_ || !((zmq::timers_t *) timers_)->check_tag ()) {
|
||||
if (!timers_ || !(static_cast<zmq::timers_t *> (timers_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ((zmq::timers_t *) timers_)->reset (timer_id_);
|
||||
return (static_cast<zmq::timers_t *> (timers_))->reset (timer_id_);
|
||||
}
|
||||
|
||||
long zmq_timers_timeout (void *timers_)
|
||||
{
|
||||
if (!timers_ || !((zmq::timers_t *) timers_)->check_tag ()) {
|
||||
if (!timers_ || !(static_cast<zmq::timers_t *> (timers_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ((zmq::timers_t *) timers_)->timeout ();
|
||||
return (static_cast<zmq::timers_t *> (timers_))->timeout ();
|
||||
}
|
||||
|
||||
int zmq_timers_execute (void *timers_)
|
||||
{
|
||||
if (!timers_ || !((zmq::timers_t *) timers_)->check_tag ()) {
|
||||
if (!timers_ || !(static_cast<zmq::timers_t *> (timers_))->check_tag ()) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ((zmq::timers_t *) timers_)->execute ();
|
||||
return (static_cast<zmq::timers_t *> (timers_))->execute ();
|
||||
}
|
||||
|
||||
// The proxy functionality
|
||||
@ -1442,9 +1456,9 @@ int zmq_proxy (void *frontend_, void *backend_, void *capture_)
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
return zmq::proxy ((zmq::socket_base_t *) frontend_,
|
||||
(zmq::socket_base_t *) backend_,
|
||||
(zmq::socket_base_t *) capture_);
|
||||
return zmq::proxy (static_cast<zmq::socket_base_t *> (frontend_),
|
||||
static_cast<zmq::socket_base_t *> (backend_),
|
||||
static_cast<zmq::socket_base_t *> (capture_));
|
||||
}
|
||||
|
||||
int zmq_proxy_steerable (void *frontend_,
|
||||
@ -1456,17 +1470,18 @@ int zmq_proxy_steerable (void *frontend_,
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
return zmq::proxy (
|
||||
(zmq::socket_base_t *) frontend_, (zmq::socket_base_t *) backend_,
|
||||
(zmq::socket_base_t *) capture_, (zmq::socket_base_t *) control_);
|
||||
return zmq::proxy (static_cast<zmq::socket_base_t *> (frontend_),
|
||||
static_cast<zmq::socket_base_t *> (backend_),
|
||||
static_cast<zmq::socket_base_t *> (capture_),
|
||||
static_cast<zmq::socket_base_t *> (control_));
|
||||
}
|
||||
|
||||
// The deprecated device functionality
|
||||
|
||||
int zmq_device (int /* type */, void *frontend_, void *backend_)
|
||||
{
|
||||
return zmq::proxy ((zmq::socket_base_t *) frontend_,
|
||||
(zmq::socket_base_t *) backend_, NULL);
|
||||
return zmq::proxy (static_cast<zmq::socket_base_t *> (frontend_),
|
||||
static_cast<zmq::socket_base_t *> (backend_), NULL);
|
||||
}
|
||||
|
||||
// Probe library capabilities; for now, reports on transport and security
|
||||
|
@ -60,7 +60,7 @@ void zmq_sleep (int seconds_)
|
||||
|
||||
void *zmq_stopwatch_start ()
|
||||
{
|
||||
uint64_t *watch = (uint64_t *) malloc (sizeof (uint64_t));
|
||||
uint64_t *watch = static_cast<uint64_t *> (malloc (sizeof (uint64_t)));
|
||||
alloc_assert (watch);
|
||||
*watch = zmq::clock_t::now_us ();
|
||||
return (void *) watch;
|
||||
@ -69,8 +69,8 @@ void *zmq_stopwatch_start ()
|
||||
unsigned long zmq_stopwatch_intermediate (void *watch_)
|
||||
{
|
||||
uint64_t end = zmq::clock_t::now_us ();
|
||||
uint64_t start = *(uint64_t *) watch_;
|
||||
return (unsigned long) (end - start);
|
||||
uint64_t start = *static_cast<uint64_t *> (watch_);
|
||||
return static_cast<unsigned long> (end - start);
|
||||
}
|
||||
|
||||
unsigned long zmq_stopwatch_stop (void *watch_)
|
||||
@ -287,14 +287,14 @@ void *zmq_atomic_counter_new (void)
|
||||
|
||||
void zmq_atomic_counter_set (void *counter_, int value_)
|
||||
{
|
||||
((zmq::atomic_counter_t *) counter_)->set (value_);
|
||||
(static_cast<zmq::atomic_counter_t *> (counter_))->set (value_);
|
||||
}
|
||||
|
||||
// Increment the atomic counter, and return the old value
|
||||
|
||||
int zmq_atomic_counter_inc (void *counter_)
|
||||
{
|
||||
return ((zmq::atomic_counter_t *) counter_)->add (1);
|
||||
return (static_cast<zmq::atomic_counter_t *> (counter_))->add (1);
|
||||
}
|
||||
|
||||
// Decrement the atomic counter and return 1 (if counter >= 1), or
|
||||
@ -302,20 +302,20 @@ int zmq_atomic_counter_inc (void *counter_)
|
||||
|
||||
int zmq_atomic_counter_dec (void *counter_)
|
||||
{
|
||||
return ((zmq::atomic_counter_t *) counter_)->sub (1) ? 1 : 0;
|
||||
return (static_cast<zmq::atomic_counter_t *> (counter_))->sub (1) ? 1 : 0;
|
||||
}
|
||||
|
||||
// Return actual value of atomic counter
|
||||
|
||||
int zmq_atomic_counter_value (void *counter_)
|
||||
{
|
||||
return ((zmq::atomic_counter_t *) counter_)->get ();
|
||||
return (static_cast<zmq::atomic_counter_t *> (counter_))->get ();
|
||||
}
|
||||
|
||||
// Destroy atomic counter, and set reference to NULL
|
||||
|
||||
void zmq_atomic_counter_destroy (void **counter_p_)
|
||||
{
|
||||
delete ((zmq::atomic_counter_t *) *counter_p_);
|
||||
delete (static_cast<zmq::atomic_counter_t *> (*counter_p_));
|
||||
*counter_p_ = NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user