From bff2284a50fa4a73fd0e52830f7e3e2964bf5d9c Mon Sep 17 00:00:00 2001 From: "reza.ebrahimi" Date: Fri, 14 Aug 2015 15:40:39 +0430 Subject: [PATCH] place a ZMQ_UNUSED macro and replace all unused variables with ZMQ_UNUSED macro --- include/zmq.h | 6 ++++++ src/client.cpp | 3 +-- src/dealer.cpp | 3 +-- src/pair.cpp | 3 +-- src/pull.cpp | 3 +-- src/push.cpp | 4 ++-- src/router.cpp | 3 +-- src/server.cpp | 3 +-- src/stream.cpp | 3 +-- src/tcp.cpp | 10 +++++----- src/tcp_address.cpp | 9 ++++----- src/xsub.cpp | 3 +-- 12 files changed, 25 insertions(+), 28 deletions(-) diff --git a/include/zmq.h b/include/zmq.h index d79d4bd8..5996f701 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -493,6 +493,12 @@ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg); ZMQ_EXPORT void zmq_threadclose (void* thread); +/******************************************************************************/ +/* 0MQ General */ +/******************************************************************************/ + +#define ZMQ_UNUSED(object) (void)object + #undef ZMQ_EXPORT #ifdef __cplusplus diff --git a/src/client.cpp b/src/client.cpp index fb0ccf19..1270e818 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -43,8 +43,7 @@ zmq::client_t::~client_t () void zmq::client_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void) subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_); diff --git a/src/dealer.cpp b/src/dealer.cpp index 2a3a5aa3..6587414b 100644 --- a/src/dealer.cpp +++ b/src/dealer.cpp @@ -44,8 +44,7 @@ zmq::dealer_t::~dealer_t () void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void) subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_); diff --git a/src/pair.cpp b/src/pair.cpp index ee2da2b2..48b25deb 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -47,8 +47,7 @@ zmq::pair_t::~pair_t () void zmq::pair_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void)subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_ != NULL); diff --git a/src/pull.cpp b/src/pull.cpp index 4754cda1..20724ae0 100644 --- a/src/pull.cpp +++ b/src/pull.cpp @@ -44,8 +44,7 @@ zmq::pull_t::~pull_t () void zmq::pull_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void)subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_); fq.attach (pipe_); diff --git a/src/push.cpp b/src/push.cpp index 65fac5ff..cc53f149 100644 --- a/src/push.cpp +++ b/src/push.cpp @@ -44,8 +44,8 @@ zmq::push_t::~push_t () void zmq::push_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void)subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); + // Don't delay pipe termination as there is no one // to receive the delimiter. pipe_->set_nodelay (); diff --git a/src/router.cpp b/src/router.cpp index 018cffb1..29e53cdb 100644 --- a/src/router.cpp +++ b/src/router.cpp @@ -66,8 +66,7 @@ zmq::router_t::~router_t () void zmq::router_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void)subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_); diff --git a/src/server.cpp b/src/server.cpp index 3b1a7fcb..dc549f8e 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -48,8 +48,7 @@ zmq::server_t::~server_t () void zmq::server_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void)subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_); diff --git a/src/stream.cpp b/src/stream.cpp index e8ce1b09..479da01e 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -58,8 +58,7 @@ zmq::stream_t::~stream_t () void zmq::stream_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void)subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_); diff --git a/src/tcp.cpp b/src/tcp.cpp index 5c74a642..14c392e5 100644 --- a/src/tcp.cpp +++ b/src/tcp.cpp @@ -94,13 +94,13 @@ void zmq::set_tcp_receive_buffer (fd_t sockfd_, int bufsize_) void zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_, int keepalive_idle_, int keepalive_intvl_) { // These options are used only under certain #ifdefs below. - (void)keepalive_; - (void)keepalive_cnt_; - (void)keepalive_idle_; - (void)keepalive_intvl_; + ZMQ_UNUSED(keepalive_); + ZMQ_UNUSED(keepalive_cnt_); + ZMQ_UNUSED(keepalive_idle_); + ZMQ_UNUSED(keepalive_intvl_); // If none of the #ifdefs apply, then s_ is unused. - (void)s_; + ZMQ_UNUSED(s_); // Tuning TCP keep-alives if platform allows it // All values = -1 means skip and leave it for OS diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index cda27365..5b2959ac 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -56,7 +56,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_src_) { // TODO: Unused parameter, IPv6 support not implemented for Solaris. - (void) ipv6_; + ZMQ_UNUSED(ipv6_); // Create a socket. const int fd = open_socket (AF_INET, SOCK_DGRAM, 0); @@ -123,7 +123,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_src_) { // TODO: Unused parameter, IPv6 support not implemented for AIX or HP/UX. - (void) ipv6_; + ZMQ_UNUSED(ipv6_); // Create a socket. const int sd = open_socket (AF_INET, SOCK_DGRAM, 0); @@ -209,9 +209,8 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_ // This is true especially of Windows. int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_src_) { - // All unused parameters. - (void) nic_; - (void) ipv6_; + ZMQ_UNUSED(nic_); + ZMQ_UNUSED(ipv6_); errno = ENODEV; return -1; diff --git a/src/xsub.cpp b/src/xsub.cpp index 615bab78..d01f8b08 100644 --- a/src/xsub.cpp +++ b/src/xsub.cpp @@ -55,8 +55,7 @@ zmq::xsub_t::~xsub_t () void zmq::xsub_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_) { - // subscribe_to_all_ is unused - (void) subscribe_to_all_; + ZMQ_UNUSED(subscribe_to_all_); zmq_assert (pipe_); fq.attach (pipe_);