[zeromq-dev] Questions about Coding Style

john skaller skaller at users.sourceforge.net
Sat Feb 11 11:43:45 CET 2012

On 11/02/2012, at 9:23 PM, niXman wrote:

> In the example above, it is enough to add check on null pointer ( if
> (optvallen_ && !(optval_)) {} ). This gives to the user more
> information about the error, instead of the silent crash.


> Regarding the check of pointers of sockets, everything is simple here.
> I'm actually very surprised that at present check is implemented in
> this way.
> Any function fulfilling operations with sockets except zmq_socket(),
> should check the pointer for its presence presence in ctx_t::sockets.
> (IMHO)
> It can seem an unnecessary overhead. But I consider that this overhead
> will be very scanty.

Well, if you believe that, you should write the rule up in the Style Guide.
I would add the qualifier: any "public" function. I.e. a member of the 
official 0MQ C bindings.

Then there's something concrete to:

(a) implement
(b) argue about 

I'm neutral at the moment. I can't see the harm in it.

Also, as to performance: the checks using assert() can be turned
off with -DNDEBUG already. So it may or may not make sense
to turn other checks on or off the same way, or to re-implement the
assert()ions so they *can't* be turned off with NDEBUG.

john skaller
skaller at users.sourceforge.net

More information about the zeromq-dev mailing list