On Thu, Feb 27, 2020 at 5:32 PM 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>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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
>