From patchwork Mon Oct 31 19:22:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9406307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6CB7960585 for ; Mon, 31 Oct 2016 19:27:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F44C28DA9 for ; Mon, 31 Oct 2016 19:27:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51C2928DB5; Mon, 31 Oct 2016 19:27:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B63A228DA9 for ; Mon, 31 Oct 2016 19:27:20 +0000 (UTC) Received: from localhost ([::1]:38148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1IEq-0001Ml-0h for patchwork-qemu-devel@patchwork.kernel.org; Mon, 31 Oct 2016 15:27:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1IAp-0005Q2-AI for qemu-devel@nongnu.org; Mon, 31 Oct 2016 15:23:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1IAo-0005Ec-GC for qemu-devel@nongnu.org; Mon, 31 Oct 2016 15:23:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56004) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1IAm-0005Cz-1b; Mon, 31 Oct 2016 15:23:08 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50A438CB56; Mon, 31 Oct 2016 19:23:07 +0000 (UTC) Received: from localhost (ovpn-112-28.phx2.redhat.com [10.3.112.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9VJN5LK006970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 31 Oct 2016 15:23:06 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Mon, 31 Oct 2016 15:22:49 -0400 Message-Id: <1477941781-4108-3-git-send-email-jcody@redhat.com> In-Reply-To: <1477941781-4108-1-git-send-email-jcody@redhat.com> References: <1477941781-4108-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 31 Oct 2016 19:23:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/14] rbd: make the code more readable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xiubo Li Make it a bit clearer and more readable. Signed-off-by: Xiubo Li Reviewed-by: Stefan Hajnoczi Reviewed-by: John Snow Reviewed-by: Jeff Cody Message-id: 1476519973-6436-1-git-send-email-lixiubo@cmss.chinamobile.com CC: John Snow Signed-off-by: Jeff Cody --- block/rbd.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index f6e1d4b..a57b3e3 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -365,45 +365,44 @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp) rados_conf_read_file(cluster, NULL); } else if (conf[0] != '\0' && qemu_rbd_set_conf(cluster, conf, true, &local_err) < 0) { - rados_shutdown(cluster); error_propagate(errp, local_err); - return -EIO; + ret = -EIO; + goto shutdown; } if (conf[0] != '\0' && qemu_rbd_set_conf(cluster, conf, false, &local_err) < 0) { - rados_shutdown(cluster); error_propagate(errp, local_err); - return -EIO; + ret = -EIO; + goto shutdown; } if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) { - rados_shutdown(cluster); - return -EIO; + ret = -EIO; + goto shutdown; } ret = rados_connect(cluster); if (ret < 0) { error_setg_errno(errp, -ret, "error connecting"); - rados_shutdown(cluster); - return ret; + goto shutdown; } ret = rados_ioctx_create(cluster, pool, &io_ctx); if (ret < 0) { error_setg_errno(errp, -ret, "error opening pool %s", pool); - rados_shutdown(cluster); - return ret; + goto shutdown; } ret = rbd_create(io_ctx, name, bytes, &obj_order); + if (ret < 0) { + error_setg_errno(errp, -ret, "error rbd create"); + } + rados_ioctx_destroy(io_ctx); + +shutdown: rados_shutdown(cluster); - if (ret < 0) { - error_setg_errno(errp, -ret, "error rbd create"); - return ret; - } - return ret; }