From nobody Mon Feb 9 01:48:28 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=1565952000; cv=none; d=zoho.com; s=zohoarc; b=hvzL9IvtIw3tgSbaEvW/UIZxQkyXx2ttEYxfASNMkMnbxqv1g06llMLpKFN3MOgP/1AJgB6TCY/rILsQneLurrU1fE3CW/h3Sd1H/FNIcbA/1UIkYbHLqfXvCg8H/tHTAOQ59q/4G4avLGvzncMTDjgeVAd/vd/nxbri9SqkHYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952000; 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=zjCviZEpwlDCgN1kFXk1oWIo2+s7SzYdkK5GSNg8H7s=; b=WB9QACV2KIOUSL7tHXeZWFkrWG+gNClfeZ/cxyzK97jJOLHfnN3zndH9lyURTpR3dZcoBTaEMcZsNZac34gHFCNcPs7wlnUq3ihSuOBz4eyt7+57WccUHygSgoQhXiKGLsG+EhOs55dAhUX6ZFkQoEx2VTTgvFi97cswby6IXz0= 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 1565952000596783.0625912415389; Fri, 16 Aug 2019 03:40:00 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 2610686662; Fri, 16 Aug 2019 10:39:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 026538F6C1; Fri, 16 Aug 2019 10:39:59 +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 C11E619722; Fri, 16 Aug 2019 10:39:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7GAdhgO021512 for ; Fri, 16 Aug 2019 06:39:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9EBA4A4F96; Fri, 16 Aug 2019 10:39:43 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A653A4F86 for ; Fri, 16 Aug 2019 10:39:43 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/14] util: storagefile: Simplify cleanup handling in virStorageSourceParseBackingURI 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 16 Aug 2019 10:39:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Automatically clean the 'uri' variable and get rid of the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 8af45bfbd2..e93f6285b0 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2664,32 +2664,31 @@ static int virStorageSourceParseBackingURI(virStorageSourcePtr src, const char *uristr) { - virURIPtr uri =3D NULL; + VIR_AUTOPTR(virURI)uri =3D NULL; const char *path =3D NULL; - int ret =3D -1; VIR_AUTOSTRINGLIST scheme =3D NULL; if (!(uri =3D virURIParse(uristr))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse backing file location '%s'"), uristr); - goto cleanup; + return -1; } if (VIR_ALLOC(src->hosts) < 0) - goto cleanup; + return -1; src->nhosts =3D 1; if (!(scheme =3D virStringSplit(uri->scheme, "+", 2))) - goto cleanup; + return -1; if (!scheme[0] || (src->protocol =3D virStorageNetProtocolTypeFromString(scheme[0]))= < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid backing protocol '%s'"), NULLSTR(scheme[0])); - goto cleanup; + return -1; } if (scheme[1] && @@ -2697,13 +2696,13 @@ virStorageSourceParseBackingURI(virStorageSourcePtr= src, virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid protocol transport type '%s'"), scheme[1]); - goto cleanup; + return -1; } /* handle socket stored as a query */ if (uri->query) { if (VIR_STRDUP(src->hosts->socket, STRSKIP(uri->query, "socket=3D"= )) < 0) - goto cleanup; + return -1; } /* XXX We currently don't support auth, so don't bother parsing it */ @@ -2725,7 +2724,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, path =3D NULL; if (VIR_STRDUP(src->path, path) < 0) - goto cleanup; + return -1; if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER) { char *tmp; @@ -2733,7 +2732,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, if (!src->path) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("missing volume name and path for gluster vol= ume")); - goto cleanup; + return -1; } if (!(tmp =3D strchr(src->path, '/')) || @@ -2741,13 +2740,13 @@ virStorageSourceParseBackingURI(virStorageSourcePtr= src, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("missing volume name or file name in " "gluster source path '%s'"), src->path); - goto cleanup; + return -1; } src->volume =3D src->path; if (VIR_STRDUP(src->path, tmp + 1) < 0) - goto cleanup; + return -1; tmp[0] =3D '\0'; } @@ -2755,13 +2754,9 @@ virStorageSourceParseBackingURI(virStorageSourcePtr = src, src->hosts->port =3D uri->port; if (VIR_STRDUP(src->hosts->name, uri->server) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virURIFree(uri); - return ret; + return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list