[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/10] vnc: Simplify vnc_display_password()
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 01/10] vnc: Simplify vnc_display_password() |
Date: |
Mon, 9 Jan 2012 09:24:08 -0200 |
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 <address@hidden>
---
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 6767ada..eb1719d 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.8.2.325.g247f9.dirty
- [Qemu-devel] [PATCH v1 00/10]: QAPI conversions round 4, Luiz Capitulino, 2012/01/09
- [Qemu-devel] [PATCH 01/10] vnc: Simplify vnc_display_password(),
Luiz Capitulino <=
- [Qemu-devel] [PATCH 02/10] qapi: Convert set_password, Luiz Capitulino, 2012/01/09
- [Qemu-devel] [PATCH 04/10] block: eject_device(): Use error_set(), Luiz Capitulino, 2012/01/09
- [Qemu-devel] [PATCH 05/10] qapi: Convert eject, Luiz Capitulino, 2012/01/09
- [Qemu-devel] [PATCH 03/10] qapi: Convert expire_password, Luiz Capitulino, 2012/01/09
- [Qemu-devel] [PATCH 06/10] monitor: expose readline state, Luiz Capitulino, 2012/01/09
- [Qemu-devel] [PATCH 07/10] qapi: Introduce change-vnc-password, Luiz Capitulino, 2012/01/09
- [Qemu-devel] [PATCH 10/10] qapi: Convert block_set_io_throttle, Luiz Capitulino, 2012/01/09