All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH 2/9] ui: remove 'enabled' and 'ws_enabled' fields from VncState
Date: Thu, 29 Sep 2016 16:45:33 +0100	[thread overview]
Message-ID: <1475163940-26094-3-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1475163940-26094-1-git-send-email-berrange@redhat.com>

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 <berrange@redhat.com>
---
 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

  parent reply	other threads:[~2016-09-29 15:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 15:45 [Qemu-devel] [PATCH 0/9] Misc VNC server code cleanups Daniel P. Berrange
2016-09-29 15:45 ` [Qemu-devel] [PATCH 1/9] ui: remove misleading comment from vnc_init_state Daniel P. Berrange
2016-09-29 15:45 ` Daniel P. Berrange [this message]
2016-09-29 15:45 ` [Qemu-devel] [PATCH 3/9] ui: remove 'ws_tls' field from VncState Daniel P. Berrange
2016-09-29 15:45 ` [Qemu-devel] [PATCH 4/9] ui: rename misleading 'VncDisplay' variables Daniel P. Berrange
2016-09-29 15:45 ` [Qemu-devel] [PATCH 5/9] ui: refactor method for setting up VncDisplay auth types Daniel P. Berrange
2016-09-29 16:10   ` Eric Blake
2016-09-29 15:45 ` [Qemu-devel] [PATCH 6/9] ui: remove bogus call to graphic_hw_update() in vnc_listen_io Daniel P. Berrange
2016-09-29 15:45 ` [Qemu-devel] [PATCH 7/9] ui: remove bogus call to reset_keys() in vnc_init_state Daniel P. Berrange
2016-09-29 15:45 ` [Qemu-devel] [PATCH 8/9] ui: move some initialization out of vnc_init_state Daniel P. Berrange
2016-09-29 15:45 ` [Qemu-devel] [PATCH 9/9] ui: rename vnc_init_state to vnc_start_protocol Daniel P. Berrange
2016-10-13  7:21 ` [Qemu-devel] [PATCH 0/9] Misc VNC server code cleanups Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475163940-26094-3-git-send-email-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.