qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 4/6] util/osdep: Improve error report by calling error_setg_wi


From: Philippe Mathieu-Daudé
Subject: [PATCH v2 4/6] util/osdep: Improve error report by calling error_setg_win32()
Date: Thu, 27 Feb 2020 17:30:59 +0100

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

Signed-off-by: Philippe Mathieu-Daudé <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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]