From nobody Mon Feb 9 10:32:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565280064; cv=none; d=zoho.com; s=zohoarc; b=MwvuEl/Nu1Q60+QRoWO+Y6ZSDMRBNGsJry3DyRZlEbbmKswX50iwI5xImJWBFI/GG40xtMj+B/UkdQ/gLTgOhVkYRTaGK8BgVxUsfxyZgheFRuy0g4hEF/3poVshuI9xBTZbmlqhMAAhhSeC8MABf+ADBC+qdifUnzLsVomFxLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565280064; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=P9bLiNmL1RdKj77bxTCSRpUFzc+4XOM2HKhyai8tih0=; b=lbL7utScOSwu44oSWPWDDJ/9Y7txRGStn6dmSGj1dxD3f9ImLiDuQhKU7AlSqa24072/vy/33DOxDhtQgJxEodgAYVhwt/M13ZPpQL1JHr9hiRJHwhpBBh3ud5ku//KkBqg0sw8285ilYzTgGZIxFkl6Ync5VijLlG6ml2Ck1N8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15652800647951000.8435250755285; Thu, 8 Aug 2019 09:01:04 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C733030A7BA7; Thu, 8 Aug 2019 16:01: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 70EB060610; Thu, 8 Aug 2019 16:01: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 DFE64180B536; Thu, 8 Aug 2019 16:01:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78G0npM005385 for ; Thu, 8 Aug 2019 12:00:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id A06C0166BB; Thu, 8 Aug 2019 16:00:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A7E6166A7 for ; Thu, 8 Aug 2019 16:00:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:00:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/12] util: storage: Refactor logic for using virStorageFileGetBackendForSupportCheck 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 08 Aug 2019 16:01:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Modify the return value so that callers don't have to repeat logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a6de6a1e45..5882d470de 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4411,6 +4411,14 @@ virStorageFileIsInitialized(const virStorageSource *= src) } +/** + * virStorageFileGetBackendForSupportCheck: + * @src: storage source to check support for + * @backend: pointer to the storage backend for @src if it's supported + * + * Returns 0 if @src is not supported by any storage backend currently lin= ked + * 1 if it is supported and -1 on error with an error reported. + */ static int virStorageFileGetBackendForSupportCheck(const virStorageSource *src, virStorageFileBackendPtr *backend) @@ -4425,7 +4433,7 @@ virStorageFileGetBackendForSupportCheck(const virStor= ageSource *src, if (src->drv) { *backend =3D src->drv->backend; - return 0; + return 1; } actualType =3D virStorageSourceGetActualType(src); @@ -4433,7 +4441,10 @@ virStorageFileGetBackendForSupportCheck(const virSto= rageSource *src, if (virStorageFileBackendForType(actualType, src->protocol, false, bac= kend) < 0) return -1; - return 0; + if (!*backend) + return 0; + + return 1; } @@ -4443,12 +4454,8 @@ virStorageFileSupportsBackingChainTraversal(virStora= geSourcePtr src) virStorageFileBackendPtr backend; int rv; - rv =3D virStorageFileGetBackendForSupportCheck(src, &backend); - if (rv < 0) - return -1; - - if (!backend) - return 0; + if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + return rv; return backend->storageFileGetUniqueIdentifier && backend->storageFileRead && @@ -4470,11 +4477,8 @@ virStorageFileSupportsSecurityDriver(const virStorag= eSource *src) virStorageFileBackendPtr backend; int rv; - rv =3D virStorageFileGetBackendForSupportCheck(src, &backend); - if (rv < 0) - return -1; - if (backend =3D=3D NULL) - return 0; + if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + return rv; return backend->storageFileChown ? 1 : 0; } @@ -4492,13 +4496,10 @@ int virStorageFileSupportsAccess(const virStorageSource *src) { virStorageFileBackendPtr backend; - int ret; + int rv; - ret =3D virStorageFileGetBackendForSupportCheck(src, &backend); - if (ret < 0) - return -1; - if (backend =3D=3D NULL) - return 0; + if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + return rv; return backend->storageFileAccess ? 1 : 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list