[zeromq-dev] Unused variable
Luca Fascione
lukes at wetafx.co.nz
Mon Feb 13 22:56:40 CET 2012
Hi Nadav,
I looked at your patch. I agree is essentially the same as mine.
If I may suggest two improvements, though, these would be:
- I suspect it would be best to namespace all ZMQ macros with a
prefix, so that your VERIFY would be ZMQ_VERIFY
- I (personally) dislike the change of name you've chosen, I think it
would be clearer to call your macro ZMQ_ASSERT, so to imply it's a
slightly customized version of the assert function, which has
essentially the same semantics
Aside from that, and fwiw, I think your proposal and mine are just as
effective.
So.. yeah, could some maintainer chime in, and get the code in there,
please? (Happy to send in a patch for my way if you'd rather, but it
seems Nadav's might be a better way forward, to support further
tailoring of assert)
Luca
On 13/02/12 14:37, Nadav Samet wrote:
> I encountered the same issue a while ago and sent a pull request
> through github, but I forgot to follow up on this.
>
> https://github.com/zeromq/zeromq2-2/pull/2
>
>
> On Sun, Feb 12, 2012 at 5:32 PM, Luca Fascione <lukes at wetafx.co.nz
> <mailto:lukes at wetafx.co.nz>> wrote:
>
> Hey guys,
> there's a couple instances in zmq.hpp that include a pattern like
> this:
>
> inline ~message_t ()
> {
> int rc = zmq_msg_close (&msg);
> assert (rc == 0);
> }
>
> in which a variable (rc in this case) is allocated for the sole
> purpose
> of being tested in an assert.
>
> As we compile with high warning levels, these variables turn into
> warnings such as this:
>
> .../zeromq-2.1.10/include/zmq.hpp: In destructor
> 'zmq::message_t::~message_t()':
> .../zeromq-2.1.10/include/zmq.hpp:108: warning: unused variable 'rc'
> [-Wunused-variable]
>
> which are annoying, especially in an otherwise clean build. I
> would like
> to mark these variables unused in the code,
> but I'm a little unsure how you guys would like to see it done.
> It seems the way would be to add to zmq.h
>
> /* Mark variables unused to quiet warnings */
> #define ZMQ_UNUSED(x) (void)sizeof(x)
>
> and then change the method above into this:
>
> inline ~message_t ()
> {
> int rc = zmq_msg_close (&msg);
> ZMQ_UNUSED(rc);
> assert (rc == 0);
> }
>
> if this sounds allright I'll submit a pull request in the near future
> Luca
>
> --
> Luca Fascione
> Rendering Research Lead - Weta Digital
> Phone: +64 4 909 6870 <tel:%2B64%20%204%20909%206870> (x6870)
> Mobile: +64 21 0764 862 <tel:%2B64%2021%200764%20862>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org <mailto:zeromq-dev at lists.zeromq.org>
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
>
>
> --
> -Nadav
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
--
Luca Fascione
Rendering Research Lead - Weta Digital
Phone: +64 4 909 6870 (x6870)
Mobile: +64 21 0764 862
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120214/66b9648f/attachment.htm>
More information about the zeromq-dev
mailing list