From nobody Mon Feb 9 06:33:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1623752866; cv=none; d=zohomail.com; s=zohoarc; b=UYoY/Rwbn3m/+8JDJDc1q8hy4RVBCKWD+Rlzikg20onH6f5UQPeSLQhX6RnfKWnIJ31g+qFmQOmNGGyFRIUb+c5Rcw6Eaw3D/bbgt0xKDY5HopL6ZxpVg2FSejnfWz1aUzbjcbkBAd0+88DKue3AMTZa7SetGtP+MOQf4n6uJ5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623752866; 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=+R8Jywp4oGb6siH99XbHMDXSg8Vnpa90E996hfix40w=; b=ITYL1pUq+Ot2Fm5eJGCRjbDUzZebBRyjH53gYMcfHhfHOBmxM/fyEhqJ3Eq62SSaT9FDrMA0iVB+AfU4Pi3G+6fbDRwFqYM85UBA47cw9VJ9MK7+9HXFvfaF4XzVA/EyA41cxK20Y4OZtDpxQ8RnKylaPZ/XQd+3IQ+SvDcJ7Ic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623752866384500.8770467337897; Tue, 15 Jun 2021 03:27:46 -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-314-wK8saVcROjaZINjQlfKtfA-1; Tue, 15 Jun 2021 06:27:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C857A40CB; Tue, 15 Jun 2021 10:27:39 +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 E27491962D; Tue, 15 Jun 2021 10:27:38 +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 A8C6D1809CAE; Tue, 15 Jun 2021 10:27:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15FARYUW019632 for ; Tue, 15 Jun 2021 06:27:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8357E189BB; Tue, 15 Jun 2021 10:27:34 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD7DA60BD9 for ; Tue, 15 Jun 2021 10:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623752865; 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=+R8Jywp4oGb6siH99XbHMDXSg8Vnpa90E996hfix40w=; b=F+1Jrd9+XXVMoCu0BSxRvf8sZH3SZZT6iO8TgnP4tK9JzSqmlqcbgMiY4jmrXKTJSUua0e ist3EMpMRihaagLEbtDjy1BVtLRQh2MRMvZLpfA6efOmiTl84r51Md4VNOR7oNvnJnISv6 /h2do4OKekKM+g5CKEicSxfXIhFjflQ= X-MC-Unique: wK8saVcROjaZINjQlfKtfA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/13] qemuMonitorJSONGetMigrationCapabilities: Refactor cleanup Date: Tue, 15 Jun 2021 12:27:16 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 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 clearing and remove the cleanup section. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 64696da210..f0d67f8f20 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6768,11 +6768,10 @@ int qemuMonitorJSONGetMigrationCapabilities(qemuMonitor *mon, char ***capabilities) { - int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; - char **list =3D NULL; + g_auto(GStrv) list =3D NULL; size_t i; size_t n; @@ -6783,15 +6782,13 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitor= *mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret =3D 0; - goto cleanup; - } + if (qemuMonitorJSONHasError(reply, "CommandNotFound")) + return 0; if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; caps =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(caps); @@ -6805,26 +6802,20 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitor= *mon, if (!cap || virJSONValueGetType(cap) !=3D VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing entry in migration capabilities list= ")); - goto cleanup; + return -1; } if (!(name =3D virJSONValueObjectGetString(cap, "capability"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing migration capability name")); - goto cleanup; + return -1; } list[i] =3D g_strdup(name); } - ret =3D n; *capabilities =3D g_steal_pointer(&list); - - cleanup: - g_strfreev(list); - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return n; } --=20 2.31.1