qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/9] ui: remove 'enabled' and 'ws_enabled' fields fr


From: Daniel P. Berrange
Subject: [Qemu-devel] [PATCH 2/9] ui: remove 'enabled' and 'ws_enabled' fields from VncState
Date: Thu, 29 Sep 2016 16:45:33 +0100

The 'ws_enabled' field is never used outside of the
vnc_display_open method, so can be a local variable.

The 'enabled' field is easily replaced by a check
for whether 'lsock' is non-NULL.

Signed-off-by: Daniel P. Berrange <address@hidden>
---
 ui/vnc.c | 23 ++++++++++-------------
 ui/vnc.h |  2 --
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 5faf79b..45a23d3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -371,7 +371,7 @@ VncInfo *qmp_query_vnc(Error **errp)
     VncDisplay *vd = vnc_display_find(NULL);
     SocketAddress *addr = NULL;
 
-    if (vd == NULL || !vd->enabled) {
+    if (vd == NULL || !vd->lsock) {
         info->enabled = false;
     } else {
         info->enabled = true;
@@ -3169,7 +3169,6 @@ static void vnc_display_close(VncDisplay *vs)
 {
     if (!vs)
         return;
-    vs->enabled = false;
     vs->is_unix = false;
     if (vs->lsock != NULL) {
         if (vs->lsock_tag) {
@@ -3178,7 +3177,6 @@ static void vnc_display_close(VncDisplay *vs)
         object_unref(OBJECT(vs->lsock));
         vs->lsock = NULL;
     }
-    vs->ws_enabled = false;
     if (vs->lwebsock != NULL) {
         if (vs->lwebsock_tag) {
             g_source_remove(vs->lwebsock_tag);
@@ -3538,6 +3536,7 @@ void vnc_display_open(const char *id, Error **errp)
     int acl = 0;
     int lock_key_sync = 1;
     int key_delay_ms;
+    bool ws_enabled = false;
 
     if (!vs) {
         error_setg(errp, "VNC display not active");
@@ -3573,7 +3572,7 @@ void vnc_display_open(const char *id, Error **errp)
             }
 
             wsaddr = g_new0(SocketAddress, 1);
-            vs->ws_enabled = true;
+            ws_enabled = true;
         }
 
         if (strncmp(vnc, "unix:", 5) == 0) {
@@ -3581,7 +3580,7 @@ void vnc_display_open(const char *id, Error **errp)
             saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
             saddr->u.q_unix.data->path = g_strdup(vnc + 5);
 
-            if (vs->ws_enabled) {
+            if (ws_enabled) {
                 error_setg(errp, "UNIX sockets not supported with websock");
                 goto fail;
             }
@@ -3617,7 +3616,7 @@ void vnc_display_open(const char *id, Error **errp)
             inet->ipv6 = ipv6;
             inet->has_ipv6 = has_ipv6;
 
-            if (vs->ws_enabled) {
+            if (ws_enabled) {
                 wsaddr->type = SOCKET_ADDRESS_KIND_INET;
                 inet = wsaddr->u.inet.data = g_new0(InetSocketAddress, 1);
                 inet->host = g_strdup(saddr->u.inet.data->host);
@@ -3777,7 +3776,7 @@ void vnc_display_open(const char *id, Error **errp)
     }
 #endif
 
-    if (vnc_display_setup_auth(vs, password, sasl, vs->ws_enabled, errp) < 0) {
+    if (vnc_display_setup_auth(vs, password, sasl, ws_enabled, errp) < 0) {
         goto fail;
     }
 
@@ -3816,7 +3815,7 @@ void vnc_display_open(const char *id, Error **errp)
         QIOChannelSocket *sioc = NULL;
         vs->lsock = NULL;
         vs->lwebsock = NULL;
-        if (vs->ws_enabled) {
+        if (ws_enabled) {
             error_setg(errp, "Cannot use websockets in reverse mode");
             goto fail;
         }
@@ -3833,9 +3832,8 @@ void vnc_display_open(const char *id, Error **errp)
             goto fail;
         }
         vs->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
-        vs->enabled = true;
 
-        if (vs->ws_enabled) {
+        if (ws_enabled) {
             vs->lwebsock = qio_channel_socket_new();
             if (qio_channel_socket_listen_sync(vs->lwebsock,
                                                wsaddr, errp) < 0) {
@@ -3848,7 +3846,7 @@ void vnc_display_open(const char *id, Error **errp)
         vs->lsock_tag = qio_channel_add_watch(
             QIO_CHANNEL(vs->lsock),
             G_IO_IN, vnc_listen_io, vs, NULL);
-        if (vs->ws_enabled) {
+        if (ws_enabled) {
             vs->lwebsock_tag = qio_channel_add_watch(
                 QIO_CHANNEL(vs->lwebsock),
                 G_IO_IN, vnc_listen_io, vs, NULL);
@@ -3866,8 +3864,7 @@ void vnc_display_open(const char *id, Error **errp)
 fail:
     qapi_free_SocketAddress(saddr);
     qapi_free_SocketAddress(wsaddr);
-    vs->enabled = false;
-    vs->ws_enabled = false;
+    ws_enabled = false;
 }
 
 void vnc_display_add_client(const char *id, int csock, bool skipauth)
diff --git a/ui/vnc.h b/ui/vnc.h
index ab5f244..a0519cc 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -150,7 +150,6 @@ struct VncDisplay
     guint lsock_tag;
     QIOChannelSocket *lwebsock;
     guint lwebsock_tag;
-    bool ws_enabled;
     DisplaySurface *ds;
     DisplayChangeListener dcl;
     kbd_layout_t *kbd_layout;
@@ -167,7 +166,6 @@ struct VncDisplay
 
     const char *id;
     QTAILQ_ENTRY(VncDisplay) next;
-    bool enabled;
     bool is_unix;
     char *password;
     time_t expires;
-- 
2.7.4




reply via email to

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