Greg Hudson ghudson at MIT.EDU
Wed Mar 24 10:36:57 EDT 2010

On Wed, 2010-03-24 at 10:15 -0400, Jeff Blaine wrote:
> Please take note of the 'retval' usage, specifically the
> final 'if (retval == 0)' shown (C), which seems really poor as
> it's checking on the return value of either "A" or "B" and
> it doesn't know/care which.

You can read "if (retval == 0)" as "if nothing has failed yet."  This
style of usage is sometimes called an "if ladder."  Each substantive
operation is wrapped in "if (retval == 0)", so as soon as anything
fails, control eventually drops to the end of the function, possibly
doing a few harmless things along the way (such as setting up the value
of scratch).

I'm not personally fond of it, but I wasn't able to get consensus on
mandating another prevalent style of flow control ("goto cleanup") when
I tried; see:

More information about the krbdev mailing list