From nobody Mon Feb 9 07:26:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075031; cv=none; d=zohomail.com; s=zohoarc; b=LrhA37/mP0L0jGtb0YwiVp+d9duopMUDnlkMYhVsnD+5WPpRjQYzJJDIggxWHaqkhzpOEh++3SHY96nO5UPbbnly3fADfTPCEJIhBpCxNjSZYZoJ3MYNqlwgJPIs1MAtV/VGWbvUoNBto6dGC9I01xmIhaRYqpY/6n/yVOrVq+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075031; 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=ed3FBXbzOAZs3SE3GCz35oCPf2O+a3qvmW+od9lYaqM=; b=kbYCrUaQnn7XZ3TYBNmqU4pGjTpP2nMqC+Dei3+2+Nph07cIyKEXKhVpl9t4PVqjo+r4hPdtIKzUz+gpK3/V1WaYKKSRsEYe0DxuH0sHe8IL/rVSMAcWWNPB7h/8JSMh+B5lfqibwhYbmG6sXoq4UVcVSjHNwWbK+xLxUWM0Z3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 162807503183229.61902096671713; Wed, 4 Aug 2021 04:03:51 -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-451-S-xaoPm2MguSe-JBX_N_xg-1; Wed, 04 Aug 2021 07:03:49 -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 AC0FE1966333; Wed, 4 Aug 2021 11:03:42 +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 8E1274EF67; Wed, 4 Aug 2021 11:03:42 +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 552C71801028; Wed, 4 Aug 2021 11:03:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3CT5014321 for ; Wed, 4 Aug 2021 07:03:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id B6D545DD68; Wed, 4 Aug 2021 11:03:12 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2358C5D9DC for ; Wed, 4 Aug 2021 11:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075030; 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=ed3FBXbzOAZs3SE3GCz35oCPf2O+a3qvmW+od9lYaqM=; b=TO8KLW3i/DfSNDiy0H4fk1GDRWm5z/7wWE/ItxwtiBu0JFyvsYjV46XlCi/655h88qZxLQ C1M7z1o4SK6jRgbkhrC57d3aPIVPHRlsDn3ArOYeEy1WB3KnbjqDdTjiipNPJYx1u75bRF Pr3syxbBdItGUFVh2b3o5DRXoZgX/NU= X-MC-Unique: S-xaoPm2MguSe-JBX_N_xg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/23] qemuProcessSetupHotpluggableVcpus: Use automatic memory freeing Date: Wed, 4 Aug 2021 13:02:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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) X-ZM-MESSAGEID: 1628075033436100009 Content-Type: text/plain; charset="utf-8" 'bootHotplug' can be auto-freed when terminating the function and moving the declaration of 'vcpuprops' to the loop which uses it along with automatic freeing allows us to simplify cleanup in certain cases. Signed-off-by: Peter Krempa --- src/qemu/qemu_process.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4730d52f01..68d9de798d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5985,12 +5985,11 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *dr= iver, qemuCgroupEmulatorAllNodesData *emulatorCgroup =3D NULL; virDomainVcpuDef *vcpu; qemuDomainVcpuPrivate *vcpupriv; - virJSONValue *vcpuprops =3D NULL; size_t i; int ret =3D -1; int rc; - virDomainVcpuDef **bootHotplug =3D NULL; + g_autofree virDomainVcpuDef **bootHotplug =3D NULL; size_t nbootHotplug =3D 0; for (i =3D 0; i < maxvcpus; i++) { @@ -6005,10 +6004,8 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *dri= ver, } } - if (nbootHotplug =3D=3D 0) { - ret =3D 0; - goto cleanup; - } + if (nbootHotplug =3D=3D 0) + return 0; qsort(bootHotplug, nbootHotplug, sizeof(*bootHotplug), qemuProcessVcpusSortOrder); @@ -6017,6 +6014,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driv= er, goto cleanup; for (i =3D 0; i < nbootHotplug; i++) { + g_autoptr(virJSONValue) vcpuprops =3D NULL; vcpu =3D bootHotplug[i]; if (!(vcpuprops =3D qemuBuildHotpluggableCPUProps(vcpu))) @@ -6033,16 +6031,12 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *dr= iver, if (rc < 0) goto cleanup; - - virJSONValueFree(vcpuprops); } ret =3D 0; cleanup: qemuCgroupEmulatorAllNodesRestore(emulatorCgroup); - VIR_FREE(bootHotplug); - virJSONValueFree(vcpuprops); return ret; } --=20 2.31.1