From patchwork Mon Jan 9 11:24:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 134995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7E9DDB6F68 for ; Mon, 9 Jan 2012 22:25:02 +1100 (EST) Received: from localhost ([::1]:55399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkDLN-0000dW-11 for incoming@patchwork.ozlabs.org; Mon, 09 Jan 2012 06:24:49 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkDL6-0000No-NQ for qemu-devel@nongnu.org; Mon, 09 Jan 2012 06:24:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkDL1-0006fH-RV for qemu-devel@nongnu.org; Mon, 09 Jan 2012 06:24:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkDL1-0006f4-8G for qemu-devel@nongnu.org; Mon, 09 Jan 2012 06:24:27 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q09BOPon009181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 9 Jan 2012 06:24:25 -0500 Received: from localhost (ovpn-113-68.phx2.redhat.com [10.3.113.68]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q09BOOCh003191; Mon, 9 Jan 2012 06:24:24 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 9 Jan 2012 09:24:08 -0200 Message-Id: <1326108257-13042-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1326108257-13042-1-git-send-email-lcapitulino@redhat.com> References: <1326108257-13042-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 01/10] vnc: Simplify vnc_display_password() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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)