[PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init()

Daniel Henrique Barboza posted 59 patches 6 years, 1 month ago
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, Max Reitz <mreitz@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Greg Kurz <groug@kaod.org>, Jason Wang <jasowang@redhat.com>, Corey Minyard <minyard@acm.org>, Aleksandar Markovic <amarkovic@wavecomp.com>, Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, David Hildenbrand <david@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, "Daniel P. Berrangé" <berrange@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Wen Congyang <wencongyang2@huawei.com>, "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Richard W.M. Jones" <rjones@redhat.com>, Jeff Cody <codyprime@gmail.com>, Riku Voipio <riku.voipio@iki.fi>, Stefan Weil <sw@weilnetz.de>, Michael Roth <mdroth@linux.vnet.ibm.com>, Richard Henderson <rth@twiddle.net>, Eduardo Habkost <ehabkost@redhat.com>, Yuval Shaia <yuval.shaia.ml@gmail.com>, Fam Zheng <fam@euphon.net>, Xie Changlong <xiechanglong.d@gmail.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Halil Pasic <pasic@linux.ibm.com>, Juan Quintela <quintela@redhat.com>, John Snow <jsnow@redhat.com>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>, Christian Borntraeger <borntraeger@de.ibm.com>, Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, Guan Xuetao <gxt@mprc.pku.edu.cn>, Paolo Bonzini <pbonzini@redhat.com>
[PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
Posted by Daniel Henrique Barboza 6 years, 1 month ago
The 'fail' label is a simply call to 'return -1' on error. Remove
it and do the return call instead.

CC: Marc-André Lureau <marcandre.lureau@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 chardev/char-win.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/chardev/char-win.c b/chardev/char-win.c
index 34825f683d..72c232e6d9 100644
--- a/chardev/char-win.c
+++ b/chardev/char-win.c
@@ -85,12 +85,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
     s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
     if (!s->hsend) {
         error_setg(errp, "Failed CreateEvent");
-        goto fail;
+        return -1;
     }
     s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
     if (!s->hrecv) {
         error_setg(errp, "Failed CreateEvent");
-        goto fail;
+        return -1;
     }
 
     s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
@@ -98,12 +98,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
     if (s->file == INVALID_HANDLE_VALUE) {
         error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
         s->file = NULL;
-        goto fail;
+        return -1;
     }
 
     if (!SetupComm(s->file, NRECVBUF, NSENDBUF)) {
         error_setg(errp, "Failed SetupComm");
-        goto fail;
+        return -1;
     }
 
     ZeroMemory(&comcfg, sizeof(COMMCONFIG));
@@ -114,29 +114,26 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
 
     if (!SetCommState(s->file, &comcfg.dcb)) {
         error_setg(errp, "Failed SetCommState");
-        goto fail;
+        return -1;
     }
 
     if (!SetCommMask(s->file, EV_ERR)) {
         error_setg(errp, "Failed SetCommMask");
-        goto fail;
+        return -1;
     }
 
     cto.ReadIntervalTimeout = MAXDWORD;
     if (!SetCommTimeouts(s->file, &cto)) {
         error_setg(errp, "Failed SetCommTimeouts");
-        goto fail;
+        return -1;
     }
 
     if (!ClearCommError(s->file, &err, &comstat)) {
         error_setg(errp, "Failed ClearCommError");
-        goto fail;
+        return -1;
     }
     qemu_add_polling_cb(win_chr_serial_poll, chr);
     return 0;
-
- fail:
-    return -1;
 }
 
 int win_chr_pipe_poll(void *opaque)
-- 
2.24.1


Re: [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
Posted by Marc-André Lureau 6 years, 1 month ago
On Mon, Jan 6, 2020 at 10:25 PM Daniel Henrique Barboza
<danielhb413@gmail.com> wrote:
>
> The 'fail' label is a simply call to 'return -1' on error. Remove
> it and do the return call instead.
>
> CC: Marc-André Lureau <marcandre.lureau@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  chardev/char-win.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/chardev/char-win.c b/chardev/char-win.c
> index 34825f683d..72c232e6d9 100644
> --- a/chardev/char-win.c
> +++ b/chardev/char-win.c
> @@ -85,12 +85,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>      s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
>      if (!s->hsend) {
>          error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>      }
>      s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
>      if (!s->hrecv) {
>          error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>      }
>
>      s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
> @@ -98,12 +98,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>      if (s->file == INVALID_HANDLE_VALUE) {
>          error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
>          s->file = NULL;
> -        goto fail;
> +        return -1;
>      }
>
>      if (!SetupComm(s->file, NRECVBUF, NSENDBUF)) {
>          error_setg(errp, "Failed SetupComm");
> -        goto fail;
> +        return -1;
>      }
>
>      ZeroMemory(&comcfg, sizeof(COMMCONFIG));
> @@ -114,29 +114,26 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>
>      if (!SetCommState(s->file, &comcfg.dcb)) {
>          error_setg(errp, "Failed SetCommState");
> -        goto fail;
> +        return -1;
>      }
>
>      if (!SetCommMask(s->file, EV_ERR)) {
>          error_setg(errp, "Failed SetCommMask");
> -        goto fail;
> +        return -1;
>      }
>
>      cto.ReadIntervalTimeout = MAXDWORD;
>      if (!SetCommTimeouts(s->file, &cto)) {
>          error_setg(errp, "Failed SetCommTimeouts");
> -        goto fail;
> +        return -1;
>      }
>
>      if (!ClearCommError(s->file, &err, &comstat)) {
>          error_setg(errp, "Failed ClearCommError");
> -        goto fail;
> +        return -1;
>      }
>      qemu_add_polling_cb(win_chr_serial_poll, chr);
>      return 0;
> -
> - fail:
> -    return -1;
>  }
>
>  int win_chr_pipe_poll(void *opaque)
> --
> 2.24.1
>


Re: [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init()
Posted by Philippe Mathieu-Daudé 6 years, 1 month ago
On 1/6/20 7:23 PM, Daniel Henrique Barboza wrote:
> The 'fail' label is a simply call to 'return -1' on error. Remove
> it and do the return call instead.
> 
> CC: Marc-André Lureau <marcandre.lureau@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   chardev/char-win.c | 19 ++++++++-----------
>   1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/chardev/char-win.c b/chardev/char-win.c
> index 34825f683d..72c232e6d9 100644
> --- a/chardev/char-win.c
> +++ b/chardev/char-win.c
> @@ -85,12 +85,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>       s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
>       if (!s->hsend) {
>           error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>       }
>       s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
>       if (!s->hrecv) {
>           error_setg(errp, "Failed CreateEvent");
> -        goto fail;
> +        return -1;
>       }
>   
>       s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
> @@ -98,12 +98,12 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>       if (s->file == INVALID_HANDLE_VALUE) {
>           error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
>           s->file = NULL;
> -        goto fail;
> +        return -1;
>       }
>   
>       if (!SetupComm(s->file, NRECVBUF, NSENDBUF)) {
>           error_setg(errp, "Failed SetupComm");
> -        goto fail;
> +        return -1;
>       }
>   
>       ZeroMemory(&comcfg, sizeof(COMMCONFIG));
> @@ -114,29 +114,26 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>   
>       if (!SetCommState(s->file, &comcfg.dcb)) {
>           error_setg(errp, "Failed SetCommState");
> -        goto fail;
> +        return -1;
>       }
>   
>       if (!SetCommMask(s->file, EV_ERR)) {
>           error_setg(errp, "Failed SetCommMask");
> -        goto fail;
> +        return -1;
>       }
>   
>       cto.ReadIntervalTimeout = MAXDWORD;
>       if (!SetCommTimeouts(s->file, &cto)) {
>           error_setg(errp, "Failed SetCommTimeouts");
> -        goto fail;
> +        return -1;
>       }
>   
>       if (!ClearCommError(s->file, &err, &comstat)) {
>           error_setg(errp, "Failed ClearCommError");
> -        goto fail;
> +        return -1;
>       }
>       qemu_add_polling_cb(win_chr_serial_poll, chr);
>       return 0;
> -
> - fail:
> -    return -1;
>   }
>   
>   int win_chr_pipe_poll(void *opaque)
>