[15639] 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 (Greg Hudson)
Wed Mar 24 10:37:03 2010

From: Greg Hudson <ghudson@mit.edu>
To: Jeff Blaine <jblaine@kickflop.net>
In-Reply-To: <4BAA1E74.7090606@kickflop.net>
Date: Wed, 24 Mar 2010 10:36:57 -0400
Message-ID: <1269441417.7493.538.camel@ray>
Mime-Version: 1.0
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 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


_______________________________________________
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