[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 4/6] util/osdep: Improve error report by calling error_set
From: |
Marc-André Lureau |
Subject: |
Re: [PATCH v2 4/6] util/osdep: Improve error report by calling error_setg_win32() |
Date: |
Thu, 27 Feb 2020 18:22:30 +0100 |
On Thu, Feb 27, 2020 at 5:32 PM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> Use error_setg_win32() which adds a hint similar to strerror(errno)).
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> util/osdep.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/util/osdep.c b/util/osdep.c
> index ef40ae512a..144e217cb9 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -82,8 +82,8 @@ static int qemu_mprotect__osdep(void *addr, size_t size,
> int prot)
> DWORD old_protect;
>
> if (!VirtualProtect(addr, size, prot, &old_protect)) {
> - error_report("%s: VirtualProtect failed with error code %ld",
> - __func__, GetLastError());
> + g_autofree gchar *emsg = g_win32_error_message(GetLastError());
> + error_report("%s: VirtualProtect failed: %s", __func__, emsg);
> return -1;
> }
> return 0;
> @@ -506,12 +506,12 @@ int socket_init(void)
> {
> #ifdef _WIN32
> WSADATA Data;
> - int ret, err;
> + int ret;
>
> ret = WSAStartup(MAKEWORD(2, 2), &Data);
> if (ret != 0) {
> - err = WSAGetLastError();
> - error_report("WSAStartup: %d", err);
> + g_autofree gchar *emsg = g_win32_error_message(WSAGetLastError());
> + error_report("WSAStartup: %s", emsg);
> return -1;
> }
> atexit(socket_cleanup);
> --
> 2.21.1
>
- [PATCH v2 0/6] misc: Improve error reporting on Windows, Philippe Mathieu-Daudé, 2020/02/27
- [PATCH v2 1/6] chardev: Improve error report by calling error_setg_win32(), Philippe Mathieu-Daudé, 2020/02/27
- [PATCH v2 2/6] util: Replace fprintf(stderr, "*\n" with error_report(), Philippe Mathieu-Daudé, 2020/02/27
- [PATCH v2 3/6] util/oslib-win32: Improve error report by calling error_setg_win32(), Philippe Mathieu-Daudé, 2020/02/27
- [PATCH v2 5/6] qga: Fix a memory leak, Philippe Mathieu-Daudé, 2020/02/27
- [PATCH v2 4/6] util/osdep: Improve error report by calling error_setg_win32(), Philippe Mathieu-Daudé, 2020/02/27
- Re: [PATCH v2 4/6] util/osdep: Improve error report by calling error_setg_win32(),
Marc-André Lureau <=
- [PATCH v2 6/6] qga: Improve error report by calling error_setg_win32(), Philippe Mathieu-Daudé, 2020/02/27