From nobody Mon Feb 9 07:56:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1598271114; cv=none; d=zohomail.com; s=zohoarc; b=J7nBxOdOaQYuEdkLbi2y8pD6BNBeSGt53UmdDxWpF2UFLdhJ3X+Ld8dCYwQWnGJCCDL4b0ttyjuq6Q/+VJxYJNT1U4UHPPBzJThAR2XBxRj7VEftd0Cs9pfwHkx7I151n7qBrlbFdyVcfr7F85nPcGud2Twsrrt6liCpfWf+SEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598271114; 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=0o9qO7RMFtGtELlCR1TjwQjJjkBLOQXee6KudLSfO5g=; b=mfHGhLs8Q9BPV94SvMMIVqKaGQeXg09pZSdOylWAKOphq5bg2gFCluYzZU2ar/JDjbFjRiF82ucY+ThEyNwHN55nQBGlFaJJ6Hly4AUKZfcBfnO6MSWBwTBMqMvNbPQeqKLxb5f8PGWEm/R8GfLe3P0o6rT4yI5ojo/nCanOfEc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1598271114116834.8799705395413; Mon, 24 Aug 2020 05:11:54 -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-15-CHWaOmAlPouypQD2q3x1Xw-1; Mon, 24 Aug 2020 08:11:50 -0400 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 9A4BE81F010; Mon, 24 Aug 2020 12:11:44 +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 7A14E5DA2A; Mon, 24 Aug 2020 12:11:44 +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 86B8218A0B69; Mon, 24 Aug 2020 12:11:43 +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 07OC69VB030825 for ; Mon, 24 Aug 2020 08:06:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70DC310013C4; Mon, 24 Aug 2020 12:06:09 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC6CF10013C1 for ; Mon, 24 Aug 2020 12:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598271112; 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=0o9qO7RMFtGtELlCR1TjwQjJjkBLOQXee6KudLSfO5g=; b=hDb+YZflie7WmOUbPEIfk42nl2p1s0zmiaJqad4QTFq8c50Ef7KaMcpQZTdlNOlNcsdmWr k8bYp16sRGmZzk2xhIYoVvga17imt9SSXg8y8Lvd/AOMKu8+j5NQHeKqlD0pgJE02A5+CF XcZTT8oLn1DFAtHzF3pVw3oJ4wLGc+o= X-MC-Unique: CHWaOmAlPouypQD2q3x1Xw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] qemuMigrationCapsToJSON: Refactor variable cleanup Date: Mon, 24 Aug 2020 14:05:57 +0200 Message-Id: <05092bb347545b2acf357e7d77803e1e4acec6d4.1598270694.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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 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 and move variables into correct scope to simplify the code and remove the need for a 'error:' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index c22362735a..9b6601367a 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -759,14 +759,12 @@ virJSONValuePtr qemuMigrationCapsToJSON(virBitmapPtr caps, virBitmapPtr states) { - virJSONValuePtr json =3D NULL; - virJSONValuePtr cap =3D NULL; + g_autoptr(virJSONValue) json =3D virJSONValueNewArray(); qemuMigrationCapability bit; - const char *name; - - json =3D virJSONValueNewArray(); for (bit =3D 0; bit < QEMU_MIGRATION_CAP_LAST; bit++) { + g_autoptr(virJSONValue) cap =3D virJSONValueNewObject(); + const char *name =3D qemuMigrationCapabilityTypeToString(bit); bool supported =3D false; bool state =3D false; @@ -776,27 +774,19 @@ qemuMigrationCapsToJSON(virBitmapPtr caps, ignore_value(virBitmapGetBit(states, bit, &state)); - cap =3D virJSONValueNewObject(); - - name =3D qemuMigrationCapabilityTypeToString(bit); if (virJSONValueObjectAppendString(cap, "capability", name) < 0) - goto error; + return NULL; if (virJSONValueObjectAppendBoolean(cap, "state", state) < 0) - goto error; + return NULL; if (virJSONValueArrayAppend(json, cap) < 0) - goto error; + return NULL; cap =3D NULL; } - return json; - - error: - virJSONValueFree(json); - virJSONValueFree(cap); - return NULL; + return g_steal_pointer(&json); } --=20 2.26.2