[PATCH] Cygwin: pty: Add error handling in setup_pseudoconsoe().

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Feb 10 15:38:00 GMT 2020

On Feb 11 00:12, Takashi Yano wrote:
> - In setup_pseudoconsole(), many error handling was omitted. This
>   patch adds missing error handling.
> ---
>  winsup/cygwin/fhandler_tty.cc | 94 +++++++++++++++++++++++++----------
>  1 file changed, 68 insertions(+), 26 deletions(-)

Uhm... please, no.  There's no problem adding goto labels per se, but
jumping back to numbered error labels is quite confusing.

Error labels should ideally be at the end of the function and in reverse
order of the potentially failing code.  For more than one error label,
the label names ideally reflect the problem they are solving.  For

    <do something>

    if (<something failed>)
      goto err_something;

    <do something else>

    if (<something else failed>)
      goto err_something_else;

    <do some other stuff>

    if (<some other stuff failed>)
      goto err_some_other;

    return true;

    <cleanup some other stuff>

    <cleanup something else>

    <cleanup something>

    return false;

I wouldn't expect that all functions in Cygwin follow this approach yet,
but for new code I'd rather see it like this.


Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20200210/576856b7/attachment.sig>

More information about the Cygwin-patches mailing list