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

Re: [libvirt] [PATCH 1/1] The use of goto



David Allan wrote:
> * Added a section on the appropriate and inappropriate uses of goto to the HACKING document and website.
> ---

Good to write that down.

> +Use of goto
> +===========
> +
> +The use of goto is not forbidden, and goto is widely used throughout
> +libvirt.  While the uncontrolled use of goto will quickly lead to
> +unmaintainable code, there is a place for it in well structured code
> +where its use increases readability and maintainability.
> +
> +The typical use of goto is to jump to cleanup code in the case of a
> +long list of actions, any of which may fail and cause the entire
> +operation to fail.  In this case, a function will have a single label
> +at the end of the funcion.  It's almost always ok to use this style.

s/funcion/function/

...
>                  Libvirt commiters guidelines
>                  ============================
> diff --git a/docs/hacking.html.in b/docs/hacking.html.in
...
> +      The typical use of goto is to jump to cleanup code in the case
> +      of a long list of actions, any of which may fail and cause the
> +      entire operation to fail.  In this case, a function will have a
> +      single label at the end of the funcion.  It's almost always ok

Likewise                                ^^^^^^

> +      to use this style.  In particular, if the cleanup code only
> +      involves free'ing memory, then having multiple labels is
...


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