Problem: MSVC warnings in connection with poll

Solution: handle types properly
This commit is contained in:
Simon Giesecke 2018-05-14 22:07:10 +02:00
parent e447f058e2
commit d437d668c0
3 changed files with 12 additions and 3 deletions

View File

@ -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<nfds_t> (pollset.size ()),
timeout ? timeout : -1);
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR);
#else

View File

@ -31,6 +31,8 @@
#include "socket_poller.hpp"
#include "err.hpp"
#include <limits.h>
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<int> (std::min<uint64_t> (end - now, INT_MAX));
// Wait for events.
while (true) {

View File

@ -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<int> (std::min<uint64_t> (end - now, INT_MAX));
// Wait for events.
{