[15640] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

Re: encrypted_challenge_main.c

daemon@ATHENA.MIT.EDU (Jeff Blaine)
Wed Mar 24 10:50:36 2010

Message-ID: <4BAA26A2.8060208@kickflop.net>
Date: Wed, 24 Mar 2010 10:50:10 -0400
From: Jeff Blaine <jblaine@kickflop.net>
MIME-Version: 1.0
To: Greg Hudson <ghudson@mit.edu>
In-Reply-To: <1269441417.7493.538.camel@ray>
Cc: "krbdev@mit.edu" <krbdev@mit.edu>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: krbdev-bounces@mit.edu

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 ?
_______________________________________________
krbdev mailing list             krbdev@mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev

home help back first fref pref prev next nref lref last post