[Ardour-Dev] Hello, some tech talk, etc.

Gabriel M. Beddingfield gabriel at teuton.org
Thu Jul 5 05:26:18 PDT 2012

On 07/04/2012 10:37 PM, Paul Davis wrote:
> On Wed, Jul 4, 2012 at 11:31 PM, Razvan Cojocaru <razvanco at gmx.net 
> <mailto:razvanco at gmx.net>> wrote:
>      >> 1) recursive mutexes are not acceptable. google around for
>     decades-old
>      >> criticisms and the story of how they came to be part of pthreads.
>      >
>      > +1 !!
>     OK, so recursive mutexes are off-limits, but gotos are OK. :D
> goto's as a mean of avoiding multiple exit points from a function 
> without creating excessively complex nested conditionals are definitely 
> OK. gotos as a means of restarting a loop under odd conditions is not 
> ideal since it can normally be done better without them, but sometimes 
>   it just feels right.

Here's an excerpt from Linux's Documentation/CodingStyle:

		Chapter 7: Centralized exiting of functions

Albeit deprecated by some people, the equivalent of the goto statement is
used frequently by compilers in form of the unconditional jump instruction.

The goto statement comes in handy when a function exits from multiple
locations and some common work such as cleanup has to be done.

The rationale is:

- unconditional statements are easier to understand and follow
- nesting is reduced
- errors by not updating individual exit points when making
    modifications are prevented
- saves the compiler work to optimize redundant code away ;)

int fun(int a)
	int result = 0;
	char *buffer = kmalloc(SIZE);

	if (buffer == NULL)
		return -ENOMEM;

	if (condition1) {
		while (loop1) {
		result = 1;
		goto out;
	return result;


More information about the Ardour-Dev mailing list