[Kamailio-Devel] Use of goto

Daniel Corbe daniel.junkmail at gmail.com
Tue Jan 27 22:13:20 CET 2009


You should read http://kerneltrap.org/node/553/2131
There's plenty of cases where goto is justified and certainly branching out
into error conditions is one of them.  At least on the intel architecture
goto typically translates 1:1 to the jmp instruction and is monumentally
more efficient than constructing complex and hard to understand loops.

-Daniel

On Tue, Jan 27, 2009 at 12:54 PM, Johansson Olle E <oej at edvina.net> wrote:

> Hi!
>
> I've been spending some time going through the mi_* modules for
> doxygen and other format changes, as well as checking spelling of log
> messages and docs.
>
> I see a lot of code with goto's that isn't needed and can be changed.
> Most common is "goto error" where error just is one line that returns
> an error code. This can simply be changed so that the "goto error" is
> replaced with "return <errorcode>;"
>
> I don't know your code guidelines, but this code would not be approved
> in Asterisk. We're trying to simplify code paths as much as possible
> to make things easier to understand and follow. Overuse of goto
> doesn't make code easy to read, in my opinion...
>
> What do you think?
>
> /O
>
>
> PS: Fixing code is a good way for me to learn how Kamailio works on
> the inside :-)
>
>
> _______________________________________________
> Kamailio (OpenSER) - Devel mailing list
> Devel at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/devel
> http://lists.openser-project.org/cgi-bin/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/devel/attachments/20090127/859887bc/attachment.htm 


More information about the Devel mailing list