From patchwork Fri Oct 19 13:31:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 192710 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 478862C0090 for ; Sat, 20 Oct 2012 01:01:44 +1100 (EST) Received: from localhost ([::1]:39647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPCiX-0007KM-5H for incoming@patchwork.ozlabs.org; Fri, 19 Oct 2012 09:34:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPChp-0006P9-Fx for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:33:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TPChf-0006Z2-F7 for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:33:41 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:59837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPChf-0005yp-1m for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:33:31 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so369528pad.4 for ; Fri, 19 Oct 2012 06:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=9t2sPcnv+492dru/BYEtNyR4VBIWeJcYiJ03QCZB+lk=; b=giAoJ8JK/vbyhohNSmAXz9qG0ID880rUOPpYDFttHgvYiW0q6TThYUGKGx+FmAKlYa R23VAtjVp2PZMT0G5b/mBEdFuJVQVGuDOzq7OThN1X2A3nf4JWSaFJwmw1xs1ounGDCQ XpGtozXxZbmSWJHogyVM5Sw7zdygob5mVSwga2DDDEBZuMBbFSYDBmrvUNP+Ws41WgXC 94v+v4g0Qjz6jiWFlC20VP8MegL2OcZxkgPhOhYDb3UO5JsAS7jD6eZpMYgnnDfpGOeV Q5UlYSW+juc4QM2tZl2yAnNZL0U84y/Oz94YvH3a3xx4Yu+f8wQWIYWo20IgPTKoiihd GQFA== Received: by 10.68.217.104 with SMTP id ox8mr5897084pbc.35.1350653610713; Fri, 19 Oct 2012 06:33:30 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id kr4sm1240726pbc.76.2012.10.19.06.33.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 06:33:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 19 Oct 2012 15:31:53 +0200 Message-Id: <1350653528-5834-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1350653528-5834-1-git-send-email-pbonzini@redhat.com> References: <1350653528-5834-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.45 Subject: [Qemu-devel] [PATCH 14/29] vnc: introduce a single label for error returns 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 Signed-off-by: Paolo Bonzini --- ui/vnc.c | 42 +++++++++++++++++------------------------- 1 file modificato, 17 inserzioni(+), 25 rimozioni(-) diff --git a/ui/vnc.c b/ui/vnc.c index 2892fb7..6da265f 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2872,8 +2872,7 @@ int vnc_display_open(DisplayState *ds, const char *display) if (strcmp(display, "none") == 0) return 0; - if (!(vs->display = strdup(display))) - return -1; + vs->display = g_strdup(display); vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; options = display; @@ -2885,9 +2884,7 @@ int vnc_display_open(DisplayState *ds, const char *display) "VNC password auth disabled due to FIPS mode, " "consider using the VeNCrypt or SASL authentication " "methods as an alternative\n"); - g_free(vs->display); - vs->display = NULL; - return -1; + goto fail; } password = 1; /* Require password auth */ } else if (strncmp(options, "reverse", 7) == 0) { @@ -2919,16 +2916,12 @@ int vnc_display_open(DisplayState *ds, const char *display) if (vnc_tls_set_x509_creds_dir(vs, path) < 0) { fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path); g_free(path); - g_free(vs->display); - vs->display = NULL; - return -1; + goto fail; } g_free(path); } else { fprintf(stderr, "No certificate path provided\n"); - g_free(vs->display); - vs->display = NULL; - return -1; + goto fail; } #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) @@ -2948,9 +2941,7 @@ int vnc_display_open(DisplayState *ds, const char *display) vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED; } else { fprintf(stderr, "unknown vnc share= option\n"); - g_free(vs->display); - vs->display = NULL; - return -1; + goto fail; } } } @@ -3053,9 +3044,7 @@ int vnc_display_open(DisplayState *ds, const char *display) if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) { fprintf(stderr, "Failed to initialize SASL auth %s", sasl_errstring(saslErr, NULL, NULL)); - g_free(vs->display); - vs->display = NULL; - return -1; + goto fail; } #endif vs->lock_key_sync = lock_key_sync; @@ -3067,9 +3056,7 @@ int vnc_display_open(DisplayState *ds, const char *display) else vs->lsock = inet_connect(display, NULL); if (vs->lsock < 0) { - g_free(vs->display); - vs->display = NULL; - return -1; + goto fail; } else { int csock = vs->lsock; vs->lsock = -1; @@ -3090,13 +3077,18 @@ int vnc_display_open(DisplayState *ds, const char *display) } if (vs->lsock < 0) { g_free(dpy); - return -1; - } else { - g_free(vs->display); - vs->display = dpy; + goto fail; } + g_free(vs->display); + vs->display = dpy; + qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs); } - return qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs); + return 0; + +fail: + g_free(vs->display); + vs->display = NULL; + return -1; } void vnc_display_add_client(DisplayState *ds, int csock, int skipauth)