From nobody Thu Apr 25 20:21:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610088794; cv=none; d=zohomail.com; s=zohoarc; b=mmsKgjd7XeQJTwGpbjlFkSyWEyuHWxsq4TpyXkyFyTsjFpXbD25ei71QX2weRS2Dmc4UqWSLHnc4/osr8xEDJlpIv1gZIEBwlKTfpdbYk4I/E+PsIFi+tNlgp6HiWgd1G51H9VUBgnmWyJbdLcjcBNv6m/X0kShY0QyDSJLXm3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610088794; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=g0XU5jtDm+WBNUZAEiZBmO3lKoxZL2sNyMX1+pRcPos=; b=Q5imFngadMHlcB/3TvVgqSnqpMOiuac4rf/OXYfTIpl9w3ipcmgu9feQLfbfTATyLPwuCK4pMUUIgwHCbqhMRODkUWR5RW2oYSBiS83veTCgSh0Q1/YZXqcPXIS7Oe9MurZG3xN/tg32t9juivhlbQ3wI4SFV1nqwRFOCcTwgwg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1610088792260814.3191247818104; Thu, 7 Jan 2021 22:53:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-PnKtp7heNrykO25j_twwAw-1; Fri, 08 Jan 2021 01:53:08 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D293E809DCF; Fri, 8 Jan 2021 06:53:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5762F6A8F0; Fri, 8 Jan 2021 06:53:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 52A54180954D; Fri, 8 Jan 2021 06:52:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1086qtft025802 for ; Fri, 8 Jan 2021 01:52:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7D27AD7DF1; Fri, 8 Jan 2021 06:52:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77602D7DF0 for ; Fri, 8 Jan 2021 06:52:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32F65858281 for ; Fri, 8 Jan 2021 06:52:53 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.70.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-8QVdgpLhNkqT78XRtB00YA-1; Fri, 08 Jan 2021 01:52:50 -0500 Received: from localhost (unknown [192.168.167.32]) by regular1.263xmail.com (Postfix) with ESMTP id 30E2C1D3C for ; Fri, 8 Jan 2021 14:52:43 +0800 (CST) Received: from localhost.localdomain (unknown [14.18.236.70]) by smtp.263.net (postfix) whith ESMTP id P25766T139972568020736S1610088272687140_; Fri, 08 Jan 2021 14:44:40 +0800 (CST) X-MC-Unique: PnKtp7heNrykO25j_twwAw-1 X-MC-Unique: 8QVdgpLhNkqT78XRtB00YA-1 X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-SKE-CHECKED: 1 X-ABS-CHECKED: 1 X-IP-DOMAINF: 1 X-UNIQUE-TAG: <6678e80503688af26139173705667489> X-RL-SENDER: yili@winhong.com X-SENDER: yili@winhong.com X-LOGIN-NAME: yili@winhong.com X-FST-TO: libvir-list@redhat.com X-SENDER-IP: 14.18.236.70 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Yi Li To: libvir-list@redhat.com Subject: [PATCH] storage: volStorageBackendRBDRefreshVolInfo: refactor Date: Fri, 8 Jan 2021 14:44:31 +0800 Message-Id: <20210108064431.3142788-1-yili@winhong.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 1086qtft025802 X-loop: libvir-list@redhat.com Cc: Yi Li X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" use the ret variable for return value Signed-off-by: Yi Li Reviewed-by: Michal Privoznik --- src/storage/storage_backend_rbd.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 1630d6eede..22f5c78591 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -507,36 +507,30 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPt= r vol, virStoragePoolObjPtr pool, virStorageBackendRBDStatePtr ptr) { - int rc, ret =3D -1; + int ret =3D -1; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); rbd_image_t image =3D NULL; rbd_image_info_t info; uint64_t features; uint64_t flags; =20 - if ((rc =3D rbd_open_read_only(ptr->ioctx, vol->name, &image, NULL)) <= 0) { - ret =3D rc; + if ((ret =3D rbd_open_read_only(ptr->ioctx, vol->name, &image, NULL)) = < 0) { virReportSystemError(errno, _("failed to open the RBD image '%s'"), vol->name); goto cleanup; } =20 - if ((rc =3D rbd_stat(image, &info, sizeof(info))) < 0) { - ret =3D rc; + if ((ret =3D rbd_stat(image, &info, sizeof(info))) < 0) { virReportSystemError(errno, _("failed to stat the RBD image '%s'"), vol->name); goto cleanup; } =20 - if ((rc =3D volStorageBackendRBDGetFeatures(image, vol->name, &feature= s)) < 0) { - ret =3D rc; + if ((ret =3D volStorageBackendRBDGetFeatures(image, vol->name, &featur= es)) < 0) goto cleanup; - } =20 - if ((rc =3D volStorageBackendRBDGetFlags(image, vol->name, &flags)) < = 0) { - ret =3D rc; + if ((ret =3D volStorageBackendRBDGetFlags(image, vol->name, &flags)) <= 0) goto cleanup; - } =20 vol->target.capacity =3D info.size; vol->type =3D VIR_STORAGE_VOL_NETWORK; @@ -549,10 +543,8 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr= vol, "Querying for actual allocation", def->source.name, vol->name); =20 - if ((rc =3D virStorageBackendRBDSetAllocation(vol, image, &info)) = < 0) { - ret =3D rc; + if ((ret =3D virStorageBackendRBDSetAllocation(vol, image, &info))= < 0) goto cleanup; - } } else { vol->target.allocation =3D info.obj_size * info.num_objs; } @@ -568,8 +560,6 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr = vol, VIR_FREE(vol->key); vol->key =3D g_strdup_printf("%s/%s", def->source.name, vol->name); =20 - ret =3D 0; - cleanup: if (image) rbd_close(image); --=20 2.25.3