mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 18:40:27 +01:00
Problem: C-style casts used
Solution: use static_cast instead
This commit is contained in:
parent
78961eeab7
commit
406c423c9a
@ -89,20 +89,23 @@ template <typename T, int ID = 0> class array_t
|
|||||||
inline void push_back (T *item_)
|
inline void push_back (T *item_)
|
||||||
{
|
{
|
||||||
if (item_)
|
if (item_)
|
||||||
((item_t *) item_)->set_array_index ((int) _items.size ());
|
static_cast<item_t *> (item_)->set_array_index (
|
||||||
|
static_cast<int> (_items.size ()));
|
||||||
_items.push_back (item_);
|
_items.push_back (item_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void erase (T *item_)
|
inline void erase (T *item_)
|
||||||
{
|
{
|
||||||
erase (((item_t *) item_)->get_array_index ());
|
erase (static_cast<item_t *> (item_)->get_array_index ());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void erase (size_type index_)
|
inline void erase (size_type index_)
|
||||||
{
|
{
|
||||||
if (_items.empty ())
|
if (_items.empty ())
|
||||||
return;
|
return;
|
||||||
((item_t *) _items.back ())->set_array_index ((int) index_);
|
static_cast<item_t *> (_items.back ())
|
||||||
|
->set_array_index (static_cast<int> (index_));
|
||||||
|
|
||||||
_items[index_] = _items.back ();
|
_items[index_] = _items.back ();
|
||||||
_items.pop_back ();
|
_items.pop_back ();
|
||||||
}
|
}
|
||||||
@ -110,9 +113,11 @@ template <typename T, int ID = 0> class array_t
|
|||||||
inline void swap (size_type index1_, size_type index2_)
|
inline void swap (size_type index1_, size_type index2_)
|
||||||
{
|
{
|
||||||
if (_items[index1_])
|
if (_items[index1_])
|
||||||
((item_t *) _items[index1_])->set_array_index ((int) index2_);
|
static_cast<item_t *> (_items[index1_])
|
||||||
|
->set_array_index (static_cast<int> (index2_));
|
||||||
if (_items[index2_])
|
if (_items[index2_])
|
||||||
((item_t *) _items[index2_])->set_array_index ((int) index1_);
|
static_cast<item_t *> (_items[index2_])
|
||||||
|
->set_array_index (static_cast<int> (index1_));
|
||||||
std::swap (_items[index1_], _items[index2_]);
|
std::swap (_items[index1_], _items[index2_]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +125,8 @@ template <typename T, int ID = 0> class array_t
|
|||||||
|
|
||||||
static inline size_type index (T *item_)
|
static inline size_type index (T *item_)
|
||||||
{
|
{
|
||||||
return (size_type) ((item_t *) item_)->get_array_index ();
|
return static_cast<size_type> (
|
||||||
|
static_cast<item_t *> (item_)->get_array_index ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -388,7 +388,7 @@ int zmq::ip_resolver_t::resolve_getaddrinfo (ip_addr_t *ip_addr_,
|
|||||||
|
|
||||||
// Use the first result.
|
// Use the first result.
|
||||||
zmq_assert (res != NULL);
|
zmq_assert (res != NULL);
|
||||||
zmq_assert ((size_t) res->ai_addrlen <= sizeof (*ip_addr_));
|
zmq_assert (static_cast<size_t> (res->ai_addrlen) <= sizeof (*ip_addr_));
|
||||||
memcpy (ip_addr_, res->ai_addr, res->ai_addrlen);
|
memcpy (ip_addr_, res->ai_addr, res->ai_addrlen);
|
||||||
|
|
||||||
// Cleanup getaddrinfo after copying the possibly referenced result.
|
// Cleanup getaddrinfo after copying the possibly referenced result.
|
||||||
|
@ -110,7 +110,8 @@ const char *zmq::mechanism_t::socket_type_string (int socket_type_)
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
static const size_t names_count = sizeof (names) / sizeof (names[0]);
|
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<int> (names_count));
|
||||||
return names[socket_type_];
|
return names[socket_type_];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ static DWORD thread_routine (LPVOID arg_)
|
|||||||
static unsigned int __stdcall thread_routine (void *arg_)
|
static unsigned int __stdcall thread_routine (void *arg_)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
zmq::thread_t *self = (zmq::thread_t *) arg_;
|
zmq::thread_t *self = static_cast<zmq::thread_t *> (arg_);
|
||||||
self->applyThreadName ();
|
self->applyThreadName ();
|
||||||
self->_tfn (self->_arg);
|
self->_tfn (self->_arg);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -115,8 +115,8 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size_,
|
|||||||
|
|
||||||
shared_message_memory_allocator &allocator = get_allocator ();
|
shared_message_memory_allocator &allocator = get_allocator ();
|
||||||
if (unlikely (!_zero_copy
|
if (unlikely (!_zero_copy
|
||||||
|| msg_size_ > (size_t) (allocator.data () + allocator.size ()
|
|| msg_size_ > static_cast<size_t> (
|
||||||
- read_pos_))) {
|
allocator.data () + allocator.size () - read_pos_))) {
|
||||||
// a new message has started, but the size would exceed the pre-allocated arena
|
// 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
|
// this happens every time when a message does not fit completely into the buffer
|
||||||
rc = _in_progress.init_size (static_cast<size_t> (msg_size_));
|
rc = _in_progress.init_size (static_cast<size_t> (msg_size_));
|
||||||
|
@ -213,8 +213,8 @@ int zmq::ws_decoder_t::size_ready (unsigned char const *read_pos_)
|
|||||||
|
|
||||||
shared_message_memory_allocator &allocator = get_allocator ();
|
shared_message_memory_allocator &allocator = get_allocator ();
|
||||||
if (unlikely (!_zero_copy
|
if (unlikely (!_zero_copy
|
||||||
|| _size > (size_t) (allocator.data () + allocator.size ()
|
|| _size > static_cast<size_t> (
|
||||||
- read_pos_))) {
|
allocator.data () + allocator.size () - read_pos_))) {
|
||||||
// a new message has started, but the size would exceed the pre-allocated arena
|
// 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
|
// this happens every time when a message does not fit completely into the buffer
|
||||||
rc = _in_progress.init_size (static_cast<size_t> (_size));
|
rc = _in_progress.init_size (static_cast<size_t> (_size));
|
||||||
|
@ -270,7 +270,7 @@ void zmq::xpub_t::xpipe_terminated (pipe_t *pipe_)
|
|||||||
// Remove pipe without actually sending the message as it was taken
|
// Remove pipe without actually sending the message as it was taken
|
||||||
// care of by the manual call above. subscriptions is the real mtrie,
|
// 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.
|
// 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<void *> (NULL), false);
|
||||||
} else {
|
} else {
|
||||||
// Remove the pipe from the trie. If there are topics that nobody
|
// Remove the pipe from the trie. If there are topics that nobody
|
||||||
// is interested in anymore, send corresponding unsubscriptions
|
// is interested in anymore, send corresponding unsubscriptions
|
||||||
|
@ -187,7 +187,7 @@ template <typename T, int N> class yqueue_t
|
|||||||
return (chunk_t *) pv;
|
return (chunk_t *) pv;
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
return (chunk_t *) malloc (sizeof (chunk_t));
|
return static_cast<chunk_t *> (malloc (sizeof (chunk_t)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ void *zmq_socket (void *ctx_, int type_)
|
|||||||
}
|
}
|
||||||
zmq::ctx_t *ctx = static_cast<zmq::ctx_t *> (ctx_);
|
zmq::ctx_t *ctx = static_cast<zmq::ctx_t *> (ctx_);
|
||||||
zmq::socket_base_t *s = ctx->create_socket (type_);
|
zmq::socket_base_t *s = ctx->create_socket (type_);
|
||||||
return (void *) s;
|
return static_cast<void *> (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq_close (void *s_)
|
int zmq_close (void *s_)
|
||||||
|
@ -63,7 +63,7 @@ void *zmq_stopwatch_start ()
|
|||||||
uint64_t *watch = static_cast<uint64_t *> (malloc (sizeof (uint64_t)));
|
uint64_t *watch = static_cast<uint64_t *> (malloc (sizeof (uint64_t)));
|
||||||
alloc_assert (watch);
|
alloc_assert (watch);
|
||||||
*watch = zmq::clock_t::now_us ();
|
*watch = zmq::clock_t::now_us ();
|
||||||
return (void *) watch;
|
return static_cast<void *> (watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long zmq_stopwatch_intermediate (void *watch_)
|
unsigned long zmq_stopwatch_intermediate (void *watch_)
|
||||||
|
Loading…
Reference in New Issue
Block a user