From 49df2f416cd43e9e18f3dbd964271c5cca835729 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 15 May 2011 13:12:09 +0200 Subject: Fixes warning when compiling with MSVC on Win64 Signed-off-by: Martin Sustrik --- src/array.hpp | 8 ++++---- src/dist.cpp | 2 +- src/encoder.hpp | 2 +- src/err.cpp | 2 +- src/fq.cpp | 6 +++--- src/ip.cpp | 10 +++++----- src/lb.cpp | 2 +- src/own.cpp | 2 +- src/select.cpp | 7 ++++--- src/tcp_socket.cpp | 16 ++++++++-------- src/tcp_socket.hpp | 6 ++++-- src/xrep.cpp | 7 +++---- src/zmq.cpp | 3 ++- 13 files changed, 38 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/array.hpp b/src/array.hpp index b9f7f78..1d18e48 100644 --- a/src/array.hpp +++ b/src/array.hpp @@ -99,7 +99,7 @@ namespace zmq inline void push_back (T *item_) { if (item_) - item_->set_array_index (items.size ()); + item_->set_array_index ((int) items.size ()); items.push_back (item_); } @@ -109,7 +109,7 @@ namespace zmq inline void erase (size_type index_) { if (items.back ()) - items.back ()->set_array_index (index_); + items.back ()->set_array_index ((int) index_); items [index_] = items.back (); items.pop_back (); } @@ -117,9 +117,9 @@ namespace zmq inline void swap (size_type index1_, size_type index2_) { if (items [index1_]) - items [index1_]->set_array_index (index2_); + items [index1_]->set_array_index ((int) index2_); if (items [index2_]) - items [index2_]->set_array_index (index1_); + items [index2_]->set_array_index ((int) index1_); std::swap (items [index1_], items [index2_]); } diff --git a/src/dist.cpp b/src/dist.cpp index c15ab6b..7c15bfd 100644 --- a/src/dist.cpp +++ b/src/dist.cpp @@ -69,7 +69,7 @@ void zmq::dist_t::terminate () zmq_assert (!terminating); terminating = true; - sink->register_term_acks (pipes.size ()); + sink->register_term_acks ((int) pipes.size ()); for (pipes_t::size_type i = 0; i != pipes.size (); i++) pipes [i]->terminate (); } diff --git a/src/encoder.hpp b/src/encoder.hpp index 617b65b..90b5ffe 100644 --- a/src/encoder.hpp +++ b/src/encoder.hpp @@ -86,7 +86,7 @@ namespace zmq // first-message-offset. if (beginning) { if (offset_ && *offset_ == -1) - *offset_ = pos; + *offset_ = (int) pos; beginning = false; } } diff --git a/src/err.cpp b/src/err.cpp index 8ac7dd9..31e2974 100644 --- a/src/err.cpp +++ b/src/err.cpp @@ -190,7 +190,7 @@ void zmq::win_error (char *buffer_, size_t buffer_size_) DWORD errcode = GetLastError (); DWORD rc = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL, - SUBLANG_DEFAULT), buffer_, buffer_size_, NULL ); + SUBLANG_DEFAULT), buffer_, (DWORD) buffer_size_, NULL ); zmq_assert (rc); } diff --git a/src/fq.cpp b/src/fq.cpp index ef68016..392e554 100644 --- a/src/fq.cpp +++ b/src/fq.cpp @@ -81,7 +81,7 @@ void zmq::fq_t::terminate () zmq_assert (!terminating); terminating = true; - sink->register_term_acks (pipes.size ()); + sink->register_term_acks ((int) pipes.size ()); for (pipes_t::size_type i = 0; i != pipes.size (); i++) pipes [i]->terminate (); } @@ -100,7 +100,7 @@ int zmq::fq_t::recv (msg_t *msg_, int flags_) errno_assert (rc == 0); // Round-robin over the pipes to get the next message. - for (int count = active; count != 0; count--) { + for (pipes_t::size_type count = active; count != 0; count--) { // Try to fetch new message. If we've already read part of the message // subsequent part should be immediately available. @@ -149,7 +149,7 @@ bool zmq::fq_t::has_in () // queueing algorithm. If there are no messages available current will // get back to its original value. Otherwise it'll point to the first // pipe holding messages, skipping only pipes with no messages available. - for (int count = active; count != 0; count--) { + for (pipes_t::size_type count = active; count != 0; count--) { if (pipes [current]->check_read ()) return true; diff --git a/src/ip.cpp b/src/ip.cpp index 3591f02..5de2485 100644 --- a/src/ip.cpp +++ b/src/ip.cpp @@ -200,7 +200,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_, // Initialize temporary output pointers with ip4_addr sockaddr *out_addr = (sockaddr *) &ip4_addr; - size_t out_addrlen = sizeof (ip4_addr); + socklen_t out_addrlen = (socklen_t) sizeof (ip4_addr); // 0 is not a valid port. if (!ip4_addr.sin_port) { @@ -211,7 +211,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_, // * resolves to INADDR_ANY. if (iface.compare("*") == 0) { ip4_addr.sin_addr.s_addr = htonl (INADDR_ANY); - zmq_assert (out_addrlen <= sizeof (*addr_)); + zmq_assert (out_addrlen <= (socklen_t) sizeof (*addr_)); memcpy (addr_, out_addr, out_addrlen); *addr_len_ = out_addrlen; return 0; @@ -222,7 +222,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_, if (rc != 0 && errno != ENODEV) return rc; if (rc == 0) { - zmq_assert (out_addrlen <= sizeof (*addr_)); + zmq_assert (out_addrlen <= (socklen_t) sizeof (*addr_)); memcpy (addr_, out_addr, out_addrlen); *addr_len_ = out_addrlen; return 0; @@ -259,7 +259,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_, // Use the first result. zmq_assert ((size_t) (res->ai_addrlen) <= sizeof (*addr_)); memcpy (addr_, res->ai_addr, res->ai_addrlen); - *addr_len_ = res->ai_addrlen; + *addr_len_ = (socklen_t) res->ai_addrlen; // Cleanup getaddrinfo after copying the possibly referenced result. if (res) @@ -308,7 +308,7 @@ int zmq::resolve_ip_hostname (sockaddr_storage *addr_, socklen_t *addr_len_, // Copy first result to output addr with hostname and service. zmq_assert ((size_t) (res->ai_addrlen) <= sizeof (*addr_)); memcpy (addr_, res->ai_addr, res->ai_addrlen); - *addr_len_ = res->ai_addrlen; + *addr_len_ = (socklen_t) res->ai_addrlen; freeaddrinfo (res); diff --git a/src/lb.cpp b/src/lb.cpp index e81df3a..8eb9157 100644 --- a/src/lb.cpp +++ b/src/lb.cpp @@ -58,7 +58,7 @@ void zmq::lb_t::terminate () zmq_assert (!terminating); terminating = true; - sink->register_term_acks (pipes.size ()); + sink->register_term_acks ((int) pipes.size ()); for (pipes_t::size_type i = 0; i != pipes.size (); i++) pipes [i]->terminate (); } diff --git a/src/own.cpp b/src/own.cpp index 57e183a..4cbfdd6 100644 --- a/src/own.cpp +++ b/src/own.cpp @@ -161,7 +161,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 (owned.size ()); + register_term_acks ((int) owned.size ()); owned.clear (); // Start termination process and check whether by chance we cannot diff --git a/src/select.cpp b/src/select.cpp index 56f9f74..35d8bd8 100644 --- a/src/select.cpp +++ b/src/select.cpp @@ -159,12 +159,13 @@ void zmq::select_t::loop () // Wait for events. struct timeval tv = {(long) (timeout / 1000), (long) (timeout % 1000 * 1000)}; - int rc = select (maxfd + 1, &readfds, &writefds, &exceptfds, - timeout ? &tv : NULL); - #ifdef ZMQ_HAVE_WINDOWS + int rc = select (0, &readfds, &writefds, &exceptfds, + timeout ? &tv : NULL); wsa_assert (rc != SOCKET_ERROR); #else + int rc = select (maxfd + 1, &readfds, &writefds, &exceptfds, + timeout ? &tv : NULL); if (rc == -1 && errno == EINTR) continue; errno_assert (rc != -1); diff --git a/src/tcp_socket.cpp b/src/tcp_socket.cpp index 6b10c1d..eb8b032 100644 --- a/src/tcp_socket.cpp +++ b/src/tcp_socket.cpp @@ -69,9 +69,9 @@ zmq::fd_t zmq::tcp_socket_t::get_fd () return s; } -int zmq::tcp_socket_t::write (const void *data, int size) +int zmq::tcp_socket_t::write (const void *data_, size_t size_) { - int nbytes = send (s, (char*) data, size, 0); + int nbytes = send (s, (char*) data_, (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). @@ -93,9 +93,9 @@ int zmq::tcp_socket_t::write (const void *data, int size) return (size_t) nbytes; } -int zmq::tcp_socket_t::read (void *data, int size) +int zmq::tcp_socket_t::read (void *data_, size_t size) { - int nbytes = recv (s, (char*) data, size, 0); + int nbytes = recv (s, (char*) data_, (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). @@ -176,9 +176,9 @@ zmq::fd_t zmq::tcp_socket_t::get_fd () return s; } -int zmq::tcp_socket_t::write (const void *data, int size) +int zmq::tcp_socket_t::write (const void *data_, size_t size_) { - ssize_t nbytes = send (s, data, size, 0); + ssize_t nbytes = send (s, data_, size_, 0); // Several errors are OK. When speculative write is being done we may not // be able to write a single byte to the socket. Also, SIGSTOP issued @@ -195,9 +195,9 @@ int zmq::tcp_socket_t::write (const void *data, int size) return (size_t) nbytes; } -int zmq::tcp_socket_t::read (void *data, int size) +int zmq::tcp_socket_t::read (void *data_, size_t size_) { - ssize_t nbytes = recv (s, data, size, 0); + ssize_t nbytes = recv (s, data_, size_, 0); // Several errors are OK. When speculative read is being done we may not // be able to read a single byte to the socket. Also, SIGSTOP issued diff --git a/src/tcp_socket.hpp b/src/tcp_socket.hpp index 3312605..4540bf9 100644 --- a/src/tcp_socket.hpp +++ b/src/tcp_socket.hpp @@ -21,6 +21,8 @@ #ifndef __ZMQ_TCP_SOCKET_HPP_INCLUDED__ #define __ZMQ_TCP_SOCKET_HPP_INCLUDED__ +#include + #include "fd.hpp" #include "stdint.hpp" @@ -49,13 +51,13 @@ namespace zmq // Writes data to the socket. Returns the number of bytes actually // written (even zero is to be considered to be a success). In case // of error or orderly shutdown by the other peer -1 is returned. - int write (const void *data, int size); + int write (const void *data_, size_t size_); // Reads data from the socket (up to 'size' bytes). Returns the number // of bytes actually read (even zero is to be considered to be // a success). In case of error or orderly shutdown by the other // peer -1 is returned. - int read (void *data, int size); + int read (void *data_, size_t size_); private: diff --git a/src/xrep.cpp b/src/xrep.cpp index f662aaf..2650f4e 100644 --- a/src/xrep.cpp +++ b/src/xrep.cpp @@ -83,7 +83,7 @@ void zmq::xrep_t::process_term (int linger_) { terminating = true; - register_term_acks (inpipes.size () + outpipes.size ()); + register_term_acks ((int) (inpipes.size () + outpipes.size ())); for (inpipes_t::iterator it = inpipes.begin (); it != inpipes.end (); ++it) @@ -257,7 +257,7 @@ int zmq::xrep_t::xrecv (msg_t *msg_, int flags_) } // Round-robin over the pipes to get the next message. - for (int count = inpipes.size (); count != 0; count--) { + for (inpipes_t::size_type count = inpipes.size (); count != 0; count--) { // Try to fetch new message. if (inpipes [current_in].active) @@ -299,7 +299,6 @@ int zmq::xrep_t::rollback (void) return 0; } - bool zmq::xrep_t::xhas_in () { // There are subsequent parts of the partly-read message available. @@ -310,7 +309,7 @@ bool zmq::xrep_t::xhas_in () // queueing algorithm. If there are no messages available current will // get back to its original value. Otherwise it'll point to the first // pipe holding messages, skipping only pipes with no messages available. - for (int count = inpipes.size (); count != 0; count--) { + for (inpipes_t::size_type count = inpipes.size (); count != 0; count--) { if (inpipes [current_in].active && inpipes [current_in].reader->check_read ()) return true; diff --git a/src/zmq.cpp b/src/zmq.cpp index b40d8b2..2fa60a2 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -587,10 +587,11 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) memcpy (&inset, &pollset_in, sizeof (fd_set)); memcpy (&outset, &pollset_out, sizeof (fd_set)); memcpy (&errset, &pollset_err, sizeof (fd_set)); - int rc = select (maxfd + 1, &inset, &outset, &errset, ptimeout); #if defined ZMQ_HAVE_WINDOWS + int rc = select (0, &inset, &outset, &errset, ptimeout); wsa_assert (rc != SOCKET_ERROR); #else + int rc = select (maxfd + 1, &inset, &outset, &errset, ptimeout); if (rc == -1 && errno == EINTR) return -1; errno_assert (rc >= 0); -- cgit v1.2.3