chardev: Improve error report by calling error_setg_win32()

Use error_setg_win32() which adds a hint similar to strerror(errno)).

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200228100726.8414-2-philmd@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2020-02-28 11:07:23 +01:00 committed by Markus Armbruster
parent 67f17e23ba
commit 4c235193a2
2 changed files with 2 additions and 2 deletions

View File

@ -70,7 +70,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL); MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);
g_free(openname); g_free(openname);
if (s->file == INVALID_HANDLE_VALUE) { if (s->file == INVALID_HANDLE_VALUE) {
error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError()); error_setg_win32(errp, GetLastError(), "Failed CreateNamedPipe");
s->file = NULL; s->file = NULL;
goto fail; goto fail;
} }

View File

@ -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, s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
if (s->file == INVALID_HANDLE_VALUE) { if (s->file == INVALID_HANDLE_VALUE) {
error_setg(errp, "Failed CreateFile (%lu)", GetLastError()); error_setg_win32(errp, GetLastError(), "Failed CreateFile");
s->file = NULL; s->file = NULL;
goto fail; goto fail;
} }