From nobody Mon May 13 23:45:49 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=1609857883; cv=none; d=zohomail.com; s=zohoarc; b=Ia/pxnj1V6vFll6fubQOwK9FkXXNPyffOiUEsuidXazETB8+AFwdODgk6O1bGJJLQtJq9vRVV87RYbMR0JYyMAnWLZIq2J+HTK+f2XeJGuyH53t0vnqVSoMleVoMahy05SWCKSfv2zkRnFtxzvwYF5tD3b09MQEnrA8fGv0YjNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609857883; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s20YU8Lb8TZisUFBkM/7P1zInuG8cyBfJNyDoNhQl+0=; b=TxP0vzgDOdvOJ0kR2JyCoYRr9Cbm/59x0lvJ1VWqLjg4KN+cEe2VROtR4G6/2RFARj+IBjL/26sPdxEB5JNT+gZZRHSOh1m/JBGrK+9su3v1aPXGHe4idYN8NzekdyuvVw9BM44wy1AvXj2YT849rTbbNzjCnQNZtQsLOba2nbY= 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 1609857883556253.83365695112843; Tue, 5 Jan 2021 06:44:43 -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-382-NMfo8vOYMnykaFucujhwXQ-1; Tue, 05 Jan 2021 09:44:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE9748030AF; Tue, 5 Jan 2021 14:44:34 +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 4CF667092C; Tue, 5 Jan 2021 14:44:33 +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 B54A6180954D; Tue, 5 Jan 2021 14:44:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 105EiS1N014731 for ; Tue, 5 Jan 2021 09:44:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 12C502026D3B; Tue, 5 Jan 2021 14:44:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CC0D2026DE8 for ; Tue, 5 Jan 2021 14:44:25 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 A6DE9805B03 for ; Tue, 5 Jan 2021 14:44:25 +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-488-Skpmys9UMJSqBuj8cd-CVA-1; Tue, 05 Jan 2021 09:44:22 -0500 Received: from localhost (unknown [192.168.167.16]) by regular1.263xmail.com (Postfix) with ESMTP id D38EC1D8A for ; Tue, 5 Jan 2021 22:44:15 +0800 (CST) Received: from localhost.localdomain (unknown [14.18.236.70]) by smtp.263.net (postfix) whith ESMTP id P11398T139672637736704S1609857845743456_; Tue, 05 Jan 2021 22:44:16 +0800 (CST) X-MC-Unique: NMfo8vOYMnykaFucujhwXQ-1 X-MC-Unique: Skpmys9UMJSqBuj8cd-CVA-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: <2a87fb9a10a43035ecc1319cf66ec61a> X-RL-SENDER: yili@winhong.com X-SENDER: yili@winhong.com X-LOGIN-NAME: yili@winhong.com X-FST-TO: mprivozn@redhat.com X-SENDER-IP: 14.18.236.70 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Yi Li To: mprivozn@redhat.com Subject: [PATCH v2 1/3] createRawFile: remove unused return variable Date: Tue, 5 Jan 2021 22:43:30 +0800 Message-Id: <20210105144332.2605148-2-yili@winhong.com> In-Reply-To: <20210105144332.2605148-1-yili@winhong.com> References: <20210105144332.2605148-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.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 105EiS1N014731 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, 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.13 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" remove unused return variable, The errno will throw by virReportSystemError Signed-off-by: Yi Li Reviewed-by: Michal Privoznik --- src/storage/storage_util.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index cf1f33f177..c13abf03af 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -315,7 +315,6 @@ createRawFile(int fd, virStorageVolDefPtr vol, bool reflink_copy) { bool need_alloc =3D true; - int ret =3D 0; unsigned long long pos =3D 0; =20 /* If the new allocation is lower than the capacity of the original fi= le, @@ -327,11 +326,10 @@ createRawFile(int fd, virStorageVolDefPtr vol, /* Seek to the final size, so the capacity is available upfront * for progress reporting */ if (ftruncate(fd, vol->target.capacity) < 0) { - ret =3D -errno; virReportSystemError(errno, _("cannot extend file '%s'"), vol->target.path); - return ret; + return -1; } =20 /* Avoid issues with older kernel's namespace pollution. */ @@ -347,11 +345,10 @@ createRawFile(int fd, virStorageVolDefPtr vol, if (fallocate(fd, 0, 0, vol->target.allocation) =3D=3D 0) { need_alloc =3D false; } else if (errno !=3D ENOSYS && errno !=3D EOPNOTSUPP) { - ret =3D -errno; virReportSystemError(errno, _("cannot allocate %llu bytes in file '%s= '"), vol->target.allocation, vol->target.path); - return ret; + return -1; } } #endif @@ -361,9 +358,9 @@ createRawFile(int fd, virStorageVolDefPtr vol, /* allow zero blocks to be skipped if we've requested sparse * allocation (allocation < capacity) or we have already * been able to allocate the required space. */ - if ((ret =3D virStorageBackendCopyToFD(vol, inputvol, fd, &remain, - !need_alloc, reflink_copy)) <= 0) - return ret; + if (virStorageBackendCopyToFD(vol, inputvol, fd, &remain, + !need_alloc, reflink_copy) < 0) + return -1; =20 /* If the new allocation is greater than the original capacity, * but fallocate failed, fill the rest with zeroes. @@ -373,21 +370,19 @@ createRawFile(int fd, virStorageVolDefPtr vol, =20 if (need_alloc && (vol->target.allocation - pos > 0)) { if (safezero(fd, pos, vol->target.allocation - pos) < 0) { - ret =3D -errno; virReportSystemError(errno, _("cannot fill file '%s'"), vol->target.path); - return ret; + return -1; } } =20 if (g_fsync(fd) < 0) { - ret =3D -errno; virReportSystemError(errno, _("cannot sync data to file '%s'"), vol->target.path); - return ret; + return -1; } =20 - return ret; + return 0; } =20 static int --=20 2.25.3 From nobody Mon May 13 23:45:49 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=1609857902; cv=none; d=zohomail.com; s=zohoarc; b=K7iYdNEhGhH16MhA2fGmMKQnlwCH3AOEk9ZXKnOkv1jaO9gvqE3icQDqNEP1eL4woIwM8KNFxOQACLpbB6MT+z9iaxEgVJ2YbEDnUSLttsKkt0zX6muzokN3JulQJMTiOS4E8RY0Zj2/zOVMZp4GXqczLb217ocPL63zCFXOU6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609857902; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+I4XDy3c/8TyZH4twHVfJQn90xUm4R4CF2lIe5WVvBM=; b=CDbwrG/tOzL4YRGmAglQmWEgS/Poric33H3d06P7SUZEU3x4WU1F64cboJwWOzWaA+o16nndDJ9tKcJjYT30h113pSEu25IHqEdrSNH64g5DtWT8SRsgWXSV0Sw42QIQSfVW732kfedgPLZlKzSrbPqwBtkOw9lzuxBkIAfD0v4= 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 1609857902321618.9082113854674; Tue, 5 Jan 2021 06:45:02 -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-590-n1ZcFD0TNk2iancg0TqFcg-1; Tue, 05 Jan 2021 09:44:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8870804012; Tue, 5 Jan 2021 14:44:51 +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 95CCF70946; Tue, 5 Jan 2021 14:44:51 +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 60D6E1809CA3; Tue, 5 Jan 2021 14:44:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 105Eihr5014784 for ; Tue, 5 Jan 2021 09:44:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id A61A2111142E; Tue, 5 Jan 2021 14:44:43 +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 A1EC0111142F for ; Tue, 5 Jan 2021 14:44:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 9000F858280 for ; Tue, 5 Jan 2021 14:44:43 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.70.203]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-541-ekpy0kBnMweJZlu3jIIvaA-1; Tue, 05 Jan 2021 09:44:41 -0500 Received: from localhost (unknown [192.168.167.16]) by regular1.263xmail.com (Postfix) with ESMTP id 75A897EA for ; Tue, 5 Jan 2021 22:44:19 +0800 (CST) Received: from localhost.localdomain (unknown [14.18.236.70]) by smtp.263.net (postfix) whith ESMTP id P11398T139672637736704S1609857845743456_; Tue, 05 Jan 2021 22:44:20 +0800 (CST) X-MC-Unique: n1ZcFD0TNk2iancg0TqFcg-1 X-MC-Unique: ekpy0kBnMweJZlu3jIIvaA-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: <6bb4b219486831f5854cb67fffdafff2> X-RL-SENDER: yili@winhong.com X-SENDER: yili@winhong.com X-LOGIN-NAME: yili@winhong.com X-FST-TO: mprivozn@redhat.com X-SENDER-IP: 14.18.236.70 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Yi Li To: mprivozn@redhat.com Subject: [PATCH v2 2/3] virStorageBackendCopyToFD: remove unused return variable Date: Tue, 5 Jan 2021 22:43:31 +0800 Message-Id: <20210105144332.2605148-3-yili@winhong.com> In-Reply-To: <20210105144332.2605148-1-yili@winhong.com> References: <20210105144332.2605148-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.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 105Eihr5014784 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, 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.13 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" remove unused return variable, The errno will throw by virReportSystemError Signed-off-by: Yi Li Reviewed-by: Michal Privoznik --- src/storage/storage_util.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index c13abf03af..c6d0f7a97c 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -128,7 +128,6 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, bool reflink_copy) { int amtread =3D -1; - int ret =3D 0; size_t rbytes =3D READ_BLOCK_SIZE_DEFAULT; int wbytes =3D 0; int interval; @@ -138,11 +137,10 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, VIR_AUTOCLOSE inputfd =3D -1; =20 if ((inputfd =3D open(inputvol->target.path, O_RDONLY)) < 0) { - ret =3D -errno; virReportSystemError(errno, _("could not open input path '%s'"), inputvol->target.path); - return ret; + return -1; } =20 #ifdef __linux__ @@ -160,11 +158,10 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, =20 if (reflink_copy) { if (reflinkCloneFile(fd, inputfd) < 0) { - ret =3D -errno; virReportSystemError(errno, _("failed to clone files from '%s'"), inputvol->target.path); - return ret; + return -1; } else { VIR_DEBUG("btrfs clone finished."); return 0; @@ -178,11 +175,10 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, rbytes =3D *total; =20 if ((amtread =3D saferead(inputfd, buf, rbytes)) < 0) { - ret =3D -errno; virReportSystemError(errno, _("failed reading from file '%s'"), inputvol->target.path); - return ret; + return -1; } *total -=3D amtread; =20 @@ -195,36 +191,32 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, =20 if (want_sparse && memcmp(buf+offset, zerobuf, interval) =3D= =3D 0) { if (lseek(fd, interval, SEEK_CUR) < 0) { - ret =3D -errno; virReportSystemError(errno, _("cannot extend file '%s'"), vol->target.path); - return ret; + return -1; } } else if (safewrite(fd, buf+offset, interval) < 0) { - ret =3D -errno; virReportSystemError(errno, _("failed writing to file '%s'"), vol->target.path); - return ret; + return -1; =20 } } while ((amtleft -=3D interval) > 0); } =20 if (virFileDataSync(fd) < 0) { - ret =3D -errno; virReportSystemError(errno, _("cannot sync data to file '%s'"), vol->target.path); - return ret; + return -1; } =20 if (VIR_CLOSE(inputfd) < 0) { - ret =3D -errno; virReportSystemError(errno, _("cannot close file '%s'"), inputvol->target.path); - return ret; + return -1; } =20 return 0; --=20 2.25.3 From nobody Mon May 13 23:45:49 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=1609857898; cv=none; d=zohomail.com; s=zohoarc; b=MFcY+7dGpsjLeMNZTe8rr46GNE755pPJdKiCEFu//q+fQIF/KSor/zAO5S1JlJGNxtX9QPhpeXgYNVqtfEYuMyfPltUX5IA8xNeUYQQSYbhyTYgE/OQaq8BtJpDIuwvUa+w0Ig5czZTS3jv487a/xOLCqFi8fWxusFpfjLHWi0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609857898; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v0o3Iy+cZJIjRBmFi8T02nEfP/RL4BbJVlXykRSEiPo=; b=ALYYaIfxnRAomzYDX1c7Egu9qOTkTbbkWLHn55VNYNTpEUOeGe/xn05Y30nXL1jxIJyjoWgUaRCJC3YEuQUgg3D64EK+xm8TRLZw3fWU3DuV9z6yJ7Cv1Jx7naU2VSBRLPzIl8bfnDeVwqoLuMl875ZICJ1hRxToeJL/R4DBjMY= 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 1609857897779987.6138770253657; Tue, 5 Jan 2021 06:44:57 -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-542-pQtPKUw8Mwe_70OIGT9UUA-1; Tue, 05 Jan 2021 09:44:53 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76FDB1005504; Tue, 5 Jan 2021 14:44:48 +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 52EFC5D9D7; Tue, 5 Jan 2021 14:44:48 +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 D0EF31809CA1; Tue, 5 Jan 2021 14:44:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 105EieXl014774 for ; Tue, 5 Jan 2021 09:44:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id B8BB61111431; Tue, 5 Jan 2021 14:44:40 +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 B48BB111142E for ; Tue, 5 Jan 2021 14:44:38 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 4A154858284 for ; Tue, 5 Jan 2021 14:44:38 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.70.205]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-7a-yy44PP8WN354cYPvp4w-1; Tue, 05 Jan 2021 09:44:34 -0500 Received: from localhost (unknown [192.168.167.16]) by regular1.263xmail.com (Postfix) with ESMTP id CE24D90F for ; Tue, 5 Jan 2021 22:44:26 +0800 (CST) Received: from localhost.localdomain (unknown [14.18.236.70]) by smtp.263.net (postfix) whith ESMTP id P11398T139672637736704S1609857845743456_; Tue, 05 Jan 2021 22:44:27 +0800 (CST) X-MC-Unique: pQtPKUw8Mwe_70OIGT9UUA-1 X-MC-Unique: 7a-yy44PP8WN354cYPvp4w-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: X-RL-SENDER: yili@winhong.com X-SENDER: yili@winhong.com X-LOGIN-NAME: yili@winhong.com X-FST-TO: mprivozn@redhat.com X-SENDER-IP: 14.18.236.70 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Yi Li To: mprivozn@redhat.com Subject: [PATCH v2 3/3] storageBackendCreateRaw: remove unused created Date: Tue, 5 Jan 2021 22:43:32 +0800 Message-Id: <20210105144332.2605148-4-yili@winhong.com> In-Reply-To: <20210105144332.2605148-1-yili@winhong.com> References: <20210105144332.2605148-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.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 105EieXl014774 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, 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.14 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" refactor and remove unused created variable. Signed-off-by: Yi Li Reviewed-by: Michal Privoznik --- src/storage/storage_util.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index c6d0f7a97c..cc8189c3e0 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -384,11 +384,9 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); - int ret =3D -1; int operation_flags; bool reflink_copy =3D false; mode_t open_mode =3D VIR_STORAGE_DEFAULT_VOL_PERM_MODE; - bool created =3D false; VIR_AUTOCLOSE fd =3D -1; =20 virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA | @@ -399,13 +397,13 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("metadata preallocation is not supported for raw " "volumes")); - goto cleanup; + return -1; } =20 if (virStorageSourceHasBacking(&vol->target)) { virReportError(VIR_ERR_NO_SUPPORT, "%s", _("backing storage not supported for raw volumes")); - goto cleanup; + return -1; } =20 if (flags & VIR_STORAGE_VOL_CREATE_REFLINK) @@ -415,7 +413,7 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool, if (vol->target.encryption) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("storage pool does not support encrypted volumes"= )); - goto cleanup; + return -1; } =20 operation_flags =3D VIR_FILE_OPEN_FORCE_MODE | VIR_FILE_OPEN_FORCE_OWN= ER; @@ -434,26 +432,25 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool, virReportSystemError(-fd, _("Failed to create file '%s'"), vol->target.path); - goto cleanup; + return -1; } - created =3D true; =20 /* NB, COW flag can only be toggled when the file is zero-size, * so must go before the createRawFile call allocates payload */ if (vol->target.nocow && virFileSetCOW(vol->target.path, VIR_TRISTATE_BOOL_NO) < 0) - goto cleanup; + goto error; =20 - if ((ret =3D createRawFile(fd, vol, inputvol, reflink_copy)) < 0) + if (createRawFile(fd, vol, inputvol, reflink_copy) < 0) /* createRawFile already reported the exact error. */ - ret =3D -1; + goto error; + return 0; =20 - cleanup: - if (ret < 0 && created) + error: ignore_value(virFileRemove(vol->target.path, vol->target.perms->uid, vol->target.perms->gid)); - return ret; + return -1; } =20 =20 --=20 2.25.3