[lkml]   [2003]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Patch?: linux-2.5.59/sound/soundcore.c referenced non-existant errno variable
"Adam J. Richter" <> said:
> To my knowledge, a goto in this case is not necessary for
> avoiding code duplication. If there are a small number of failable
> steps that may need to be unwound, you could adopt the style of my patch
> (which shortened the code slightly):
> if (step1() == ok) {
> if (step2() == ok) {
> if (strep3() == ok)
> return OK;
> undo_step2();
> }
> undo_step1();
> }
> return failure;

The "undo_stepX()"'s pollute the CPU's cache, and (even much worse) the
gentle reader's.

> If the nesting gets any deeper than this, then a more
> understandable solution for readability than using goto would be to
> define a separate inline routine.

Can't be done (cleanly) in many cases due to function semantics in C,
polutes CPU cache as above, screws up or gives bad code due to compiler
bugs. Plus has the gentle reader who wants to check error handling chasing
all over the place.

> In general, I recommend using goto only when it is
> topologically necessary to avoid code duplication or due to some
> compiler quirk where you want to sqeeze a few more cycles out of code
> in a critical path. That way, the use of goto basically flags these
> unusual cases for other programmers.

IMVHO, any general criterion that is not strictly based on code
understandability, possibly mitigated by a justified need of maximal speed,
is flawed. This might come close, but won't cut it for me.
Dr. Horst H. von Brand User #22616
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:32    [W:0.094 / U:1.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site