From nobody Mon Feb 9 16:54:06 2026 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=1598271136; cv=none; d=zohomail.com; s=zohoarc; b=oGvqUP/z0fJSptB/qgYk6wX2HqWTRrIqwURwHxjlpCJQN83D9XbMvBTyupiHD/6nSvwomuikRifQrFpHaebXZEWfj0XIypkCb1yxQU7BVoR9/V7gPbRQyDnBs6YYUFQDwoesBAcefNO5BAY7JdzIpCt/y8axW4ZrXRbLx+CkGfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271136; 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=IRwqEbRn4H0Z25w8REOuIWjw3vDt2xSe/abQ03aPikM=; b=KKYUKFpxAFjxA2P6tR37uUM4DqHO+QmYNtzAY3l4w3gj9jTiuwnYBYLNmbFN/OCNJzk0L5k1RltcCRuTwg3NuemHOPUAVwKGejkEJ3c979KSQ8iDf23rtia2n8skhazO3s7sJL1KLorgakxfCHWNoBBUswYg4td6unO0ojqoopA= 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 159827113647254.05442616885057; Mon, 24 Aug 2020 05:12:16 -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-184-TmgEewimNLGS2spfI9i_Tg-1; Mon, 24 Aug 2020 08:12:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E05D801AE6; Mon, 24 Aug 2020 12:12:05 +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 4D0FD5FC3B; Mon, 24 Aug 2020 12:12:05 +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 1B76B18A0B6A; Mon, 24 Aug 2020 12:12:05 +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 07OC6BgQ030850 for ; Mon, 24 Aug 2020 08:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FFE410013C4; Mon, 24 Aug 2020 12:06:11 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0052E10013C1 for ; Mon, 24 Aug 2020 12:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271135; 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=IRwqEbRn4H0Z25w8REOuIWjw3vDt2xSe/abQ03aPikM=; b=go496uWUGMt3mcNHcStzl0I+p0RStf7vpqh1QF/7t8aLjk04OFexxlfgC3IB3iW631yZfz U+1kOg8wfRBnFxhm+HkixmdrWgjmo3pkRWLuIXRWWRDpn9rdAujSeTLyyRXingmqzltiDz Ohmo+6yOWuFzQHL8F8JlPu3lxgOp3UA= X-MC-Unique: TmgEewimNLGS2spfI9i_Tg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/7] qemuMigrationCapsCheck: Refactor variable cleanup Date: Mon, 24 Aug 2020 14:05:59 +0200 Message-Id: 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.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 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 memory allocation to simplify the code and remove the need for a 'cleanup:' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 33 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 38a5a91f2a..c785f87ab8 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1352,11 +1352,10 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, int asyncJob) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - virBitmapPtr migEvent =3D NULL; - virJSONValuePtr json =3D NULL; - char **caps =3D NULL; + g_autoptr(virBitmap) migEvent =3D NULL; + g_autoptr(virJSONValue) json =3D NULL; + VIR_AUTOSTRINGLIST caps =3D NULL; char **capStr; - int ret =3D -1; int rc; if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) @@ -1365,16 +1364,14 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, rc =3D qemuMonitorGetMigrationCapabilities(priv->mon, &caps); if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) - goto cleanup; + return -1; - if (!caps) { - ret =3D 0; - goto cleanup; - } + if (!caps) + return 0; priv->migrationCaps =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); if (!priv->migrationCaps) - goto cleanup; + return -1; for (capStr =3D caps; *capStr; capStr++) { int cap =3D qemuMigrationCapabilityTypeFromString(*capStr); @@ -1390,21 +1387,21 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT)) { migEvent =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); if (!migEvent) - goto cleanup; + return -1; ignore_value(virBitmapSetBit(migEvent, QEMU_MIGRATION_CAP_EVENTS)); if (!(json =3D qemuMigrationCapsToJSON(migEvent, migEvent))) - goto cleanup; + return -1; if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + return -1; rc =3D qemuMonitorSetMigrationCapabilities(priv->mon, json); json =3D NULL; if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + return -1; if (rc < 0) { virResetLastError(); @@ -1420,13 +1417,7 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver, ignore_value(virBitmapClearBit(priv->migrationCaps, QEMU_MIGRATION_CAP_EVENTS)); - ret =3D 0; - - cleanup: - virBitmapFree(migEvent); - virJSONValueFree(json); - g_strfreev(caps); - return ret; + return 0; } --=20 2.26.2