From 9df7ed074093413f2ec04c27a7a07bfbff7e64b8 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Sat, 30 Jan 2016 03:42:29 -0500 Subject: [PATCH] place a ZMQ_UNUSED macro and replace all unused variables with ZMQ_UNUSED macro Backported from zeromq/libzmq@bff2284 # Conflicts: # src/client.cpp # src/server.cpp --- include/zmq.h | 6 ++++++ src/dealer.cpp | 3 +-- src/pair.cpp | 3 +-- src/pull.cpp | 3 +-- src/push.cpp | 4 ++-- src/router.cpp | 3 +-- src/stream.cpp | 3 +-- src/tcp.cpp | 10 +++++----- src/tcp_address.cpp | 9 ++++----- src/xsub.cpp | 3 +-- 10 files changed, 23 insertions(+), 24 deletions(-) diff --git a/include/zmq.h b/include/zmq.h index 8970d5bd..4f0af82c 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -407,6 +407,12 @@ ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string); /* Deprecated method */ ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend); +/******************************************************************************/ +/* 0MQ General */ +/******************************************************************************/ + +#define ZMQ_UNUSED(object) (void)object + #undef ZMQ_EXPORT #ifdef __cplusplus diff --git a/src/dealer.cpp b/src/dealer.cpp index d330d0b1..7edd461e 100644 --- a/src/dealer.cpp +++ b/src/dealer.cpp @@ -34,8 +34,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 66efab92..4113e90a 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -36,8 +36,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 a7d246d1..15620b27 100644 --- a/src/pull.cpp +++ b/src/pull.cpp @@ -34,8 +34,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 acb852c3..5603d100 100644 --- a/src/push.cpp +++ b/src/push.cpp @@ -34,8 +34,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 6fabf67f..a4badc0b 100644 --- a/src/router.cpp +++ b/src/router.cpp @@ -55,8 +55,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/stream.cpp b/src/stream.cpp index 987a2679..b1a983b8 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -48,8 +48,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 a02ea153..cc04fa5c 100755 --- a/src/tcp.cpp +++ b/src/tcp.cpp @@ -84,13 +84,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 1c758125..eabbe7a8 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -53,7 +53,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_) { // TODO: Unused parameter, IPv6 support not implemented for Solaris. - (void) ipv6_; + ZMQ_UNUSED(ipv6_); // Create a socket. int fd = open_socket (AF_INET, SOCK_DGRAM, 0); @@ -117,7 +117,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_) int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_) { // TODO: Unused parameter, IPv6 support not implemented for AIX or HP/UX. - (void) ipv6_; + ZMQ_UNUSED(ipv6_); // Create a socket. int sd = open_socket (AF_INET, SOCK_DGRAM, 0); @@ -195,9 +195,8 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_) // This is true especially of Windows. int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_) { - // 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 c4381a26..7e815d5a 100644 --- a/src/xsub.cpp +++ b/src/xsub.cpp @@ -45,8 +45,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_);