Patchwork [06/26] util: move socket_init() to osdep.c

login
register
mail settings
Submitter Alon Levy
Date March 18, 2013, 1:10 p.m.
Message ID <1363612272-13713-7-git-send-email-alevy@redhat.com>
Download mbox | patch
Permalink /patch/228656/
State New
Headers show

Comments

Alon Levy - March 18, 2013, 1:10 p.m.
From: Marc-André Lureau <marcandre.lureau@redhat.com>

vscclient needs to call socket_init() for portability.
Moving to osdep.c since it has no internal dependency.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 util/osdep.c        | 23 +++++++++++++++++++++++
 util/qemu-sockets.c | 24 ------------------------
 2 files changed, 23 insertions(+), 24 deletions(-)

Patch

diff --git a/util/osdep.c b/util/osdep.c
index bd59ac9..6ae5aaf 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -406,3 +406,26 @@  bool fips_get_state(void)
     return fips_enabled;
 }
 
+#ifdef _WIN32
+static void socket_cleanup(void)
+{
+    WSACleanup();
+}
+#endif
+
+int socket_init(void)
+{
+#ifdef _WIN32
+    WSADATA Data;
+    int ret, err;
+
+    ret = WSAStartup(MAKEWORD(2, 2), &Data);
+    if (ret != 0) {
+        err = WSAGetLastError();
+        fprintf(stderr, "WSAStartup: %d\n", err);
+        return -1;
+    }
+    atexit(socket_cleanup);
+#endif
+    return 0;
+}
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 83e4e08..f42f0b7 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -973,27 +973,3 @@  int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
     qemu_opts_del(opts);
     return fd;
 }
-
-#ifdef _WIN32
-static void socket_cleanup(void)
-{
-    WSACleanup();
-}
-#endif
-
-int socket_init(void)
-{
-#ifdef _WIN32
-    WSADATA Data;
-    int ret, err;
-
-    ret = WSAStartup(MAKEWORD(2,2), &Data);
-    if (ret != 0) {
-        err = WSAGetLastError();
-        fprintf(stderr, "WSAStartup: %d\n", err);
-        return -1;
-    }
-    atexit(socket_cleanup);
-#endif
-    return 0;
-}