diff --git a/src/array.hpp b/src/array.hpp index 4e4869e7..e1b55349 100644 --- a/src/array.hpp +++ b/src/array.hpp @@ -89,20 +89,23 @@ template class array_t inline void push_back (T *item_) { if (item_) - ((item_t *) item_)->set_array_index ((int) _items.size ()); + static_cast (item_)->set_array_index ( + static_cast (_items.size ())); _items.push_back (item_); } inline void erase (T *item_) { - erase (((item_t *) item_)->get_array_index ()); + erase (static_cast (item_)->get_array_index ()); } inline void erase (size_type index_) { if (_items.empty ()) return; - ((item_t *) _items.back ())->set_array_index ((int) index_); + static_cast (_items.back ()) + ->set_array_index (static_cast (index_)); + _items[index_] = _items.back (); _items.pop_back (); } @@ -110,9 +113,11 @@ template class array_t inline void swap (size_type index1_, size_type index2_) { if (_items[index1_]) - ((item_t *) _items[index1_])->set_array_index ((int) index2_); + static_cast (_items[index1_]) + ->set_array_index (static_cast (index2_)); if (_items[index2_]) - ((item_t *) _items[index2_])->set_array_index ((int) index1_); + static_cast (_items[index2_]) + ->set_array_index (static_cast (index1_)); std::swap (_items[index1_], _items[index2_]); } @@ -120,7 +125,8 @@ template class array_t static inline size_type index (T *item_) { - return (size_type) ((item_t *) item_)->get_array_index (); + return static_cast ( + static_cast (item_)->get_array_index ()); } private: diff --git a/src/ip_resolver.cpp b/src/ip_resolver.cpp index c0bb25b3..dcf7ea0c 100644 --- a/src/ip_resolver.cpp +++ b/src/ip_resolver.cpp @@ -388,7 +388,7 @@ int zmq::ip_resolver_t::resolve_getaddrinfo (ip_addr_t *ip_addr_, // Use the first result. zmq_assert (res != NULL); - zmq_assert ((size_t) res->ai_addrlen <= sizeof (*ip_addr_)); + zmq_assert (static_cast (res->ai_addrlen) <= sizeof (*ip_addr_)); memcpy (ip_addr_, res->ai_addr, res->ai_addrlen); // Cleanup getaddrinfo after copying the possibly referenced result. diff --git a/src/mechanism.cpp b/src/mechanism.cpp index 7bac643b..93945a33 100644 --- a/src/mechanism.cpp +++ b/src/mechanism.cpp @@ -110,7 +110,8 @@ const char *zmq::mechanism_t::socket_type_string (int socket_type_) #endif }; static const size_t names_count = sizeof (names) / sizeof (names[0]); - zmq_assert (socket_type_ >= 0 && socket_type_ < (int) names_count); + zmq_assert (socket_type_ >= 0 + && socket_type_ < static_cast (names_count)); return names[socket_type_]; } diff --git a/src/thread.cpp b/src/thread.cpp index c40e3061..539622b9 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -50,7 +50,7 @@ static DWORD thread_routine (LPVOID arg_) static unsigned int __stdcall thread_routine (void *arg_) #endif { - zmq::thread_t *self = (zmq::thread_t *) arg_; + zmq::thread_t *self = static_cast (arg_); self->applyThreadName (); self->_tfn (self->_arg); return 0; diff --git a/src/v2_decoder.cpp b/src/v2_decoder.cpp index 92e37fce..5848d6a0 100644 --- a/src/v2_decoder.cpp +++ b/src/v2_decoder.cpp @@ -115,8 +115,8 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size_, shared_message_memory_allocator &allocator = get_allocator (); if (unlikely (!_zero_copy - || msg_size_ > (size_t) (allocator.data () + allocator.size () - - read_pos_))) { + || msg_size_ > static_cast ( + allocator.data () + allocator.size () - read_pos_))) { // a new message has started, but the size would exceed the pre-allocated arena // this happens every time when a message does not fit completely into the buffer rc = _in_progress.init_size (static_cast (msg_size_)); diff --git a/src/ws_decoder.cpp b/src/ws_decoder.cpp index 68c2e955..9fc4e2e2 100644 --- a/src/ws_decoder.cpp +++ b/src/ws_decoder.cpp @@ -213,8 +213,8 @@ int zmq::ws_decoder_t::size_ready (unsigned char const *read_pos_) shared_message_memory_allocator &allocator = get_allocator (); if (unlikely (!_zero_copy - || _size > (size_t) (allocator.data () + allocator.size () - - read_pos_))) { + || _size > static_cast ( + allocator.data () + allocator.size () - read_pos_))) { // a new message has started, but the size would exceed the pre-allocated arena // this happens every time when a message does not fit completely into the buffer rc = _in_progress.init_size (static_cast (_size)); diff --git a/src/xpub.cpp b/src/xpub.cpp index 0c81b413..36748e13 100644 --- a/src/xpub.cpp +++ b/src/xpub.cpp @@ -270,7 +270,7 @@ void zmq::xpub_t::xpipe_terminated (pipe_t *pipe_) // Remove pipe without actually sending the message as it was taken // care of by the manual call above. subscriptions is the real mtrie, // so the pipe must be removed from there or it will be left over. - _subscriptions.rm (pipe_, stub, (void *) NULL, false); + _subscriptions.rm (pipe_, stub, static_cast (NULL), false); } else { // Remove the pipe from the trie. If there are topics that nobody // is interested in anymore, send corresponding unsubscriptions diff --git a/src/yqueue.hpp b/src/yqueue.hpp index 4a950521..6ba634a3 100644 --- a/src/yqueue.hpp +++ b/src/yqueue.hpp @@ -187,7 +187,7 @@ template class yqueue_t return (chunk_t *) pv; return NULL; #else - return (chunk_t *) malloc (sizeof (chunk_t)); + return static_cast (malloc (sizeof (chunk_t))); #endif } diff --git a/src/zmq.cpp b/src/zmq.cpp index 76a7c649..372ba707 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -259,7 +259,7 @@ void *zmq_socket (void *ctx_, int type_) } zmq::ctx_t *ctx = static_cast (ctx_); zmq::socket_base_t *s = ctx->create_socket (type_); - return (void *) s; + return static_cast (s); } int zmq_close (void *s_) diff --git a/src/zmq_utils.cpp b/src/zmq_utils.cpp index 74cad47e..a42d732a 100644 --- a/src/zmq_utils.cpp +++ b/src/zmq_utils.cpp @@ -63,7 +63,7 @@ void *zmq_stopwatch_start () uint64_t *watch = static_cast (malloc (sizeof (uint64_t))); alloc_assert (watch); *watch = zmq::clock_t::now_us (); - return (void *) watch; + return static_cast (watch); } unsigned long zmq_stopwatch_intermediate (void *watch_)