encrypted_challenge_main.c
Jeff Blaine
jblaine at kickflop.net
Wed Mar 24 10:50:10 EDT 2010
On 3/24/2010 10:36 AM, Greg Hudson wrote:
> 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:
> http://mailman.mit.edu/pipermail/krbdev/2009-April/007613.html
I'm definitely not fond of it either.
Would line ~415:
if (padata->length) {
} else {
}
be better then as:
if (padata->length && retval == 0) {
...
} else if (retval == 0) {
...
}
so that we don't enter either of those if gak_fct() did
not return 0 ?
More information about the krbdev
mailing list