Coding Standards. was: a style question

Dave Caswell dbc at bushido.uucp
Tue Nov 20 12:25:47 AEST 1990


I said
>>rules like having a single entrance and exit point are good
>>ones.  They should be written down and strictly enforced.

.
.Blech!  Consider the following example:
.
>int fubar (x, y, z)
>int x, y, z;
>{
>    if (abnormal_condition_1)
>	return(foo);
>    if (abnormal_condition_2)
>	return(bar);
>    for (blah; blah; blah) {
>	do_some_stuff();
>	if (screwed_up)
>	    return(foobar);
>	do_other_stuff();
>    }
>    return(blech);

Try modifying this to pass in the error value, or how about if clean-up
code has to be written.  They're plenty of reasons to think that a goto
to ERROR_EXIT: (or whatever), is better than having more than one return
statement.

-- 
David Caswell                             dbc%bushido.uucp at umich.edu



More information about the Comp.lang.c mailing list