From 65ae6b33fd3451ea29d75889f807802f8a48c0bf Mon Sep 17 00:00:00 2001 From: Giesecke Date: Sat, 12 May 2018 09:18:46 +0200 Subject: [PATCH] Problem: poller_t::wait_all and active_poller_t::wait declare int return type but actually return an element count Solution: change return type to size_t, remove a redundant if in consequence --- zmq.hpp | 6 +++--- zmq_addon.hpp | 19 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/zmq.hpp b/zmq.hpp index 837a73e..dd9c28c 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -1091,14 +1091,14 @@ template class poller_t } } - int wait_all (std::vector &poller_events, - const std::chrono::microseconds timeout) + size_t wait_all (std::vector &poller_events, + const std::chrono::microseconds timeout) { int rc = zmq_poller_wait_all (poller_ptr.get (), poller_events.data (), static_cast (poller_events.size ()), static_cast (timeout.count ())); if (rc > 0) - return rc; + return static_cast (rc); #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 3) if (zmq_errno () == EAGAIN) diff --git a/zmq_addon.hpp b/zmq_addon.hpp index d85b70f..cc8c674 100644 --- a/zmq_addon.hpp +++ b/zmq_addon.hpp @@ -398,7 +398,7 @@ class active_poller_t base_poller.modify (socket, events); } - int wait (std::chrono::milliseconds timeout) + size_t wait (std::chrono::milliseconds timeout) { if (need_rebuild) { poller_events.resize (handlers.size ()); @@ -409,16 +409,13 @@ class active_poller_t } need_rebuild = false; } - const int count = base_poller.wait_all (poller_events, timeout); - if (count != 0) { - std::for_each (poller_events.begin (), - poller_events.begin () + count, - [](zmq_poller_event_t &event) { - if (event.user_data != NULL) - (*reinterpret_cast ( - event.user_data)) (event.events); - }); - } + const auto count = base_poller.wait_all (poller_events, timeout); + std::for_each (poller_events.begin (), poller_events.begin () + count, + [](zmq_poller_event_t &event) { + if (event.user_data != NULL) + (*reinterpret_cast ( + event.user_data)) (event.events); + }); return count; }