From nobody Mon Feb 9 10:34:37 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=1609941858; cv=none; d=zohomail.com; s=zohoarc; b=n+3iJ2zfhvi5CcFPJOQnsoQ+8dHMgKYbQoGaBKXsiUeuxDMNca47bJt0gdZWPV5egs/YpS0a6umPUFrbgGhTvQ2P1IZUueLVpcF6JsBTZsh2gosagpEUwFYdgmWFfMIJiWmRArMDWBenLvGj8Xo2wbn8+qpIvGoKMW6OHnh2F4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609941858; 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=GSQXHaQy/ZLSr4tSkzGAZZz5ByPoaT8h6jM2G3D6s5E=; b=Ny16AveJpLq92mNtNKlHabqrBoE5WujoV80u3USpgEkxdLXIg6jUKqc7nbJNoOeSwUtP8R62Ew+Jd064CtWDERVa3N05T34RtAf0tEtkBjAj0DuuTi52B9I0FvGWwM9VRN/yH75HZec2+sxyk2onntsAgKK8hz+btf1uMNuA2Ck= 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 1609941858370203.56209610108567; Wed, 6 Jan 2021 06:04:18 -0800 (PST) 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-130-_cmVdms3NeKCaNoftz6MCw-1; Wed, 06 Jan 2021 09:04:14 -0500 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 8F2EC80362D; Wed, 6 Jan 2021 14:04:07 +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 6B26F5D9CD; Wed, 6 Jan 2021 14:04:07 +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 31CB64EEEE; Wed, 6 Jan 2021 14:04:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106E3roK031358 for ; Wed, 6 Jan 2021 09:03:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id AB5231840B; Wed, 6 Jan 2021 14:03:53 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF49B37A0 for ; Wed, 6 Jan 2021 14:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609941857; 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=GSQXHaQy/ZLSr4tSkzGAZZz5ByPoaT8h6jM2G3D6s5E=; b=HUepawrzRGLhNVyUI4U69SOYsNN7X1vhIzYCjRFjjCjCFa9oEs6IxSc0aLINW0aekhFwnJ HnuFINxvt6vZD06cUIiE+4EKTizqLZrLN4rpNZll8jntM3S5uzF6hi5jC1rblWWxM5V2CB SVdfSovkrzwMCDtG0SffdRJyS1dHIVo= X-MC-Unique: _cmVdms3NeKCaNoftz6MCw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/12] testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities: refactor cleanup Date: Wed, 6 Jan 2021 15:03:35 +0100 Message-Id: <728880c74acf12b1fe44ab3d2eb393957f501463.1609941694.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 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 freeing to remove the 'cleanup:' label and 'ret' variable. Signed-off-by: Peter Krempa --- tests/qemumonitorjsontest.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 13794c2886..29c396891b 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2050,11 +2050,10 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapab= ilities(const void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOptionPtr xmlopt =3D data->xmlopt; - int ret =3D -1; const char *cap; - char **caps =3D NULL; - virBitmapPtr bitmap =3D NULL; - virJSONValuePtr json =3D NULL; + g_auto(GStrv) caps =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; + g_autoptr(virJSONValue) json =3D NULL; const char *reply =3D "{" " \"return\": [" @@ -2073,32 +2072,26 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapab= ilities(const void *opaque) if (qemuMonitorTestAddItem(test, "query-migrate-capabilities", reply) = < 0 || qemuMonitorTestAddItem(test, "migrate-set-capabilities", "{\"return\":{}}") < 0) - goto cleanup; + return -1; if (qemuMonitorGetMigrationCapabilities(qemuMonitorTestGetMonitor(test= ), &caps) < 0) - goto cleanup; + return -1; cap =3D qemuMigrationCapabilityTypeToString(QEMU_MIGRATION_CAP_XBZRLE); if (!virStringListHasString((const char **) caps, cap)) { virReportError(VIR_ERR_INTERNAL_ERROR, "Expected capability %s is missing", cap); - goto cleanup; + return -1; } bitmap =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); ignore_value(virBitmapSetBit(bitmap, QEMU_MIGRATION_CAP_XBZRLE)); if (!(json =3D qemuMigrationCapsToJSON(bitmap, bitmap))) - goto cleanup; - - ret =3D qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMoni= tor(test), - &json); + return -1; - cleanup: - virJSONValueFree(json); - g_strfreev(caps); - virBitmapFree(bitmap); - return ret; + return qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMonit= or(test), + &json); } static int --=20 2.29.2