Jumping into blocks

ARPA at brl-smoke ARPA at brl-smoke
Tue Apr 29 08:42:00 AEST 1986


>>So, assuming that goatooze are acceptable for error handling, but jumping
>>into a block is forbidden, what's the best way to write this?  Use two
>>braches, and hide the common code at the bottom of main()?  Set an error
>>flag and test it outside the while?  (Ugh, that requires an artificial
>>boolean *and* a break statement.)  Make usage() a non-returning function
>>instead of a label?  (My usual preference.)  Duplicate the code?

I've seen two variations that *I* prefer:

	1) If you're in a condition that calls for bailing out, use a function
	   that prints an error message (to the appropriate place) and call
	   exit(). This is what I tend to use for usage/fatal error kinds of
	   situations.

	2) In some (kernel) routines, one may have several "error" conditions
	   that have a common set of "cleanup procedures" (like setting an
	   error code or some such thing) before returning. In this case,
	   several "gohtoose" that wind up at the bottom of the routine seem
	   the neatest (well, least sloppy) way of doing it.

I've used the other variations that you mentioned, but wouldn't in anything
that anyone else would have to see/support.

	Rich Brown
	Downers Grove, IL

P.S.	I take that back. I've never jumped into a block like that. I think
	I would put that under the heading of "tacky".



More information about the Comp.lang.c mailing list