From nobody Mon Feb 9 15:09:52 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=1613167674; cv=none; d=zohomail.com; s=zohoarc; b=RUA5ZsCXEgiaFWg8wV+nyy4ODnpjQsRwLm/UfU2t8onbAMITZRgsS25m2E4sLerzcTExJUKVepLi7ivSDt85tTDrt9aOjzUQSNcKmvkJurciMy1q8AjKROnqd114eB74Verr2SVOyBgsLfPsKxQh61bS912T/oq8wmaF8uFL/SY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167674; 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=488AuWGYgn4Uos3geA33KKzomHtTRm9E+4a7R1D/bBk=; b=j/ASGOroZcWiDc2XCp3G/N63WymGrwA9IS9ypxONJVwrPSxR4R0T9VIOb3of85HYo1228zi2xH2JjJ60Vsk2kAPFe3xZXBF6C56oaZCGQu8gLDb5QtaANva2/9YOAi45nIwXj5QDfECvuJiqKYV+A3BLimt82vfyjJ8tN2mt9Ng= 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) header.from= 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 1613167673697991.8387268563665; Fri, 12 Feb 2021 14:07:53 -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-46-d8ooiJXsO_6Ooq4UDoaMoQ-1; Fri, 12 Feb 2021 17:07:47 -0500 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 6AC7B801962; Fri, 12 Feb 2021 22:07:40 +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 4828D6F920; Fri, 12 Feb 2021 22:07:40 +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 0FEB93805; Fri, 12 Feb 2021 22:07:40 +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 11CM7LjI006127 for ; Fri, 12 Feb 2021 17:07:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id E579B1001E73; Fri, 12 Feb 2021 22:07:21 +0000 (UTC) Received: from vhost2.router.laine.org (ovpn-112-48.phx2.redhat.com [10.3.112.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8788E1002388 for ; Fri, 12 Feb 2021 22:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167669; 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=488AuWGYgn4Uos3geA33KKzomHtTRm9E+4a7R1D/bBk=; b=bEI9WhZQIiF7QxTcndA8y+nAZ9WjWuDbt0ruvmRiuIZIEvvNxieNSSrqmf3WOP/RMAU7ux WdQZNEc6ZINo46k+dv430yCUK1kbTdil3gEEe7PWyAfOtnl9m2zmMam+XIcRDjHCNGR/n7 5yMCMaVPI4EibYrqnRrljuOt7zYRdSk= X-MC-Unique: d8ooiJXsO_6Ooq4UDoaMoQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 1/9] esx: use g_autofree for char* where it is trivially possible Date: Fri, 12 Feb 2021 17:07:09 -0500 Message-Id: <20210212220717.910294-2-laine@redhat.com> In-Reply-To: <20210212220717.910294-1-laine@redhat.com> References: <20210212220717.910294-1-laine@redhat.com> 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.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" All of these strings are allocated once, freed once, and are never returned out of the function where they are created, used, and are freed. Signed-off-by: Laine Stump --- src/esx/esx_driver.c | 128 +++++++++-------------------- src/esx/esx_storage_backend_vmfs.c | 102 ++++++++--------------- src/esx/esx_stream.c | 7 +- src/esx/esx_util.c | 11 +-- src/esx/esx_vi.c | 53 ++++-------- src/esx/esx_vi_methods.c | 3 +- src/esx/esx_vi_types.c | 8 +- 7 files changed, 93 insertions(+), 219 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 0271f81a56..df257341b8 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -139,8 +139,8 @@ esxParseVMXFileName(const char *fileName, char *datastoreName; char *tmp; char *saveptr; - char *strippedFileName =3D NULL; - char *copyOfFileName =3D NULL; + g_autofree char *strippedFileName =3D NULL; + g_autofree char *copyOfFileName =3D NULL; char *directoryAndFileName; int ret =3D -1; =20 @@ -253,8 +253,6 @@ esxParseVMXFileName(const char *fileName, esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&datastoreList); esxVI_DatastoreHostMount_Free(&hostMount); - VIR_FREE(strippedFileName); - VIR_FREE(copyOfFileName); =20 return ret; } @@ -280,8 +278,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque) bool success =3D false; char *result =3D NULL; esxVMX_Data *data =3D opaque; - char *datastoreName =3D NULL; - char *directoryAndFileName =3D NULL; + g_autofree char *datastoreName =3D NULL; + g_autofree char *directoryAndFileName =3D NULL; esxVI_ObjectContent *datastore =3D NULL; esxVI_DatastoreHostMount *hostMount =3D NULL; char separator =3D '/'; @@ -349,8 +347,6 @@ esxFormatVMXFileName(const char *fileName, void *opaque) if (! success) VIR_FREE(result); =20 - VIR_FREE(datastoreName); - VIR_FREE(directoryAndFileName); esxVI_ObjectContent_Free(&datastore); esxVI_DatastoreHostMount_Free(&hostMount); =20 @@ -613,9 +609,9 @@ esxConnectToHost(esxPrivate *priv, { int result =3D -1; g_autofree char *ipAddress =3D NULL; - char *username =3D NULL; - char *password =3D NULL; - char *url =3D NULL; + g_autofree char *username =3D NULL; + g_autofree char *password =3D NULL; + g_autofree char *url =3D NULL; esxVI_String *propertyNameList =3D NULL; esxVI_ObjectContent *hostSystem =3D NULL; esxVI_Boolean inMaintenanceMode =3D esxVI_Boolean_Undefined; @@ -683,9 +679,6 @@ esxConnectToHost(esxPrivate *priv, result =3D 0; =20 cleanup: - VIR_FREE(username); - VIR_FREE(password); - VIR_FREE(url); esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&hostSystem); =20 @@ -703,9 +696,9 @@ esxConnectToVCenter(esxPrivate *priv, { int result =3D -1; g_autofree char *ipAddress =3D NULL; - char *username =3D NULL; - char *password =3D NULL; - char *url =3D NULL; + g_autofree char *username =3D NULL; + g_autofree char *password =3D NULL; + g_autofree char *url =3D NULL; =20 if (!hostSystemIPAddress && (!priv->parsedUri->path || STREQ(priv->parsedUri->path, "/"))) { @@ -761,10 +754,6 @@ esxConnectToVCenter(esxPrivate *priv, result =3D 0; =20 cleanup: - VIR_FREE(username); - VIR_FREE(password); - VIR_FREE(url); - return result; } =20 @@ -822,7 +811,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr au= th, { virDrvOpenStatus result =3D VIR_DRV_OPEN_ERROR; esxPrivate *priv =3D NULL; - char *potentialVCenterIPAddress =3D NULL; + g_autofree char *potentialVCenterIPAddress =3D NULL; g_autofree char *vCenterIPAddress =3D NULL; =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); @@ -938,8 +927,6 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr au= th, =20 cleanup: esxFreePrivate(&priv); - VIR_FREE(potentialVCenterIPAddress); - return result; } =20 @@ -1472,7 +1459,7 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsig= ned char *uuid) esxVI_ObjectContent *virtualMachine =3D NULL; esxVI_VirtualMachinePowerState powerState; int id =3D -1; - char *name =3D NULL; + g_autofree char *name =3D NULL; virDomainPtr domain =3D NULL; =20 if (esxVI_EnsureSession(priv->primary) < 0) @@ -1498,8 +1485,6 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsig= ned char *uuid) cleanup: esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachine); - VIR_FREE(name); - return domain; } =20 @@ -1559,7 +1544,7 @@ esxDomainSuspend(virDomainPtr domain) esxVI_VirtualMachinePowerState powerState; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 if (esxVI_EnsureSession(priv->primary) < 0) return -1; @@ -1599,8 +1584,6 @@ esxDomainSuspend(virDomainPtr domain) esxVI_ObjectContent_Free(&virtualMachine); esxVI_String_Free(&propertyNameList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -1616,7 +1599,7 @@ esxDomainResume(virDomainPtr domain) esxVI_VirtualMachinePowerState powerState; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 if (esxVI_EnsureSession(priv->primary) < 0) return -1; @@ -1656,8 +1639,6 @@ esxDomainResume(virDomainPtr domain) esxVI_ObjectContent_Free(&virtualMachine); esxVI_String_Free(&propertyNameList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -1767,7 +1748,7 @@ esxDomainDestroyFlags(virDomainPtr domain, esxVI_VirtualMachinePowerState powerState; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(0, -1); =20 @@ -1816,8 +1797,6 @@ esxDomainDestroyFlags(virDomainPtr domain, esxVI_ObjectContent_Free(&virtualMachine); esxVI_String_Free(&propertyNameList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -1902,7 +1881,7 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned l= ong memory) esxVI_VirtualMachineConfigSpec *spec =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 if (esxVI_EnsureSession(priv->primary) < 0) return -1; @@ -1954,8 +1933,6 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned l= ong memory) esxVI_ObjectContent_Free(&virtualMachine); esxVI_VirtualMachineConfigSpec_Free(&spec); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -1972,7 +1949,7 @@ esxDomainSetMemoryFlags(virDomainPtr domain, esxVI_VirtualMachineConfigSpec *spec =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(0, -1); =20 @@ -2013,8 +1990,6 @@ esxDomainSetMemoryFlags(virDomainPtr domain, esxVI_ObjectContent_Free(&virtualMachine); esxVI_VirtualMachineConfigSpec_Free(&spec); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -2434,7 +2409,7 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned = int nvcpus, esxVI_VirtualMachineConfigSpec *spec =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE, -1); =20 @@ -2492,8 +2467,6 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned = int nvcpus, esxVI_ObjectContent_Free(&virtualMachine); esxVI_VirtualMachineConfigSpec_Free(&spec); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -2574,14 +2547,14 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned i= nt flags) esxVI_ObjectContent *virtualMachine =3D NULL; esxVI_VirtualMachinePowerState powerState; int id; - char *moref =3D NULL; + g_autofree char *moref =3D NULL; char *vmPathName =3D NULL; - char *datastoreName =3D NULL; - char *directoryName =3D NULL; - char *directoryAndFileName =3D NULL; + g_autofree char *datastoreName =3D NULL; + g_autofree char *directoryName =3D NULL; + g_autofree char *directoryAndFileName =3D NULL; g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; - char *url =3D NULL; - char *vmx =3D NULL; + g_autofree char *url =3D NULL; + g_autofree char *vmx =3D NULL; virVMXContext ctx; esxVMX_Data data; virDomainDefPtr def =3D NULL; @@ -2655,13 +2628,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) cleanup: esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachine); - VIR_FREE(moref); - VIR_FREE(datastoreName); - VIR_FREE(directoryName); - VIR_FREE(directoryAndFileName); - VIR_FREE(url); VIR_FREE(data.datastorePathWithoutFileName); - VIR_FREE(vmx); virDomainDefFree(def); =20 return xml; @@ -2858,7 +2825,7 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigne= d int flags) int id =3D -1; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(0, -1); =20 @@ -2903,7 +2870,6 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigne= d int flags) esxVI_ObjectContent_Free(&virtualMachine); esxVI_String_Free(&propertyNameList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); =20 return result; } @@ -2923,25 +2889,25 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int flags) { esxPrivate *priv =3D conn->privateData; virDomainDefPtr def =3D NULL; - char *vmx =3D NULL; + g_autofree char *vmx =3D NULL; size_t i; virDomainDiskDefPtr disk =3D NULL; esxVI_ObjectContent *virtualMachine =3D NULL; int virtualHW_version; virVMXContext ctx; esxVMX_Data data; - char *datastoreName =3D NULL; - char *directoryName =3D NULL; - char *escapedName =3D NULL; + g_autofree char *datastoreName =3D NULL; + g_autofree char *directoryName =3D NULL; + g_autofree char *escapedName =3D NULL; g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; - char *url =3D NULL; + g_autofree char *url =3D NULL; char *datastoreRelatedPath =3D NULL; esxVI_String *propertyNameList =3D NULL; esxVI_ObjectContent *hostSystem =3D NULL; esxVI_ManagedObjectReference *resourcePool =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; virDomainPtr domain =3D NULL; const char *src; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; @@ -3122,19 +3088,11 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int flags) =20 cleanup: virDomainDefFree(def); - VIR_FREE(vmx); - VIR_FREE(datastoreName); - VIR_FREE(directoryName); - VIR_FREE(escapedName); - VIR_FREE(url); - VIR_FREE(datastoreRelatedPath); esxVI_ObjectContent_Free(&virtualMachine); esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&hostSystem); esxVI_ManagedObjectReference_Free(&resourcePool); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return domain; } =20 @@ -3554,7 +3512,7 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr dom= ain, esxVI_SharesInfo *sharesInfo =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; size_t i; =20 virCheckFlags(0, -1); @@ -3670,8 +3628,6 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr dom= ain, esxVI_ObjectContent_Free(&virtualMachine); esxVI_VirtualMachineConfigSpec_Free(&spec); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -3735,7 +3691,7 @@ esxDomainMigratePerform(virDomainPtr domain, esxVI_Event *eventList =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(ESX_MIGRATION_FLAGS, -1); =20 @@ -3850,8 +3806,6 @@ esxDomainMigratePerform(virDomainPtr domain, esxVI_ObjectContent_Free(&virtualMachine); esxVI_Event_Free(&eventList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -4049,7 +4003,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, esxVI_VirtualMachineSnapshotTree *snapshotTree =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; bool diskOnly =3D (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) !=3D = 0; bool quiesce =3D (flags & VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE) !=3D 0; @@ -4122,8 +4076,6 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, esxVI_ObjectContent_Free(&virtualMachine); esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return snapshot; } =20 @@ -4563,7 +4515,7 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapsh= ot, unsigned int flags) esxVI_VirtualMachineSnapshotTree *snapshotTree =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(0, -1); =20 @@ -4599,8 +4551,6 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapsh= ot, unsigned int flags) cleanup: esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -4616,7 +4566,7 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot= , unsigned int flags) esxVI_Boolean removeChildren =3D esxVI_Boolean_False; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1); @@ -4663,8 +4613,6 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot= , unsigned int flags) cleanup: esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotList); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -4680,7 +4628,7 @@ esxDomainSetMemoryParameters(virDomainPtr domain, vir= TypedParameterPtr params, esxVI_VirtualMachineConfigSpec *spec =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; size_t i; =20 virCheckFlags(0, -1); @@ -4733,8 +4681,6 @@ esxDomainSetMemoryParameters(virDomainPtr domain, vir= TypedParameterPtr params, esxVI_ObjectContent_Free(&virtualMachine); esxVI_VirtualMachineConfigSpec_Free(&spec); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 27d8016194..9466ec81cb 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -672,8 +672,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, { virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D pool->conn->privateData; - char *datastorePath =3D NULL; - char *key =3D NULL; + g_autofree char *datastorePath =3D NULL; + g_autofree char *key =3D NULL; =20 datastorePath =3D g_strdup_printf("[%s] %s", pool->name, name); =20 @@ -686,9 +686,6 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, &esxStorageBackendVMFS, NULL); =20 cleanup: - VIR_FREE(datastorePath); - VIR_FREE(key); - return volume; } =20 @@ -699,9 +696,9 @@ esxStorageVolLookupByPath(virConnectPtr conn, const cha= r *path) { virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D conn->privateData; - char *datastoreName =3D NULL; - char *directoryAndFileName =3D NULL; - char *key =3D NULL; + g_autofree char *datastoreName =3D NULL; + g_autofree char *directoryAndFileName =3D NULL; + g_autofree char *key =3D NULL; =20 if (esxUtil_ParseDatastorePath(path, &datastoreName, NULL, &directoryAndFileName) < 0) { @@ -717,10 +714,6 @@ esxStorageVolLookupByPath(virConnectPtr conn, const ch= ar *path) &esxStorageBackendVMFS, NULL); =20 cleanup: - VIR_FREE(datastoreName); - VIR_FREE(directoryAndFileName); - VIR_FREE(key); - return volume; } =20 @@ -864,20 +857,20 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, esxPrivate *priv =3D pool->conn->privateData; virStoragePoolDef poolDef; char *tmp; - char *unescapedDatastorePath =3D NULL; - char *unescapedDirectoryName =3D NULL; - char *unescapedDirectoryAndFileName =3D NULL; - char *directoryName =3D NULL; - char *fileName =3D NULL; - char *datastorePathWithoutFileName =3D NULL; - char *datastorePath =3D NULL; + g_autofree char *unescapedDatastorePath =3D NULL; + g_autofree char *unescapedDirectoryName =3D NULL; + g_autofree char *unescapedDirectoryAndFileName =3D NULL; + g_autofree char *directoryName =3D NULL; + g_autofree char *fileName =3D NULL; + g_autofree char *datastorePathWithoutFileName =3D NULL; + g_autofree char *datastorePath =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; esxVI_FileBackedVirtualDiskSpec *virtualDiskSpec =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; - char *uuid_string =3D NULL; - char *key =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; + g_autofree char *uuid_string =3D NULL; + g_autofree char *key =3D NULL; g_autoptr(virStorageVolDef) def =3D NULL; =20 virCheckFlags(0, NULL); @@ -1045,20 +1038,9 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, virtualDiskSpec->adapterType =3D NULL; } =20 - VIR_FREE(unescapedDatastorePath); - VIR_FREE(unescapedDirectoryName); - VIR_FREE(unescapedDirectoryAndFileName); - VIR_FREE(directoryName); - VIR_FREE(fileName); - VIR_FREE(datastorePathWithoutFileName); - VIR_FREE(datastorePath); esxVI_FileInfo_Free(&fileInfo); esxVI_FileBackedVirtualDiskSpec_Free(&virtualDiskSpec); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - VIR_FREE(uuid_string); - VIR_FREE(key); - return volume; } =20 @@ -1073,21 +1055,21 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D pool->conn->privateData; virStoragePoolDef poolDef; - char *sourceDatastorePath =3D NULL; + g_autofree char *sourceDatastorePath =3D NULL; char *tmp; - char *unescapedDatastorePath =3D NULL; - char *unescapedDirectoryName =3D NULL; - char *unescapedDirectoryAndFileName =3D NULL; - char *directoryName =3D NULL; - char *fileName =3D NULL; - char *datastorePathWithoutFileName =3D NULL; - char *datastorePath =3D NULL; + g_autofree char *unescapedDatastorePath =3D NULL; + g_autofree char *unescapedDirectoryName =3D NULL; + g_autofree char *unescapedDirectoryAndFileName =3D NULL; + g_autofree char *directoryName =3D NULL; + g_autofree char *fileName =3D NULL; + g_autofree char *datastorePathWithoutFileName =3D NULL; + g_autofree char *datastorePath =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; - char *uuid_string =3D NULL; - char *key =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; + g_autofree char *uuid_string =3D NULL; + g_autofree char *key =3D NULL; g_autoptr(virStorageVolDef) def =3D NULL; =20 virCheckFlags(0, NULL); @@ -1219,20 +1201,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, &esxStorageBackendVMFS, NULL); =20 cleanup: - VIR_FREE(sourceDatastorePath); - VIR_FREE(unescapedDatastorePath); - VIR_FREE(unescapedDirectoryName); - VIR_FREE(unescapedDirectoryAndFileName); - VIR_FREE(directoryName); - VIR_FREE(fileName); - VIR_FREE(datastorePathWithoutFileName); - VIR_FREE(datastorePath); esxVI_FileInfo_Free(&fileInfo); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - VIR_FREE(uuid_string); - VIR_FREE(key); - return volume; } =20 @@ -1243,10 +1213,10 @@ esxStorageVolDelete(virStorageVolPtr volume, unsign= ed int flags) { int result =3D -1; esxPrivate *priv =3D volume->conn->privateData; - char *datastorePath =3D NULL; + g_autofree char *datastorePath =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(0, -1); =20 @@ -1271,10 +1241,7 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigne= d int flags) result =3D 0; =20 cleanup: - VIR_FREE(datastorePath); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -1285,10 +1252,10 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned= int flags) { int result =3D -1; esxPrivate *priv =3D volume->conn->privateData; - char *datastorePath =3D NULL; + g_autofree char *datastorePath =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; =20 virCheckFlags(0, -1); =20 @@ -1313,10 +1280,7 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned = int flags) result =3D 0; =20 cleanup: - VIR_FREE(datastorePath); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); - return result; } =20 @@ -1328,7 +1292,7 @@ esxStorageVolGetInfo(virStorageVolPtr volume, { int result =3D -1; esxPrivate *priv =3D volume->conn->privateData; - char *datastorePath =3D NULL; + g_autofree char *datastorePath =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; esxVI_VmDiskFileInfo *vmDiskFileInfo =3D NULL; =20 @@ -1358,7 +1322,6 @@ esxStorageVolGetInfo(virStorageVolPtr volume, result =3D 0; =20 cleanup: - VIR_FREE(datastorePath); esxVI_FileInfo_Free(&fileInfo); =20 return result; @@ -1372,7 +1335,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, { esxPrivate *priv =3D volume->conn->privateData; virStoragePoolDef pool; - char *datastorePath =3D NULL; + g_autofree char *datastorePath =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; esxVI_VmDiskFileInfo *vmDiskFileInfo =3D NULL; esxVI_IsoImageFileInfo *isoImageFileInfo =3D NULL; @@ -1438,7 +1401,6 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, xml =3D virStorageVolDefFormat(&pool, &def); =20 cleanup: - VIR_FREE(datastorePath); esxVI_FileInfo_Free(&fileInfo); VIR_FREE(def.key); =20 diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c index 2e7f979e79..cc48c182d9 100644 --- a/src/esx/esx_stream.c +++ b/src/esx/esx_stream.c @@ -395,8 +395,8 @@ esxStreamOpen(virStreamPtr stream, esxPrivate *priv, co= nst char *url, { int result =3D -1; esxStreamPrivate *streamPriv; - char *range =3D NULL; - char *userpwd =3D NULL; + g_autofree char *range =3D NULL; + g_autofree char *userpwd =3D NULL; esxVI_MultiCURL *multi =3D NULL; =20 /* FIXME: Although there is already some code in place to deal with @@ -467,9 +467,6 @@ esxStreamOpen(virStreamPtr stream, esxPrivate *priv, co= nst char *url, esxFreeStreamPrivate(&streamPriv); } =20 - VIR_FREE(range); - VIR_FREE(userpwd); - return result; } =20 diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index d9e7641d67..64a2c968f0 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -207,7 +207,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, char **directoryName, char **directoryAndFileNa= me) { int result =3D -1; - char *copyOfDatastorePath =3D NULL; + g_autofree char *copyOfDatastorePath =3D NULL; char *tmp =3D NULL; char *saveptr =3D NULL; char *preliminaryDatastoreName =3D NULL; @@ -270,8 +270,6 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, VIR_FREE(*directoryAndFileName); } =20 - VIR_FREE(copyOfDatastorePath); - return result; } =20 @@ -429,8 +427,8 @@ esxUtil_ReplaceSpecialWindowsPathChars(char *string) char * esxUtil_EscapeDatastoreItem(const char *string) { - char *replaced; - char *escaped1; + g_autofree char *replaced =3D NULL; + g_autofree char *escaped1 =3D NULL; char *escaped2 =3D NULL; =20 replaced =3D g_strdup(string); @@ -445,9 +443,6 @@ esxUtil_EscapeDatastoreItem(const char *string) escaped2 =3D esxUtil_EscapeBase64(escaped1); =20 cleanup: - VIR_FREE(replaced); - VIR_FREE(escaped1); - return escaped2; } =20 diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 2eb8048858..7ff43adaaf 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -169,7 +169,7 @@ static int esxVI_CURL_Debug(CURL *curl G_GNUC_UNUSED, curl_infotype type, char *info, size_t size, void *userdata G_GNUC_UNUSED) { - char *buffer =3D NULL; + g_autofree char *buffer =3D NULL; =20 /* * The libcurl documentation says: @@ -221,8 +221,6 @@ esxVI_CURL_Debug(CURL *curl G_GNUC_UNUSED, curl_infotyp= e type, break; } =20 - VIR_FREE(buffer); - return 0; } #endif @@ -833,7 +831,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, const char *password, esxUtil_ParsedUri *parsedUri) { int result =3D -1; - char *escapedPassword =3D NULL; + g_autofree char *escapedPassword =3D NULL; =20 if (!ctx || !url || !ipAddress || !username || !password || ctx->url || ctx->service || ctx->curl) { @@ -965,8 +963,6 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, result =3D 0; =20 cleanup: - VIR_FREE(escapedPassword); - return result; } =20 @@ -1013,7 +1009,7 @@ int esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *p= ath) { int result =3D -1; - char *tmp =3D NULL; + g_autofree char *tmp =3D NULL; char *saveptr =3D NULL; char *previousItem =3D NULL; char *item =3D NULL; @@ -1181,7 +1177,6 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Contex= t *ctx, const char *path) esxVI_ManagedObjectReference_Free(&root); } =20 - VIR_FREE(tmp); esxVI_Folder_Free(&folder); =20 return result; @@ -1239,7 +1234,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, int result =3D -1; g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; esxVI_Fault *fault =3D NULL; - char *xpathExpression =3D NULL; + g_autofree char *xpathExpression =3D NULL; xmlXPathContextPtr xpathContext =3D NULL; xmlNodePtr responseNode =3D NULL; =20 @@ -1401,7 +1396,6 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, esxVI_Fault_Free(&fault); } =20 - VIR_FREE(xpathExpression); xmlXPathFreeContext(xpathContext); =20 return result; @@ -1509,7 +1503,7 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration= *enumeration, { size_t i; int result =3D -1; - char *name =3D NULL; + g_autofree char *name =3D NULL; =20 if (!value) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); @@ -1534,8 +1528,6 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration= *enumeration, name, esxVI_Type_ToString(enumeration->type)); } =20 - VIR_FREE(name); - return result; } =20 @@ -1895,7 +1887,7 @@ esxVI_EnsureSession(esxVI_Context *ctx) esxVI_ObjectContent *sessionManager =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; esxVI_UserSession *currentSession =3D NULL; - char *escapedPassword =3D NULL; + g_autofree char *escapedPassword =3D NULL; =20 if (!ctx->sessionLock) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call, no m= utex")); @@ -1959,7 +1951,6 @@ esxVI_EnsureSession(esxVI_Context *ctx) cleanup: virMutexUnlock(ctx->sessionLock); =20 - VIR_FREE(escapedPassword); esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&sessionManager); esxVI_UserSession_Free(¤tSession); @@ -3378,12 +3369,12 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *= ctx, esxVI_Occurrence occurrence) { int result =3D -1; - char *datastoreName =3D NULL; - char *directoryName =3D NULL; - char *directoryAndFileName =3D NULL; - char *fileName =3D NULL; + g_autofree char *datastoreName =3D NULL; + g_autofree char *directoryName =3D NULL; + g_autofree char *directoryAndFileName =3D NULL; + g_autofree char *fileName =3D NULL; size_t length; - char *datastorePathWithoutFileName =3D NULL; + g_autofree char *datastorePathWithoutFileName =3D NULL; esxVI_String *propertyNameList =3D NULL; esxVI_ObjectContent *datastore =3D NULL; esxVI_ManagedObjectReference *hostDatastoreBrowser =3D NULL; @@ -3394,7 +3385,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ct= x, esxVI_FloppyImageFileQuery *floppyImageFileQuery =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; esxVI_TaskInfo *taskInfo =3D NULL; esxVI_HostDatastoreBrowserSearchResults *searchResults =3D NULL; =20 @@ -3544,17 +3535,11 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *= ctx, if (searchSpec && searchSpec->matchPattern) searchSpec->matchPattern->value =3D NULL; =20 - VIR_FREE(datastoreName); - VIR_FREE(directoryName); - VIR_FREE(directoryAndFileName); - VIR_FREE(fileName); - VIR_FREE(datastorePathWithoutFileName); esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&datastore); esxVI_ManagedObjectReference_Free(&hostDatastoreBrowser); esxVI_HostDatastoreBrowserSearchSpec_Free(&searchSpec); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); esxVI_TaskInfo_Free(&taskInfo); esxVI_HostDatastoreBrowserSearchResults_Free(&searchResults); esxVI_FolderFileQuery_Free(&folderFileQuery); @@ -3580,10 +3565,10 @@ esxVI_LookupDatastoreContentByDatastoreName esxVI_VmDiskFileQuery *vmDiskFileQuery =3D NULL; esxVI_IsoImageFileQuery *isoImageFileQuery =3D NULL; esxVI_FloppyImageFileQuery *floppyImageFileQuery =3D NULL; - char *datastorePath =3D NULL; + g_autofree char *datastorePath =3D NULL; esxVI_ManagedObjectReference *task =3D NULL; esxVI_TaskInfoState taskInfoState; - char *taskInfoErrorMessage =3D NULL; + g_autofree char *taskInfoErrorMessage =3D NULL; esxVI_TaskInfo *taskInfo =3D NULL; =20 ESX_VI_CHECK_ARG_LIST(searchResultsList); @@ -3672,9 +3657,7 @@ esxVI_LookupDatastoreContentByDatastoreName esxVI_ObjectContent_Free(&datastore); esxVI_ManagedObjectReference_Free(&hostDatastoreBrowser); esxVI_HostDatastoreBrowserSearchSpec_Free(&searchSpec); - VIR_FREE(datastorePath); esxVI_ManagedObjectReference_Free(&task); - VIR_FREE(taskInfoErrorMessage); esxVI_TaskInfo_Free(&taskInfo); esxVI_VmDiskFileQuery_Free(&vmDiskFileQuery); esxVI_IsoImageFileQuery_Free(&isoImageFileQuery); @@ -3692,7 +3675,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Con= text *ctx, { int result =3D -1; esxVI_FileInfo *fileInfo =3D NULL; - char *uuid_string =3D NULL; + g_autofree char *uuid_string =3D NULL; =20 ESX_VI_CHECK_ARG_LIST(key); =20 @@ -3727,8 +3710,6 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Con= text *ctx, =20 cleanup: esxVI_FileInfo_Free(&fileInfo); - VIR_FREE(uuid_string); - return result; } =20 @@ -4120,7 +4101,7 @@ esxVI_HandleVirtualMachineQuestion g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; esxVI_ElementDescription *answerChoice =3D NULL; int answerIndex =3D 0; - char *possibleAnswers =3D NULL; + g_autofree char *possibleAnswers =3D NULL; =20 if (!blocked) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); @@ -4199,8 +4180,6 @@ esxVI_HandleVirtualMachineQuestion result =3D 0; =20 cleanup: - VIR_FREE(possibleAnswers); - return result; } =20 diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c index e22a078997..87046b6225 100644 --- a/src/esx/esx_vi_methods.c +++ b/src/esx/esx_vi_methods.c @@ -106,7 +106,7 @@ int result =3D -1; \ const char *methodName =3D #_name; \ g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; \ - char *request =3D NULL; \ + g_autofree char *request =3D NULL; \ esxVI_Response *response =3D NULL; \ \ ESX_VI__METHOD__PARAMETER__THIS__##_this_from_service \ @@ -136,7 +136,6 @@ result =3D 0; \ \ cleanup: \ - VIR_FREE(request); \ esxVI_Response_Free(&response); \ \ return result; \ diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 4d3617e0a8..1af075813e 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -330,7 +330,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); esxVI_##_type##_Deserialize(xmlNodePtr node, esxVI_##_type **number) \ { \ int result =3D -1; \ - char *string; \ + g_autofree char *string =3D NULL; \ long long value; \ \ if (!number || *number) { \ @@ -374,8 +374,6 @@ VIR_LOG_INIT("esx.esx_vi_types"); if (result < 0) { \ esxVI_##_type##_Free(number); \ } \ - \ - VIR_FREE(string); \ \ return result; \ } @@ -703,7 +701,7 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type b= aseType, esxVI_Type *actualType) { int result =3D -1; - char *type =3D NULL; + g_autofree char *type =3D NULL; =20 if (!actualType || *actualType !=3D esxVI_Type_Undefined) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); @@ -732,8 +730,6 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type b= aseType, result =3D 0; =20 cleanup: - VIR_FREE(type); - return result; } =20 --=20 2.29.2