From d437d668c0c15fd9c547568191f5efe245962ff1 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Mon, 14 May 2018 22:07:10 +0200 Subject: [PATCH] Problem: MSVC warnings in connection with poll Solution: handle types properly --- src/poll.cpp | 7 ++++++- src/socket_poller.cpp | 5 ++++- src/zmq.cpp | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/poll.cpp b/src/poll.cpp index 6f9001b0..809685c6 100644 --- a/src/poll.cpp +++ b/src/poll.cpp @@ -43,6 +43,10 @@ #include "config.hpp" #include "i_poll_events.hpp" +#ifdef ZMQ_HAVE_WINDOWS +typedef unsigned long nfds_t; +#endif + zmq::poll_t::poll_t (const zmq::thread_ctx_t &ctx_) : worker_poller_base_t (ctx_), retired (false) @@ -155,7 +159,8 @@ void zmq::poll_t::loop () } // Wait for events. - int rc = poll (&pollset[0], pollset.size (), timeout ? timeout : -1); + int rc = poll (&pollset[0], static_cast (pollset.size ()), + timeout ? timeout : -1); #ifdef ZMQ_HAVE_WINDOWS wsa_assert (rc != SOCKET_ERROR); #else diff --git a/src/socket_poller.cpp b/src/socket_poller.cpp index eed1bfae..d0629ce5 100644 --- a/src/socket_poller.cpp +++ b/src/socket_poller.cpp @@ -31,6 +31,8 @@ #include "socket_poller.hpp" #include "err.hpp" +#include + static bool is_thread_safe (zmq::socket_base_t &socket) { // do not use getsockopt here, since that would fail during context termination @@ -575,7 +577,8 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, else if (timeout_ < 0) timeout = -1; else - timeout = end - now; + timeout = + static_cast (std::min (end - now, INT_MAX)); // Wait for events. while (true) { diff --git a/src/zmq.cpp b/src/zmq.cpp index 6301cdc8..056ea9c0 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -867,7 +867,8 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) else if (timeout_ < 0) timeout = -1; else - timeout = end - now; + timeout = + static_cast (std::min (end - now, INT_MAX)); // Wait for events. {