From nobody Tue Feb 10 12:45:19 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=1612411116; cv=none; d=zohomail.com; s=zohoarc; b=BbfPbH5rz3/7czS+L4VnSckAGHeiIRz11OyvT7g7xd/SZYq4JpU1i0D6ro3OJ1r0U02zYXokoChsT0n+EOZvlN6xdk2J+Ns9McUzlmeRlRE1BqEtsex430OIFRvH7EXtIo8wVkUcSrkYXH/Y8qge3Kmv8CqrI4Fa/saqUaw1QFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612411116; 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=mRrQ+DBBc0q8CFb+yfGzoQSDbsZNkUDEXHQZci6tdlg=; b=HHsDALxoSzD3zl9HRxD/P+ekOYrtUsFJNWGCAxyxEP9jDgtOyNuzy4T3402veJ4MIWZI7iTVbo/2dgOclKbA9/UQ46rwsPeX9GyRxSqqGgVJtkX64RG8gMRwtTJ6HQQDya+w41rvcreOFJSPcs2y3/FS9fuKulsEEbIlmotT7Ig= 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 1612411116879631.0125762249003; Wed, 3 Feb 2021 19:58:36 -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-116-7LzKbPBHMwaVVPj5tpU8Fw-1; Wed, 03 Feb 2021 22:58:33 -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 65086E75F; Thu, 4 Feb 2021 03:58:27 +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 441435D9C9; Thu, 4 Feb 2021 03:58:27 +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 110FE18089D1; Thu, 4 Feb 2021 03:58:27 +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 1143wGA5003586 for ; Wed, 3 Feb 2021 22:58:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7C4B85B697; Thu, 4 Feb 2021 03:58:16 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-199.phx2.redhat.com [10.3.112.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 463525B698 for ; Thu, 4 Feb 2021 03:58:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612411115; 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=mRrQ+DBBc0q8CFb+yfGzoQSDbsZNkUDEXHQZci6tdlg=; b=cJ80LER70BYaM5j7DuWXWo9Rv5rTOf8ltpmCm+DEWj3A2OpllBOSEXCs8ah68hCURjJQuk Mg/GUNdWEE6ehNbVMW4XbahP1LuwKy0sYtmw4A8LdoQpUJOmH2m0/8DIE6gWugUtM7dHjZ 2CxrW0/zXOlriS621K6xCM99iK80rjs= X-MC-Unique: 7LzKbPBHMwaVVPj5tpU8Fw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH v2 22/24] qemu: pass pointers instead of copying objects for qemuFirmware*FreeContent() Date: Wed, 3 Feb 2021 22:57:49 -0500 Message-Id: <20210204035751.164765-23-laine@redhat.com> In-Reply-To: <20210204035751.164765-1-laine@redhat.com> References: <20210204035751.164765-1-laine@redhat.com> 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" These functions all cooperate to free memory pointed to by a single object that contains (doesn't *point to*, but acutally contains) several sub-objects. They were written to send copies of these sub-objects to subordinate functions, rather than just sending pointers to the sub-objects. Let's change these functions to just send pointers to the objects they're cleaning out rather than all the wasteful and pointless copying. Signed-off-by: Laine Stump --- src/qemu/qemu_firmware.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index c22b1f1e9c..aad39ee038 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -188,47 +188,47 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuFirmwareOSInterface= , qemuFirmwareOSInterfaceFr =20 =20 static void -qemuFirmwareFlashFileFreeContent(qemuFirmwareFlashFile flash) +qemuFirmwareFlashFileFreeContent(qemuFirmwareFlashFilePtr flash) { - VIR_FREE(flash.filename); - VIR_FREE(flash.format); + VIR_FREE(flash->filename); + VIR_FREE(flash->format); } =20 =20 static void -qemuFirmwareMappingFlashFreeContent(qemuFirmwareMappingFlash flash) +qemuFirmwareMappingFlashFreeContent(qemuFirmwareMappingFlashPtr flash) { - qemuFirmwareFlashFileFreeContent(flash.executable); - qemuFirmwareFlashFileFreeContent(flash.nvram_template); + qemuFirmwareFlashFileFreeContent(&flash->executable); + qemuFirmwareFlashFileFreeContent(&flash->nvram_template); } =20 =20 static void -qemuFirmwareMappingKernelFreeContent(qemuFirmwareMappingKernel kernel) +qemuFirmwareMappingKernelFreeContent(qemuFirmwareMappingKernelPtr kernel) { - VIR_FREE(kernel.filename); + VIR_FREE(kernel->filename); } =20 =20 static void -qemuFirmwareMappingMemoryFreeContent(qemuFirmwareMappingMemory memory) +qemuFirmwareMappingMemoryFreeContent(qemuFirmwareMappingMemoryPtr memory) { - VIR_FREE(memory.filename); + VIR_FREE(memory->filename); } =20 =20 static void -qemuFirmwareMappingFreeContent(qemuFirmwareMapping mapping) +qemuFirmwareMappingFreeContent(qemuFirmwareMappingPtr mapping) { - switch (mapping.device) { + switch (mapping->device) { case QEMU_FIRMWARE_DEVICE_FLASH: - qemuFirmwareMappingFlashFreeContent(mapping.data.flash); + qemuFirmwareMappingFlashFreeContent(&mapping->data.flash); break; case QEMU_FIRMWARE_DEVICE_KERNEL: - qemuFirmwareMappingKernelFreeContent(mapping.data.kernel); + qemuFirmwareMappingKernelFreeContent(&mapping->data.kernel); break; case QEMU_FIRMWARE_DEVICE_MEMORY: - qemuFirmwareMappingMemoryFreeContent(mapping.data.memory); + qemuFirmwareMappingMemoryFreeContent(&mapping->data.memory); break; case QEMU_FIRMWARE_DEVICE_NONE: case QEMU_FIRMWARE_DEVICE_LAST: @@ -271,7 +271,7 @@ qemuFirmwareFree(qemuFirmwarePtr fw) return; =20 qemuFirmwareOSInterfaceFree(fw->interfaces); - qemuFirmwareMappingFreeContent(fw->mapping); + qemuFirmwareMappingFreeContent(&fw->mapping); for (i =3D 0; i < fw->ntargets; i++) qemuFirmwareTargetFree(fw->targets[i]); g_free(fw->targets); --=20 2.29.2