mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-27 19:10:22 +01:00
Problem: old C-style casts used
Solution: replace by static_cast/reinterpret_cast
This commit is contained in:
@@ -108,7 +108,7 @@ zmq::epoll_t::handle_t zmq::epoll_t::add_fd (fd_t fd_, i_poll_events *events_)
|
|||||||
void zmq::epoll_t::rm_fd (handle_t handle_)
|
void zmq::epoll_t::rm_fd (handle_t handle_)
|
||||||
{
|
{
|
||||||
check_thread ();
|
check_thread ();
|
||||||
poll_entry_t *pe = (poll_entry_t *) handle_;
|
poll_entry_t *pe = static_cast<poll_entry_t *> (handle_);
|
||||||
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_DEL, pe->fd, &pe->ev);
|
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_DEL, pe->fd, &pe->ev);
|
||||||
errno_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
pe->fd = retired_fd;
|
pe->fd = retired_fd;
|
||||||
@@ -123,7 +123,7 @@ void zmq::epoll_t::rm_fd (handle_t handle_)
|
|||||||
void zmq::epoll_t::set_pollin (handle_t handle_)
|
void zmq::epoll_t::set_pollin (handle_t handle_)
|
||||||
{
|
{
|
||||||
check_thread ();
|
check_thread ();
|
||||||
poll_entry_t *pe = (poll_entry_t *) handle_;
|
poll_entry_t *pe = static_cast<poll_entry_t *> (handle_);
|
||||||
pe->ev.events |= EPOLLIN;
|
pe->ev.events |= EPOLLIN;
|
||||||
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
||||||
errno_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
@@ -132,8 +132,8 @@ void zmq::epoll_t::set_pollin (handle_t handle_)
|
|||||||
void zmq::epoll_t::reset_pollin (handle_t handle_)
|
void zmq::epoll_t::reset_pollin (handle_t handle_)
|
||||||
{
|
{
|
||||||
check_thread ();
|
check_thread ();
|
||||||
poll_entry_t *pe = (poll_entry_t *) handle_;
|
poll_entry_t *pe = static_cast<poll_entry_t *> (handle_);
|
||||||
pe->ev.events &= ~((short) EPOLLIN);
|
pe->ev.events &= ~(static_cast<short> (EPOLLIN));
|
||||||
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
||||||
errno_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ void zmq::epoll_t::reset_pollin (handle_t handle_)
|
|||||||
void zmq::epoll_t::set_pollout (handle_t handle_)
|
void zmq::epoll_t::set_pollout (handle_t handle_)
|
||||||
{
|
{
|
||||||
check_thread ();
|
check_thread ();
|
||||||
poll_entry_t *pe = (poll_entry_t *) handle_;
|
poll_entry_t *pe = static_cast<poll_entry_t *> (handle_);
|
||||||
pe->ev.events |= EPOLLOUT;
|
pe->ev.events |= EPOLLOUT;
|
||||||
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
||||||
errno_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
@@ -150,8 +150,8 @@ void zmq::epoll_t::set_pollout (handle_t handle_)
|
|||||||
void zmq::epoll_t::reset_pollout (handle_t handle_)
|
void zmq::epoll_t::reset_pollout (handle_t handle_)
|
||||||
{
|
{
|
||||||
check_thread ();
|
check_thread ();
|
||||||
poll_entry_t *pe = (poll_entry_t *) handle_;
|
poll_entry_t *pe = static_cast<poll_entry_t *> (handle_);
|
||||||
pe->ev.events &= ~((short) EPOLLOUT);
|
pe->ev.events &= ~(static_cast<short> (EPOLLOUT));
|
||||||
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev);
|
||||||
errno_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ void zmq::epoll_t::loop ()
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Execute any due timers.
|
// Execute any due timers.
|
||||||
int timeout = (int) execute_timers ();
|
int timeout = static_cast<int> (execute_timers ());
|
||||||
|
|
||||||
if (get_load () == 0) {
|
if (get_load () == 0) {
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
@@ -191,7 +191,8 @@ void zmq::epoll_t::loop ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
poll_entry_t *pe = ((poll_entry_t *) ev_buf[i].data.ptr);
|
poll_entry_t *pe =
|
||||||
|
(static_cast<poll_entry_t *> (ev_buf[i].data.ptr));
|
||||||
|
|
||||||
if (pe->fd == retired_fd)
|
if (pe->fd == retired_fd)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -100,9 +100,9 @@ const sockaddr *zmq::ipc_address_t::addr () const
|
|||||||
socklen_t zmq::ipc_address_t::addrlen () const
|
socklen_t zmq::ipc_address_t::addrlen () const
|
||||||
{
|
{
|
||||||
if (!address.sun_path[0] && address.sun_path[1])
|
if (!address.sun_path[0] && address.sun_path[1])
|
||||||
return (socklen_t) strlen (address.sun_path + 1) + sizeof (sa_family_t)
|
return static_cast<socklen_t> (strlen (address.sun_path + 1))
|
||||||
+ 1;
|
+ sizeof (sa_family_t) + 1;
|
||||||
return (socklen_t) sizeof address;
|
return static_cast<socklen_t> (sizeof address);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -252,7 +252,8 @@ zmq::fd_t zmq::ipc_connecter_t::connect ()
|
|||||||
#else
|
#else
|
||||||
socklen_t len = sizeof (err);
|
socklen_t len = sizeof (err);
|
||||||
#endif
|
#endif
|
||||||
int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char *) &err, &len);
|
int rc = getsockopt (s, SOL_SOCKET, SO_ERROR,
|
||||||
|
reinterpret_cast<char *> (&err), &len);
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
if (errno == ENOPROTOOPT)
|
if (errno == ENOPROTOOPT)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|||||||
@@ -201,13 +201,13 @@ int zmq::ipc_listener_t::get_address (std::string &addr_)
|
|||||||
#else
|
#else
|
||||||
socklen_t sl = sizeof (ss);
|
socklen_t sl = sizeof (ss);
|
||||||
#endif
|
#endif
|
||||||
int rc = getsockname (s, (sockaddr *) &ss, &sl);
|
int rc = getsockname (s, reinterpret_cast<sockaddr *> (&ss), &sl);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
addr_.clear ();
|
addr_.clear ();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc_address_t addr ((struct sockaddr *) &ss, sl);
|
ipc_address_t addr (reinterpret_cast<struct sockaddr *> (&ss), sl);
|
||||||
return addr.to_string (addr_);
|
return addr.to_string (addr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,8 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind the socket to the file path.
|
// Bind the socket to the file path.
|
||||||
rc = bind (s, (sockaddr *) address.addr (), address.addrlen ());
|
rc = bind (s, const_cast<sockaddr *> (address.addr ()),
|
||||||
|
address.addrlen ());
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void zmq::seed_random ()
|
|||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
int pid = static_cast<int> (GetCurrentProcessId ());
|
int pid = static_cast<int> (GetCurrentProcessId ());
|
||||||
#else
|
#else
|
||||||
int pid = (int) getpid ();
|
int pid = static_cast<int> (getpid ());
|
||||||
#endif
|
#endif
|
||||||
srand (static_cast<unsigned int> (clock_t::now_us () + pid));
|
srand (static_cast<unsigned int> (clock_t::now_us () + pid));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ void zmq::socket_poller_t::rebuild ()
|
|||||||
if (_pollset_size == 0)
|
if (_pollset_size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_pollfds = (pollfd *) malloc (_pollset_size * sizeof (pollfd));
|
_pollfds = static_cast<pollfd *> (malloc (_pollset_size * sizeof (pollfd)));
|
||||||
alloc_assert (_pollfds);
|
alloc_assert (_pollfds);
|
||||||
|
|
||||||
int item_nbr = 0;
|
int item_nbr = 0;
|
||||||
|
|||||||
@@ -128,8 +128,9 @@ int zmq::tune_tcp_keepalives (fd_t s_,
|
|||||||
#else
|
#else
|
||||||
#ifdef ZMQ_HAVE_SO_KEEPALIVE
|
#ifdef ZMQ_HAVE_SO_KEEPALIVE
|
||||||
if (keepalive_ != -1) {
|
if (keepalive_ != -1) {
|
||||||
int rc = setsockopt (s_, SOL_SOCKET, SO_KEEPALIVE, (char *) &keepalive_,
|
int rc =
|
||||||
sizeof (int));
|
setsockopt (s_, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
|
reinterpret_cast<char *> (&keepalive_), sizeof (int));
|
||||||
tcp_assert_tuning_error (s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
@@ -292,7 +293,7 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
const ssize_t rc = recv (s_, (char *) data_, size_, 0);
|
const ssize_t rc = recv (s_, static_cast<char *> (data_), size_, 0);
|
||||||
|
|
||||||
// Several errors are OK. When speculative read is being done we may not
|
// Several errors are OK. When speculative read is being done we may not
|
||||||
// be able to read a single byte from the socket. Also, SIGSTOP issued
|
// be able to read a single byte from the socket. Also, SIGSTOP issued
|
||||||
|
|||||||
@@ -291,7 +291,8 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
|
|||||||
socklen_t ss_len = sizeof (ss);
|
socklen_t ss_len = sizeof (ss);
|
||||||
#endif
|
#endif
|
||||||
#if defined ZMQ_HAVE_SOCK_CLOEXEC && defined HAVE_ACCEPT4
|
#if defined ZMQ_HAVE_SOCK_CLOEXEC && defined HAVE_ACCEPT4
|
||||||
fd_t sock = ::accept4 (_s, (struct sockaddr *) &ss, &ss_len, SOCK_CLOEXEC);
|
fd_t sock = ::accept4 (_s, reinterpret_cast<struct sockaddr *> (&ss),
|
||||||
|
&ss_len, SOCK_CLOEXEC);
|
||||||
#else
|
#else
|
||||||
fd_t sock =
|
fd_t sock =
|
||||||
::accept (_s, reinterpret_cast<struct sockaddr *> (&ss), &ss_len);
|
::accept (_s, reinterpret_cast<struct sockaddr *> (&ss), &ss_len);
|
||||||
@@ -318,7 +319,7 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
|
|||||||
for (options_t::tcp_accept_filters_t::size_type i = 0;
|
for (options_t::tcp_accept_filters_t::size_type i = 0;
|
||||||
i != options.tcp_accept_filters.size (); ++i) {
|
i != options.tcp_accept_filters.size (); ++i) {
|
||||||
if (options.tcp_accept_filters[i].match_address (
|
if (options.tcp_accept_filters[i].match_address (
|
||||||
(struct sockaddr *) &ss, ss_len)) {
|
reinterpret_cast<struct sockaddr *> (&ss), ss_len)) {
|
||||||
matched = true;
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,8 +457,9 @@ void zmq::udp_engine_t::in_event ()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int nbytes = recvfrom (_fd, _in_buffer, MAX_UDP_MSG, 0,
|
int nbytes =
|
||||||
(sockaddr *) &in_address, &in_addrlen);
|
recvfrom (_fd, _in_buffer, MAX_UDP_MSG, 0,
|
||||||
|
reinterpret_cast<sockaddr *> (&in_address), &in_addrlen);
|
||||||
if (nbytes == -1) {
|
if (nbytes == -1) {
|
||||||
#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE
|
#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE
|
||||||
errno_assert (errno != EBADF && errno != EFAULT && errno != ENOMEM
|
errno_assert (errno != EBADF && errno != EFAULT && errno != ENOMEM
|
||||||
|
|||||||
@@ -831,7 +831,7 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
|||||||
pollfd *pollfds = spollfds;
|
pollfd *pollfds = spollfds;
|
||||||
|
|
||||||
if (nitems_ > ZMQ_POLLITEMS_DFLT) {
|
if (nitems_ > ZMQ_POLLITEMS_DFLT) {
|
||||||
pollfds = (pollfd *) malloc (nitems_ * sizeof (pollfd));
|
pollfds = static_cast<pollfd *> (malloc (nitems_ * sizeof (pollfd)));
|
||||||
alloc_assert (pollfds);
|
alloc_assert (pollfds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user