[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are Goto's in the Linux Kernel necessarily bad?



Mike Connor wrote:
> 
> It depends on why they're being used.  In the kernel, they are being used
> for error handling, and pretty much only error handling in complex
> situations.
> 
> A typical situation is setting up a data structure or some hardware that
> requires multiple steps, like say 10.  If any step goes wrong, you cannot
> continue.  To do this "properly", it would require a 10 deep nested
> if/then/else statement.  They get nasty around 3.  The goto way is much
> easier to read and modify.  Plus, it's faster executing (~75 extra
> machine instructions to do a 10 deep), which matters  when some of these
> functions are executing many times a second (sched.c).
> 
> Any other use of a goto usually means bad code or intentionally
>man you are a delight to read

 obfuscated.
> 
> Mike
> 
> On Sat, 15 Feb 2003, Jonathan Drews wrote:
> 
> > I have heard that there are many goto statements in the Linux kernel.
> > The accepted convention is that goto statements are a source of
> > programming errors and therefore inherently bad. Is this true and will
> > the use of these goto statements make the Linux kernel  unstable?
> >
> >
> >                                                       TIA,
> >
> >                                                       Jonathan
> >
> > -
> > To unsubscribe, send email to majordomo@silug.org with
> > "unsubscribe silug-discuss" in the body.
> >
> 
> -
> To unsubscribe, send email to majordomo@silug.org with
> "unsubscribe silug-discuss" in the bod

-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.