Problem: C-style casts used

Solution: replace by C++-style casts
This commit is contained in:
Simon Giesecke
2018-05-18 15:54:00 +02:00
parent d002eb5578
commit 4e616f30dd
52 changed files with 408 additions and 325 deletions

View File

@@ -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))