From f0b0e80da008649b91da12cb15f6af61f5b06bd1 Mon Sep 17 00:00:00 2001 From: Laurent Stacul Date: Fri, 21 Feb 2020 08:17:45 +0000 Subject: [PATCH] Fix unused-variable warning in perf/proxy_thr.cpp --- RELICENSE/lstacul.md | 14 ++++++++++++++ perf/proxy_thr.cpp | 24 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 RELICENSE/lstacul.md diff --git a/RELICENSE/lstacul.md b/RELICENSE/lstacul.md new file mode 100644 index 00000000..b95c149a --- /dev/null +++ b/RELICENSE/lstacul.md @@ -0,0 +1,14 @@ +# Permission to Relicense under MPLv2 + +This is a statement by Laurent Stacul +that grants permission to relicense its copyrights in the libzmq C++ +library (ZeroMQ) under the Mozilla Public License v2 (MPLv2). + +A portion of the commits made by the Github handle "stac47", with +commit author "Laurent Stacul ", are copyright of +Laurent Stacul . +This document hereby grants the libzmq project team to relicense libzmq, +including all past, present and future contributions of the author listed above. + +Laurent Stacul +2020/02/21 diff --git a/perf/proxy_thr.cpp b/perf/proxy_thr.cpp index e8029d5a..eca57fa6 100644 --- a/perf/proxy_thr.cpp +++ b/perf/proxy_thr.cpp @@ -74,6 +74,14 @@ #define TEST_ASSERT_SUCCESS_ERRNO(expr) \ test_assert_success_message_errno_helper (expr, NULL, #expr) +// This macro is used to avoid-variable warning. If used with an expression, +// the sizeof is not evaluated to avoid polluting the assembly code. +#ifdef NDEBUG +#define ASSERT_EXPR_SAFE(x) do { (void)sizeof(x);} while (0) +#else +#define ASSERT_EXPR_SAFE(x) assert(x) +#endif + static uint64_t message_count = 0; static size_t message_size = 0; @@ -238,7 +246,7 @@ static void proxy_thread_main (void *pvoid) if (ep != NULL) { assert (strlen (ep) > 5); rc = zmq_bind (frontend_xsub, ep); - assert (rc == 0); + ASSERT_EXPR_SAFE (rc == 0); } } @@ -252,7 +260,7 @@ static void proxy_thread_main (void *pvoid) int optval = 1; rc = zmq_setsockopt (backend_xpub, ZMQ_XPUB_NODROP, &optval, sizeof (optval)); - assert (rc == 0); + ASSERT_EXPR_SAFE (rc == 0); set_hwm (backend_xpub); @@ -262,7 +270,7 @@ static void proxy_thread_main (void *pvoid) if (ep != NULL) { assert (strlen (ep) > 5); rc = zmq_bind (backend_xpub, ep); - assert (rc == 0); + ASSERT_EXPR_SAFE (rc == 0); } } @@ -275,7 +283,7 @@ static void proxy_thread_main (void *pvoid) // Bind CONTROL rc = zmq_bind (control_rep, cfg->control_endpoint); - assert (rc == 0); + ASSERT_EXPR_SAFE (rc == 0); // Start proxying! @@ -298,12 +306,12 @@ void terminate_proxy (const proxy_hwm_cfg_t *cfg) // Connect CONTROL-REQ: a socket to which send commands int rc = zmq_connect (control_req, cfg->control_endpoint); - assert (rc == 0); + ASSERT_EXPR_SAFE (rc == 0); // Ask the proxy to exit: the subscriber has received all messages rc = zmq_send (control_req, "TERMINATE", 9, 0); - assert (rc == 9); + ASSERT_EXPR_SAFE (rc == 9); zmq_close (control_req); } @@ -327,7 +335,7 @@ int main (int argc, char *argv[]) assert (context); int rv = zmq_ctx_set (context, ZMQ_IO_THREADS, 4); - assert (rv == 0); + ASSERT_EXPR_SAFE (rv == 0); // START ALL SECONDARY THREADS @@ -395,7 +403,7 @@ int main (int argc, char *argv[]) zmq_threadclose (proxy); int rc = zmq_ctx_term (context); - assert (rc == 0); + ASSERT_EXPR_SAFE (rc == 0); return 0; }