From nobody Mon Nov 25 16:44:31 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1600868048; cv=none; d=zohomail.com; s=zohoarc; b=YpqKUNH04+3J+pBBZe1yiUuiaeEGEq5SjsJY802tMfq8YsMNFwhd6lEmkwFhoIin4NZQnz+HU+XypA7iTQV5Q+B40HNk896ZM3jDdzhZgtzbUu9TgCGM11o4KGN/KEr/h7vrgMGDQXxfAW3UvIwXTY9K+oMqSBk4EixmZmffZp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868048; 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; bh=XG51X0f/RI3xbqMaCH/2G+KZ/BoxRt4q0h521VaiPg8=; b=mFNbIwLbfWjQnCp3e02lh+FUgLXgeUQabEDnOiJ95EGV9Bv4qJuBisDelvnGAHA+8C9fXAuL1LFxtshqT/gzx40kclKCBZaepC1ADG67URyVxzgVghR5qope756O9AcgzLrCse9Rzus+EyfqGgyE3BOgie0Megu3a4LMGo9Mv0E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= 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 1600868048786305.43954174734347; Wed, 23 Sep 2020 06:34:08 -0700 (PDT) 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-72-rreKZGbzMX6aTmM222W3rA-1; Wed, 23 Sep 2020 09:34:05 -0400 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 1F48E801AE9; Wed, 23 Sep 2020 13:34:00 +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 EC49A55777; Wed, 23 Sep 2020 13:33: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 57024183D043; Wed, 23 Sep 2020 13:33:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NDXtwn013891 for ; Wed, 23 Sep 2020 09:33:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42637100238E; Wed, 23 Sep 2020 13:33:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9981810021AA for ; Wed, 23 Sep 2020 13:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868047; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XG51X0f/RI3xbqMaCH/2G+KZ/BoxRt4q0h521VaiPg8=; b=dhcn6AH51Qv7KUR6XUtkB3ZnjQB81s2luF5md+bd3IS7HhCB6UP+4DSft4HHo04fRXOTWg QXWlRoz3IOkZuAkMFxRadFkvpyLR2zZlcleUlwIouwDwt5sZHPOMIsAOcTjhBB2AHuaCJu 8yXDtWtoP8jEEtCbD7G771GgDgN2P18= X-MC-Unique: rreKZGbzMX6aTmM222W3rA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/13] virDomainSnapshotAlignDisks: Refactor cleanup Date: Wed, 23 Sep 2020 15:33:36 +0200 Message-Id: <7a66077024983a0c79718cf7d7d13f1b78559b2f.1600867955.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use automatic pointer for the bitmap and get rid of the 'cleanup' label and 'ret' variable. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 87a00082ef..160f2054a4 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -649,31 +649,28 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, int default_snapshot, bool require_match) { - int ret =3D -1; - virBitmapPtr map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; size_t i; int ndisks; if (!def->parent.dom) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); - goto cleanup; + return -1; } if (def->ndisks > def->parent.dom->ndisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("too many disk snapshot requests for domain")); - goto cleanup; + return -1; } /* Unlikely to have a guest without disks but technically possible. */ - if (!def->parent.dom->ndisks) { - ret =3D 0; - goto cleanup; - } + if (!def->parent.dom->ndisks) + return 0; if (!(map =3D virBitmapNew(def->parent.dom->ndisks))) - goto cleanup; + return -1; /* Double check requested disks. */ for (i =3D 0; i < def->ndisks; i++) { @@ -684,14 +681,14 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, if (idx < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("no disk named '%s'"), disk->name); - goto cleanup; + return -1; } if (virBitmapIsBitSet(map, idx)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' specified twice"), disk->name); - goto cleanup; + return -1; } ignore_value(virBitmapSetBit(map, idx)); disk->idx =3D idx; @@ -714,7 +711,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' must use snapshot mode '%s'"), disk->name, tmp); - goto cleanup; + return -1; } if (disk->src->path && disk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { @@ -722,7 +719,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, _("file '%s' for disk '%s' requires " "use of external snapshot mode"), disk->src->path, disk->name); - goto cleanup; + return -1; } if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) { VIR_FREE(disk->name); @@ -734,7 +731,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, ndisks =3D def->ndisks; if (VIR_EXPAND_N(def->disks, def->ndisks, def->parent.dom->ndisks - def->ndisks) < 0) - goto cleanup; + return -1; for (i =3D 0; i < def->parent.dom->ndisks; i++) { virDomainSnapshotDiskDefPtr disk; @@ -762,13 +759,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr de= f, /* Generate default external file names for external snapshot location= s */ if (virDomainSnapshotDefAssignExternalNames(def) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virBitmapFree(map); - return ret; + return 0; } --=20 2.26.2