qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 01/14] vnc: Simplify vnc_display_password()
Date: Wed, 18 Jan 2012 15:41:11 -0200	[thread overview]
Message-ID: <1326908484-13389-2-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1326908484-13389-1-git-send-email-lcapitulino@redhat.com>

Drop the qerror_report() call from it and let its callers set the error
themselves. This also allows for dropping the 'ret' variable.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 console.h |    1 -
 monitor.c |    7 ++++++-
 ui/vnc.c  |   14 ++++----------
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/console.h b/console.h
index 9466886..be3b7c8 100644
--- a/console.h
+++ b/console.h
@@ -384,7 +384,6 @@ int vnc_display_pw_expire(DisplayState *ds, time_t expires);
 #else
 static inline int vnc_display_password(DisplayState *ds, const char *password)
 {
-    qerror_report(QERR_FEATURE_DISABLED, "vnc");
     return -ENODEV;
 }
 static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)
diff --git a/monitor.c b/monitor.c
index 7334401..759c133 100644
--- a/monitor.c
+++ b/monitor.c
@@ -929,7 +929,12 @@ static int set_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
         }
         /* Note that setting an empty password will not disable login through
          * this interface. */
-        return vnc_display_password(NULL, password);
+        rc = vnc_display_password(NULL, password);
+        if (rc < 0) {
+            qerror_report(QERR_SET_PASSWD_FAILED);
+            return -1;
+        }
+        return 0;
     }
 
     qerror_report(QERR_INVALID_PARAMETER, "protocol");
diff --git a/ui/vnc.c b/ui/vnc.c
index 1869a7a..16b79ec 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2686,19 +2686,16 @@ int vnc_display_disable_login(DisplayState *ds)
 
 int vnc_display_password(DisplayState *ds, const char *password)
 {
-    int ret = 0;
     VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
 
     if (!vs) {
-        ret = -EINVAL;
-        goto out;
+        return -EINVAL;
     }
 
     if (!password) {
         /* This is not the intention of this interface but err on the side
            of being safe */
-        ret = vnc_display_disable_login(ds);
-        goto out;
+        return vnc_display_disable_login(ds);
     }
 
     if (vs->password) {
@@ -2707,11 +2704,8 @@ int vnc_display_password(DisplayState *ds, const char *password)
     }
     vs->password = g_strdup(password);
     vs->auth = VNC_AUTH_VNC;
-out:
-    if (ret != 0) {
-        qerror_report(QERR_SET_PASSWD_FAILED);
-    }
-    return ret;
+
+    return 0;
 }
 
 int vnc_display_pw_expire(DisplayState *ds, time_t expires)
-- 
1.7.9.rc0.dirty

  reply	other threads:[~2012-01-18 17:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-18 17:41 [Qemu-devel] [PULL 00/14]: QMP queue Luiz Capitulino
2012-01-18 17:41 ` Luiz Capitulino [this message]
2012-01-18 17:41 ` [Qemu-devel] [PATCH 02/14] qapi: Convert set_password Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 03/14] qapi: Convert expire_password Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 04/14] block: eject_device(): Use error_set() Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 05/14] qapi: Convert eject Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 06/14] monitor: expose readline state Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 07/14] qapi: Introduce change-vnc-password Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 08/14] qerror: Extend QERR_DEVICE_ENCRYPTED Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 09/14] qapi: Convert change Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 10/14] qapi: Convert block_set_io_throttle Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 11/14] qmp: Add missing gcc format attribute and fix format string Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 12/14] qerror: add check-qerror.sh to verify alphabetical order Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 13/14] qerror: restore alphabetical order over qerrors Luiz Capitulino
2012-01-18 17:41 ` [Qemu-devel] [PATCH 14/14] block: use proper qerrors in qmp_block_resize Luiz Capitulino
2012-01-24  9:35   ` Markus Armbruster
2012-01-19 18:47 ` [Qemu-devel] [PULL 00/14]: QMP queue Anthony Liguori

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=1326908484-13389-2-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=aliguori@us.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).