[PATCH 1/2] chardev: Improve error report by calling error_setg_win32()

Philippe Mathieu-Daudé posted 2 patches 5 years, 8 months ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>
There is a newer version of this series
[PATCH 1/2] chardev: Improve error report by calling error_setg_win32()
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
Use error_setg_win32() which adds a hint similar to strerror(errno)).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 chardev/char-pipe.c | 2 +-
 chardev/char-win.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c
index 94d714ffcd..fd12c9e63b 100644
--- a/chardev/char-pipe.c
+++ b/chardev/char-pipe.c
@@ -70,7 +70,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
                               MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);
     g_free(openname);
     if (s->file == INVALID_HANDLE_VALUE) {
-        error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError());
+        error_setg_win32(errp, GetLastError(), "Failed CreateNamedPipe");
         s->file = NULL;
         goto fail;
     }
diff --git a/chardev/char-win.c b/chardev/char-win.c
index 34825f683d..d4fb44c4dc 100644
--- a/chardev/char-win.c
+++ b/chardev/char-win.c
@@ -96,7 +96,7 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
     s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                       OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
     if (s->file == INVALID_HANDLE_VALUE) {
-        error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
+        error_setg_win32(errp, GetLastError(), "Failed CreateFile");
         s->file = NULL;
         goto fail;
     }
-- 
2.21.1


Re: [PATCH 1/2] chardev: Improve error report by calling error_setg_win32()
Posted by Daniel P. Berrangé 5 years, 8 months ago
On Thu, Feb 27, 2020 at 11:02:49AM +0100, Philippe Mathieu-Daudé wrote:
> Use error_setg_win32() which adds a hint similar to strerror(errno)).
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  chardev/char-pipe.c | 2 +-
>  chardev/char-win.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH 1/2] chardev: Improve error report by calling error_setg_win32()
Posted by Marc-André Lureau 5 years, 8 months ago
On Thu, Feb 27, 2020 at 11:03 AM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> Use error_setg_win32() which adds a hint similar to strerror(errno)).
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  chardev/char-pipe.c | 2 +-
>  chardev/char-win.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c
> index 94d714ffcd..fd12c9e63b 100644
> --- a/chardev/char-pipe.c
> +++ b/chardev/char-pipe.c
> @@ -70,7 +70,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
>                                MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);
>      g_free(openname);
>      if (s->file == INVALID_HANDLE_VALUE) {
> -        error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError());
> +        error_setg_win32(errp, GetLastError(), "Failed CreateNamedPipe");
>          s->file = NULL;
>          goto fail;
>      }
> diff --git a/chardev/char-win.c b/chardev/char-win.c
> index 34825f683d..d4fb44c4dc 100644
> --- a/chardev/char-win.c
> +++ b/chardev/char-win.c
> @@ -96,7 +96,7 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
>      s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
>                        OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
>      if (s->file == INVALID_HANDLE_VALUE) {
> -        error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
> +        error_setg_win32(errp, GetLastError(), "Failed CreateFile");
>          s->file = NULL;
>          goto fail;
>      }
> --
> 2.21.1
>

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


Daniel, do you mind queuing this with the qio patch?