[zeromq-dev] Questions about Coding Style
john skaller
skaller at users.sourceforge.net
Sat Feb 11 21:27:29 CET 2012
On 12/02/2012, at 6:47 AM, niXman wrote:
> I'm confused ...
> Do you all agree with that the arguments must be checked? And with the
> fact that in case of error of arguments is not necessary to use assert
> but set errno and return -1?
IMHO, if you do a check for a NULL pointer you should use assert.
You want to crash the program instantly, not return an error the
user might not test.
If the check is about resources, eg "is there enough disk space"
then you probably return an error code, because that condition
is outside the programmers control, but doing something about
it inside the program may not be.
The one I get a lot is: port address not available. I try to bind
a socket, but it is already in use (because there's already another
server running).
The client program could chose another port. So this one returns
an error code.
--
john skaller
skaller at users.sourceforge.net
More information about the zeromq-dev
mailing list