Patchwork [1/4] util: move socket_init() to osdep.c

login
register
mail settings
Submitter Marc-André Lureau
Date Feb. 25, 2013, 5:56 p.m.
Message ID <1361815009-24145-1-git-send-email-marcandre.lureau@redhat.com>
Download mbox | patch
Permalink /patch/222987/
State New
Headers show

Comments

Marc-André Lureau - Feb. 25, 2013, 5:56 p.m.
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(-)
Paolo Bonzini - Feb. 25, 2013, 6:13 p.m.
Il 25/02/2013 18:56, Marc-André Lureau ha scritto:
> 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(-)
> 
> diff --git a/util/osdep.c b/util/osdep.c
> index 5b51a03..3c1a0a3 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -400,3 +400,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 1350ccc..d8994c1 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -944,27 +944,3 @@ int socket_listen(SocketAddress *addr, 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;
> -}
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch

diff --git a/util/osdep.c b/util/osdep.c
index 5b51a03..3c1a0a3 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -400,3 +400,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 1350ccc..d8994c1 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -944,27 +944,3 @@  int socket_listen(SocketAddress *addr, 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;
-}