On Tue 27 Nov 2012 09:33:00 AM EST, Simo Sorce wrote:
On Tue, 2012-11-27 at 15:18 +0100, Pavel Březina wrote:
> Can you use "fail" pattern instead of calling the former each time
> allocation fails?
>
> Otherwise it looks good. I like the function.
>
I would like to vouch for always using 'done:' as a label and not other
arbitrary words.
Whether it is a failure or not should be determined by testing the error
value. This way we always use the same pattern, which helps in reading
the code.
There are three labels that we've used fairly consistently in the code
in the past:
done:
Used when the exit can be shared between success and failure modes,
possibly with some minor conditionals.
fail:
Used when some part of the exit processing requires
overly-complicated differences from the success case. I think 99% of
these could be merged to done: cases (and should be, where
appropriate), but I suspect there are a few situations where this may
need to remain. It should be the exception, though.
immediate:
Used in tevent_req routines where some part of the first phase of
the request (the one that initially creates the request object) fails
after the object is created. In this case, we need to return the object
and call tevent_req_immediate(), which I think should definitely remain
a separate label from "done:" to indicate to future maintainers that
exiting via this label is cutting directly to the completion callback.