From nobody Sun May 5 05:48:51 2024 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 Reviewed-by: Michal Privoznik --- 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 From nobody Sun May 5 05:48:51 2024 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=1613167663; cv=none; d=zohomail.com; s=zohoarc; b=TTVeoM+JLqw5/cTHOMBHqCcRpkRuLru4QQXTuqjs81WhD/CnNHtYVuKYgY+kkWipPErS+dsYks9wv70WiFrMBDjaqkQUXAkdkqewjcPeX3RmOhM1uJdImTJITXHC8DX5hXW2+jCUMHqZFXQj9cNxbErT0TQfSyoDEECwlP9V9NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167663; 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=Jq96KHr4rVhRu1T9+W8xmQMKdjMoEntKJyJFku7UIyk=; b=Bkys3L3c185ngms2STTSdzy2Qzt5oCR5huaN/CwyX/pbc0370uZz7wTEAz/hj4hs+RzYt1bENKzuw+H005rMZO+lekopmb4fXXq5uVZYBmqIAf32ic+gdV38g8uTOprUaljLz9QZa31o5yaD1sa+Zo7rH0zSRuvIM+0yxWP6rHM= 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) header.from= 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 1613167662819237.69095117312088; Fri, 12 Feb 2021 14:07:42 -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-477-uar5-RTWNy-129l43AS4Cw-1; Fri, 12 Feb 2021 17:07:35 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F79A106BC69; Fri, 12 Feb 2021 22:07:29 +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 1D74B5C3FD; Fri, 12 Feb 2021 22:07:28 +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 A6C6918095CB; Fri, 12 Feb 2021 22:07:24 +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 11CM7MCm006132 for ; Fri, 12 Feb 2021 17:07:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 500F11002388; Fri, 12 Feb 2021 22:07:22 +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 1601A1001E73 for ; Fri, 12 Feb 2021 22:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167657; 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=Jq96KHr4rVhRu1T9+W8xmQMKdjMoEntKJyJFku7UIyk=; b=hKdlZ5X4kcpW3JPkDYe/GFemsZpSrbupw9gLYKJjtSMV1q1iVGUl/T9EzX83uGDK5tR1XW TO3wz84wgOhgiIbch3kzYsicl0i6/Zwon/yCrgbO2ZOZ4hM97WotQywYp/vl2+2m+Qfn5M ulBNwttUNWCb+3WvXrMoYwlqRldvoqE= X-MC-Unique: uar5-RTWNy-129l43AS4Cw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 2/9] esx: use g_autofree when made possible by reducing scope Date: Fri, 12 Feb 2021 17:07:10 -0500 Message-Id: <20210212220717.910294-3-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.16 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 strings were being VIR_FREEd multiple times because they were defined at the top of a function, but then set each time through a loop. But they are only used inside that loop, so they can be converted to use g_autofree if their definition is also placed inside that loop. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_driver.c | 13 ++++--------- src/esx/esx_storage_backend_iscsi.c | 12 ++++-------- src/esx/esx_storage_backend_vmfs.c | 18 ++++-------------- src/esx/esx_vi.c | 5 +---- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index df257341b8..8afec464dd 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1391,7 +1391,6 @@ esxDomainLookupByID(virConnectPtr conn, int id) esxVI_ObjectContent *virtualMachine =3D NULL; esxVI_VirtualMachinePowerState powerState; int id_candidate =3D -1; - char *name_candidate =3D NULL; unsigned char uuid_candidate[VIR_UUID_BUFLEN]; virDomainPtr domain =3D NULL; =20 @@ -1410,6 +1409,8 @@ esxDomainLookupByID(virConnectPtr conn, int id) =20 for (virtualMachine =3D virtualMachineList; virtualMachine; virtualMachine =3D virtualMachine->_next) { + g_autofree char *name_candidate =3D NULL; + if (esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { goto cleanup; @@ -1419,8 +1420,6 @@ esxDomainLookupByID(virConnectPtr conn, int id) if (powerState =3D=3D esxVI_VirtualMachinePowerState_PoweredOff) continue; =20 - VIR_FREE(name_candidate); - if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id_candidate, &name_candidate, uuid_candidate) < 0) { @@ -1444,8 +1443,6 @@ esxDomainLookupByID(virConnectPtr conn, int id) cleanup: esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachineList); - VIR_FREE(name_candidate); - return domain; } =20 @@ -4754,7 +4751,6 @@ esxConnectListAllDomains(virConnectPtr conn, esxVI_AutoStartPowerInfo *powerInfoList =3D NULL; esxVI_AutoStartPowerInfo *powerInfo =3D NULL; esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList =3D NULL; - char *name =3D NULL; int id; unsigned char uuid[VIR_UUID_BUFLEN]; int count =3D 0; @@ -4839,9 +4835,9 @@ esxConnectListAllDomains(virConnectPtr conn, =20 for (virtualMachine =3D virtualMachineList; virtualMachine; virtualMachine =3D virtualMachine->_next) { - if (needIdentity) { - VIR_FREE(name); + g_autofree char *name =3D NULL; =20 + if (needIdentity) { if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id, &name, uuid) < 0) { goto cleanup; @@ -4959,7 +4955,6 @@ esxConnectListAllDomains(virConnectPtr conn, VIR_FREE(doms); } =20 - VIR_FREE(name); esxVI_AutoStartDefaults_Free(&autoStartDefaults); esxVI_AutoStartPowerInfo_Free(&powerInfoList); esxVI_String_Free(&propertyNameList); diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index 4d16ba2520..41bb9f6094 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -494,7 +494,6 @@ esxStorageVolLookupByPath(virConnectPtr conn, const cha= r *path) esxVI_ScsiLun *scsiLunList =3D NULL; esxVI_ScsiLun *scsiLun; esxVI_HostScsiDisk *hostScsiDisk =3D NULL; - char *poolName =3D NULL; /* VIR_CRYPTO_HASH_SIZE_MD5 =3D VIR_UUID_BUFLEN =3D 16 */ unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5]; char uuid_string[VIR_UUID_STRING_BUFLEN] =3D ""; @@ -503,11 +502,12 @@ esxStorageVolLookupByPath(virConnectPtr conn, const c= har *path) goto cleanup; =20 for (scsiLun =3D scsiLunList; scsiLun; scsiLun =3D scsiLun->_next) { + g_autofree char *poolName =3D NULL; + hostScsiDisk =3D esxVI_HostScsiDisk_DynamicCast(scsiLun); =20 if (hostScsiDisk && STREQ(hostScsiDisk->devicePath, path)) { /* Found matching device */ - VIR_FREE(poolName); =20 if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary, hostScsiDisk->key, @@ -527,8 +527,6 @@ esxStorageVolLookupByPath(virConnectPtr conn, const cha= r *path) =20 cleanup: esxVI_ScsiLun_Free(&scsiLunList); - VIR_FREE(poolName); - return volume; } =20 @@ -539,7 +537,6 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) { virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D conn->privateData; - char *poolName =3D NULL; esxVI_ScsiLun *scsiLunList =3D NULL; esxVI_ScsiLun *scsiLun; /* VIR_CRYPTO_HASH_SIZE_MD5 =3D VIR_UUID_BUFLEN =3D 16 */ @@ -555,6 +552,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) =20 for (scsiLun =3D scsiLunList; scsiLun; scsiLun =3D scsiLun->_next) { + g_autofree char *poolName =3D NULL; + memset(uuid_string, '\0', sizeof(uuid_string)); memset(md5, '\0', sizeof(md5)); =20 @@ -564,7 +563,6 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) =20 if (STREQ(key, uuid_string)) { /* Found matching UUID */ - VIR_FREE(poolName); =20 if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary, scsiLun->key, @@ -581,8 +579,6 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) =20 cleanup: esxVI_ScsiLun_Free(&scsiLunList); - VIR_FREE(poolName); - return volume; } =20 diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 9466ec81cb..63959ec237 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -598,7 +598,6 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char = **const names, esxVI_HostDatastoreBrowserSearchResults *searchResultsList =3D NULL; esxVI_HostDatastoreBrowserSearchResults *searchResults =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; - char *directoryAndFileName =3D NULL; size_t length; int count =3D 0; size_t i; @@ -619,7 +618,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char = **const names, /* Interpret search result */ for (searchResults =3D searchResultsList; searchResults; searchResults =3D searchResults->_next) { - VIR_FREE(directoryAndFileName); + g_autofree char *directoryAndFileName =3D NULL; =20 if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, NU= LL, &directoryAndFileName) < 0) { @@ -659,8 +658,6 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char = **const names, } =20 esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList); - VIR_FREE(directoryAndFileName); - return count; } =20 @@ -730,12 +727,9 @@ esxStorageVolLookupByKey(virConnectPtr conn, const cha= r *key) char *datastoreName =3D NULL; esxVI_HostDatastoreBrowserSearchResults *searchResultsList =3D NULL; esxVI_HostDatastoreBrowserSearchResults *searchResults =3D NULL; - char *directoryAndFileName =3D NULL; size_t length; - char *datastorePath =3D NULL; char *volumeName =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; - char *uuid_string =3D NULL; char key_candidate[VIR_UUID_STRING_BUFLEN] =3D ""; =20 if (STRPREFIX(key, "[")) { @@ -777,7 +771,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) /* Interpret search result */ for (searchResults =3D searchResultsList; searchResults; searchResults =3D searchResults->_next) { - VIR_FREE(directoryAndFileName); + g_autofree char *directoryAndFileName =3D NULL; =20 if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, NULL, &directoryAndFileName) < = 0) { @@ -795,7 +789,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) /* Build datastore path and query the UUID */ for (fileInfo =3D searchResults->file; fileInfo; fileInfo =3D fileInfo->_next) { - VIR_FREE(datastorePath); + g_autofree char *datastorePath =3D NULL; + g_autofree char *uuid_string =3D NULL; =20 if (length < 1) { volumeName =3D g_strdup(fileInfo->path); @@ -811,8 +806,6 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) continue; } =20 - VIR_FREE(uuid_string); - if (esxVI_QueryVirtualDiskUuid (priv->primary, datastorePath, priv->primary->datacenter->_reference, @@ -838,10 +831,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const cha= r *key) esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&datastoreList); esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList); - VIR_FREE(directoryAndFileName); - VIR_FREE(datastorePath); VIR_FREE(volumeName); - VIR_FREE(uuid_string); =20 return volume; } diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 7ff43adaaf..987259be4b 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -2761,7 +2761,6 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, = const char *name, esxVI_String *completePropertyNameList =3D NULL; esxVI_ObjectContent *virtualMachineList =3D NULL; esxVI_ObjectContent *candidate =3D NULL; - char *name_candidate =3D NULL; =20 ESX_VI_CHECK_ARG_LIST(virtualMachine); =20 @@ -2775,7 +2774,7 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, = const char *name, =20 for (candidate =3D virtualMachineList; candidate; candidate =3D candidate->_next) { - VIR_FREE(name_candidate); + g_autofree char *name_candidate =3D NULL; =20 if (esxVI_GetVirtualMachineIdentity(candidate, NULL, &name_candida= te, NULL) < 0) { @@ -2802,8 +2801,6 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, = const char *name, cleanup: esxVI_String_Free(&completePropertyNameList); esxVI_ObjectContent_Free(&virtualMachineList); - VIR_FREE(name_candidate); - return result; } =20 --=20 2.29.2 From nobody Sun May 5 05:48:51 2024 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=1613167670; cv=none; d=zohomail.com; s=zohoarc; b=jP5O2YlkSMtEsR+z2/YF9i5yqhX7KV0yTt4/37v0gjbgWyEKpdRW9qGZVCu0Zc1POtzDbf+XKJvUeo1xz/LsY69OymIeADWmerc9y3GfQrKlY9wXMC+ywGOdKo8ldTLTk+1gR7QsfY5nzjfEr5sg1Z1SyOpQRH9GiHBiqGNUM6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167670; 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=6xtjZWbipcrWzOBcR7fqvaWlpfiRo4HbyQ3pwXGENeU=; b=mpducfCyfGSf0jl42OfxB6ehRts6KgExAx4XEdrVI/YTkf033TQK/AJMte4ulSrfQv3Wb0ZHy4qDb8LLtTdqfAUKuIzbM7Qcu4XhUwcfVa8FPwAjUcu2BL9MjFd9n7oQ7sHnnOJnuedphAuwHs92JAk7kk75sz6FubR58d8WoDg= 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 1613167670426132.64034220842802; Fri, 12 Feb 2021 14:07:50 -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-42-NgWStyWQOeKIr1rqlR940Q-1; Fri, 12 Feb 2021 17:07:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76D5F1005501; Fri, 12 Feb 2021 22:07:28 +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 20E05E70D; Fri, 12 Feb 2021 22:07:28 +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 E76C44E58E; Fri, 12 Feb 2021 22:07:24 +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 11CM7Mxt006140 for ; Fri, 12 Feb 2021 17:07:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE1B91002388; Fri, 12 Feb 2021 22:07:22 +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 751461001E73 for ; Fri, 12 Feb 2021 22:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167658; 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=6xtjZWbipcrWzOBcR7fqvaWlpfiRo4HbyQ3pwXGENeU=; b=fo/uRdWNu8Wj2NqkM3ZMhU/tRBeXbserdVgXYGkLya0fnu3kvb095if/yn4lchR8Nxufui B+cZF/8qYNuMH441IsxI0c4h/j2F7FSHjwaf/dWJErqVIBEesUBC6Vln31LQ1ZbOFwUO0Y A+yjuhSJeyQnS4GQkkn2QxNzG5bUtco= X-MC-Unique: NgWStyWQOeKIr1rqlR940Q-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 3/9] esx: fix memory leak by switching to g_autofree Date: Fri, 12 Feb 2021 17:07:11 -0500 Message-Id: <20210212220717.910294-4-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.84 on 10.5.11.23 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" volumeName was defined at the top of the function, then a new string was assigned to it each time through a loop, but after the first iteration of the loop, the previous string wasn't freed before allocating a new string the next time. By reducing the scope of volumeName to be just the loop, and making it g_autofree, we eliminate the leak. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_storage_backend_vmfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 63959ec237..225b2a4751 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -728,7 +728,6 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) esxVI_HostDatastoreBrowserSearchResults *searchResultsList =3D NULL; esxVI_HostDatastoreBrowserSearchResults *searchResults =3D NULL; size_t length; - char *volumeName =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; char key_candidate[VIR_UUID_STRING_BUFLEN] =3D ""; =20 @@ -789,6 +788,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) /* Build datastore path and query the UUID */ for (fileInfo =3D searchResults->file; fileInfo; fileInfo =3D fileInfo->_next) { + g_autofree char *volumeName =3D NULL; g_autofree char *datastorePath =3D NULL; g_autofree char *uuid_string =3D NULL; =20 @@ -831,8 +831,6 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&datastoreList); esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList); - VIR_FREE(volumeName); - return volume; } =20 --=20 2.29.2 From nobody Sun May 5 05:48:51 2024 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=1613167750; cv=none; d=zohomail.com; s=zohoarc; b=O5SdKl5OVTGQXtUD7qnwUU0HgKqb27yCJjZ7xNyXbHdnO+/LvTvEbWZEMj/tYAa/JHayzorYKJloKKIqPxzdX0Eii1IeUZNKIuxnRMVB+4u70dp6vodH3jAQclW4lk5wsBgpI52T7mf4u3S5QqFfPAGp/4iiEGKqhrjfj+N2/GI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167750; 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=6GvLqd3MLiwMgIh8Wp0ImjqZs2uq4SUN6X4lDfuaPLE=; b=W5a83sqVl5Wgb7G4xs9Ti5pUWx2hkPShzmyQgmVMhQWEteiMy37Gyz1rYvFcjS5U0b8jJxYCbu9Ci77xBOMxAUgKw8S9uPkAa/97gehYfr+B66ibD2sNeUkswS1Jlw9aQbx6Jm3V2fgxIO9ktlBV4GdlwMjhrthaJjTHaonjhnQ= 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 161316774982654.61669147376642; Fri, 12 Feb 2021 14:09:09 -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-567--tb1c6U4OtGn6lHvHbhLwg-1; Fri, 12 Feb 2021 17:07:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3289C8710E0; Fri, 12 Feb 2021 22:07:43 +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 0C6447086E; Fri, 12 Feb 2021 22:07:43 +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 CA5D057DFA; Fri, 12 Feb 2021 22:07:42 +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 11CM7Ncn006147 for ; Fri, 12 Feb 2021 17:07:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1736E100239A; Fri, 12 Feb 2021 22:07:23 +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 D25FF1002388 for ; Fri, 12 Feb 2021 22:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167746; 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=6GvLqd3MLiwMgIh8Wp0ImjqZs2uq4SUN6X4lDfuaPLE=; b=GXaJakNpupPBdp0Lg59K4QpbiZTyrUzC+rPxkkAgnaMqR5iYaJS0/am4nC2h1KWU5aTe7T EVSV6ubCb/6Ho26DotIlZN3z/32O8EjbA4bbDUoDkXkQHy1dxPaX4qjapps4Ezz4/M9xgX Bht0PwPvBJPUTL1Rubkm1a3L3Fk4fDs= X-MC-Unique: -tb1c6U4OtGn6lHvHbhLwg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 4/9] esx: switch VIR_FREE->g_free in esx*Free*() Date: Fri, 12 Feb 2021 17:07:12 -0500 Message-Id: <20210212220717.910294-5-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.13 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" Although the three functions esxFreePrivate(), esxFreeStreamPrivate(), and esxUtil_FreeParsedUri() are calling VIR_FREE on *object, and so in theory the caller of the function might rely on "object" (the free function's arg) being set to NULL, in practice these functions are only called from a couple places each, and in all cases the pointer that is passed is a local variable, and goes out of scope almost immediately after calling the Free function, so it is safe to change VIR_FREE() into g_free(). Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_driver.c | 2 +- src/esx/esx_stream.c | 4 ++-- src/esx/esx_util.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 8afec464dd..952e769376 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -71,7 +71,7 @@ esxFreePrivate(esxPrivate **priv) esxUtil_FreeParsedUri(&(*priv)->parsedUri); virObjectUnref((*priv)->caps); virObjectUnref((*priv)->xmlopt); - VIR_FREE(*priv); + g_free(*priv); } =20 =20 diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c index cc48c182d9..131fbc100b 100644 --- a/src/esx/esx_stream.c +++ b/src/esx/esx_stream.c @@ -336,8 +336,8 @@ esxFreeStreamPrivate(esxStreamPrivate **priv) return; =20 esxVI_CURL_Free(&(*priv)->curl); - VIR_FREE((*priv)->backlog); - VIR_FREE(*priv); + g_free((*priv)->backlog); + g_free(*priv); } =20 static int diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index 64a2c968f0..e9b74f386f 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -171,12 +171,12 @@ esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri) if (!parsedUri || !(*parsedUri)) return; =20 - VIR_FREE((*parsedUri)->transport); - VIR_FREE((*parsedUri)->vCenter); - VIR_FREE((*parsedUri)->proxy_hostname); - VIR_FREE((*parsedUri)->path); + g_free((*parsedUri)->transport); + g_free((*parsedUri)->vCenter); + g_free((*parsedUri)->proxy_hostname); + g_free((*parsedUri)->path); =20 - VIR_FREE(*parsedUri); + g_free(*parsedUri); } =20 =20 --=20 2.29.2 From nobody Sun May 5 05:48:51 2024 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=1613167678; cv=none; d=zohomail.com; s=zohoarc; b=bNgfHnoto/o002sN7Nc9nLYc5BZaCc2v75ITEzzFP7s6o/9UcuZwsmyu0x3cuVThdh50I1RQtDXu2+8zpOyFkg/zNjMTzSp5C8l/GhYcipWOjjhe2RkdWtPi7Zi0jm18FgK/gmkJHDu3AhOuxMTWEOqaWD4Lp4cBdsIDBnNwSGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167678; 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=Im600bnC8SwRMKN+oyG0EQ0g7UDZNI3KTQSSGqDNG5E=; b=f/pwilhgoowKH1kDxPuMWriPWikmiDp6lfbvg4qXcQ9ND3vJw7d2ZHayKaY4+y1WOmEat41Y1wQFqKj6fsPvOY6K4+b3+R0JxmBDrv/JE0z6vFLV+mOflrBl291Kb12TmeSATOB1PJaQoJbiUcw0ivpGDf9IBKQOZtog4Aci0dE= 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) header.from= 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 1613167678728217.22245815148744; Fri, 12 Feb 2021 14:07:58 -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-33-EAMf4tUCN2qWK6HwHWh59A-1; Fri, 12 Feb 2021 17:07:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53597107ACE4; Fri, 12 Feb 2021 22:07:41 +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 2F52D5C3FD; Fri, 12 Feb 2021 22:07:41 +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 E3B071809C8F; 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 11CM7N6j006157 for ; Fri, 12 Feb 2021 17:07:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 739A310023AD; Fri, 12 Feb 2021 22:07:23 +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 3AB801002388 for ; Fri, 12 Feb 2021 22:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167670; 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=Im600bnC8SwRMKN+oyG0EQ0g7UDZNI3KTQSSGqDNG5E=; b=cvehI2IL8BkTWb8z0dYSgvCmQdvdnEYac8YvcWhGshP0q/3d2++EoGmLPlDid803e8MM/D 1LWQQ0p2WA+Aeni+8IP6NgdNtbFV87Hc+IAKq/mtuMN9obrvXimiafEuILbk0/tKj7Aui2 wimIxHo4MW1AJYt96afBs2AeF3Xdo5s= X-MC-Unique: EAMf4tUCN2qWK6HwHWh59A-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] esx: use g_steal_pointer+g_autofree on return value Date: Fri, 12 Feb 2021 17:07:13 -0500 Message-Id: <20210212220717.910294-6-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.16 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" If we put the potential return string into the g_autofreed tmpResult, and the move it to the returned "result" only as a final step ater, we can avoid the need to explicitly VIR_FREE (or g_free) on failure. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_driver.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 952e769376..47873c0d54 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -275,7 +275,7 @@ esxParseVMXFileName(const char *fileName, static char * esxFormatVMXFileName(const char *fileName, void *opaque) { - bool success =3D false; + g_autofree char *tmpResult =3D NULL; char *result =3D NULL; esxVMX_Data *data =3D opaque; g_autofree char *datastoreName =3D NULL; @@ -329,10 +329,10 @@ esxFormatVMXFileName(const char *fileName, void *opaq= ue) virBufferAddChar(&buffer, separator); virBufferAdd(&buffer, directoryAndFileName, -1); =20 - result =3D virBufferContentAndReset(&buffer); + tmpResult =3D virBufferContentAndReset(&buffer); } else if (*fileName =3D=3D '/') { /* FIXME: need to deal with Windows paths here too */ - result =3D g_strdup(fileName); + tmpResult =3D g_strdup(fileName); } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not handle file name '%s'"), fileName); @@ -341,15 +341,11 @@ esxFormatVMXFileName(const char *fileName, void *opaq= ue) =20 /* FIXME: Check if referenced path/file really exists */ =20 - success =3D true; + result =3D g_steal_pointer(&tmpResult); =20 cleanup: - if (! success) - VIR_FREE(result); - esxVI_ObjectContent_Free(&datastore); esxVI_DatastoreHostMount_Free(&hostMount); - return result; } =20 --=20 2.29.2 From nobody Sun May 5 05:48:51 2024 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=1613167685; cv=none; d=zohomail.com; s=zohoarc; b=hX3BPTEwOLQDUZKMR2t6Z1TW2P+r4azz2xpPKFYGnqIqBl6ZdXnNMUC3shJTGKTnE0q7PrABgU0YEyGCNr+++WDFjvW10cik8h/3oQIlDxjohiQlkrceFkPHOSjn5YcUlxD3G+cwEEKi+F1j4cf8rj+q3FqPcUlKrwBIE7c16vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167685; 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=T5yKy7PyP13MeE4GJx0FHXMKKm5JIth1MSbeDg1Yyn4=; b=VTZzvhyRX/09B4lhLw/GNyQKkyf6VSTz+IYeND377ywMCYSJEO9w1AMxzuiEsrSj/esnhFho8pYHIosMhyGKIgg41gJp6mVrU4rF/UlWMMwK2xIUtmswDa3+tdeL5Ng95ex87s0zjCVnxpAML4u/dBN4PM1eEFC1GkV9QVpQdeQ= 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 1613167685181317.8639866825238; Fri, 12 Feb 2021 14:08:05 -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-267-RZkj-Yc7OEy2RDvVSvbUpA-1; Fri, 12 Feb 2021 17:07:50 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 146B580197A; Fri, 12 Feb 2021 22:07:44 +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 E76AD60BE5; Fri, 12 Feb 2021 22:07:43 +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 B26501809C92; Fri, 12 Feb 2021 22:07:43 +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 11CM7N6G006162 for ; Fri, 12 Feb 2021 17:07:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id D12471002388; Fri, 12 Feb 2021 22:07:23 +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 987101001E73 for ; Fri, 12 Feb 2021 22:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167681; 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=T5yKy7PyP13MeE4GJx0FHXMKKm5JIth1MSbeDg1Yyn4=; b=fDxvYPTtAUAugXRKz4ZoQoRriKkzv5sn2pGtR1yCXkv7JUSUQIcAuLuUYiZHNZthTkCXba a5PGpgYI8ghv11Bj0/pfKNwERqARRB2DFB2UYNDkVhnsH2Vq3CjSH9i3OQuZ5jJSLsm1p7 qrmUT8CZbNNv7tv1nI1ZS+QyivzQjuc= X-MC-Unique: RZkj-Yc7OEy2RDvVSvbUpA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] esx: reorder code to avoid need to VIR_FREE mimeType Date: Fri, 12 Feb 2021 17:07:14 -0500 Message-Id: <20210212220717.910294-7-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.12 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" mimeType is initialized to NULL, and then only set in one place, just before a check (not involving mimeType) that then VIR_FREEs mimeType if it fails. If we just reorder the code to do the check prior to setting mimeType, then there won't be any need to VIR_FREE(mimeType) on failure (because it will already be empty/NULL). Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_driver.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 47873c0d54..2d010096a5 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2374,12 +2374,10 @@ esxDomainScreenshot(virDomainPtr domain, virStreamP= tr stream, =20 url =3D virBufferContentAndReset(&buffer); =20 - mimeType =3D g_strdup("image/png"); - - if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) { - VIR_FREE(mimeType); + if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) goto cleanup; - } + + mimeType =3D g_strdup("image/png"); =20 cleanup: =20 --=20 2.29.2 From nobody Sun May 5 05:48:51 2024 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=1613167693; cv=none; d=zohomail.com; s=zohoarc; b=IgGWzYlOQ/2N6LqG7gP2+9Zb+5faSNP+bP9E1dEK4EOVK4Bc1ltNk9pkxYgSy+OZm6Mmq85WvGlOkzQA5uUBECYUVrt5lu1InrP4wyMhmQ9eMPJORPfrz/8Y+A9pVUDiYjpMBTEODfcCKNOx+VcwIa0L9sVa9NE72YwYHTpty88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167693; 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=FFWVIOFQg1+WhI//ANP1R+NUojp+ErZKhyg4KlIA7mc=; b=YYdfcARGZQ6gFKg7jByw2lm6yufqLx8/ASJVJ9AaihrSxcPFdhMAz0ZPiwAJUDU2KMUpMWppDQHkjqD9XxuUKP3AeeSTo4vQNBDGSA1YEk5aNQUB+Q6ckGMM1ZkuY/mGATaFI61o3etG1+ZUYXmrDStjgk/zXGtpPy1K7+w3PGU= 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) header.from= 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 1613167693201820.4126094255387; Fri, 12 Feb 2021 14:08:13 -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-561-xD14SbF1PhyrYmJmNdBDVA-1; Fri, 12 Feb 2021 17:07:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7ED7B107ACC7; Fri, 12 Feb 2021 22:07:40 +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 5A66A5C23D; 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 22AA218095CD; 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 11CM7OGn006170 for ; Fri, 12 Feb 2021 17:07:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3A3AD1002388; Fri, 12 Feb 2021 22:07:24 +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 0238C1001E73 for ; Fri, 12 Feb 2021 22:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167685; 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=FFWVIOFQg1+WhI//ANP1R+NUojp+ErZKhyg4KlIA7mc=; b=famO9Hlz3Cy4knf+/XF9plRUMLzYN7ST9cBdk8KbE46tyOKcqGH+CbRXXZfwVvfxZxrGnd n8GAmaZsOQjVMYB93NIWS/abAB9b891ziG7S2eQZI/IlM8qYM1+UzBSbHJYA/RRdeCFoLA SjXwqn4tHg16bl5hr9Yh4D738dS3sgo= X-MC-Unique: xD14SbF1PhyrYmJmNdBDVA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 7/9] esx: switch VIR_FREE->g_free when the pointer will immediately go out of scope Date: Fri, 12 Feb 2021 17:07:15 -0500 Message-Id: <20210212220717.910294-8-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.16 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" Or when it will be immediately have a new value assigned to it. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_driver.c | 4 ++-- src/esx/esx_network_driver.c | 2 +- src/esx/esx_storage_backend_iscsi.c | 4 ++-- src/esx/esx_storage_backend_vmfs.c | 4 ++-- src/esx/esx_util.c | 4 ++-- src/esx/esx_vi.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 2d010096a5..fe98f90ea9 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2619,7 +2619,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int= flags) cleanup: esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachine); - VIR_FREE(data.datastorePathWithoutFileName); + g_free(data.datastorePathWithoutFileName); virDomainDefFree(def); =20 return xml; @@ -4946,7 +4946,7 @@ esxConnectListAllDomains(virConnectPtr conn, for (id =3D 0; id < count; id++) virObjectUnref(doms[id]); =20 - VIR_FREE(doms); + g_free(doms); } =20 esxVI_AutoStartDefaults_Free(&autoStartDefaults); diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index 15fc7931c0..b489f4de8a 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -913,7 +913,7 @@ esxConnectListAllNetworks(virConnectPtr conn, if (ret < 0) { if (nets && *nets) { for (i =3D 0; i < count; ++i) - VIR_FREE((*nets)[i]); + g_free((*nets)[i]); VIR_FREE(*nets); } } diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index 41bb9f6094..d89b5a4ba8 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -348,7 +348,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsign= ed int flags) xml =3D virStoragePoolDefFormat(&def); =20 cleanup: - VIR_FREE(def.source.hosts); + g_free(def.source.hosts); esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba); =20 return xml; @@ -727,7 +727,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, =20 cleanup: esxVI_ScsiLun_Free(&scsiLunList); - VIR_FREE(def.key); + g_free(def.key); =20 return xml; } diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 225b2a4751..95505d6796 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -544,7 +544,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsign= ed int flags) xml =3D virStoragePoolDefFormat(&def); =20 cleanup: - VIR_FREE(def.source.hosts); + g_free(def.source.hosts); esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&datastore); esxVI_DatastoreHostMount_Free(&hostMount); @@ -1390,7 +1390,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, =20 cleanup: esxVI_FileInfo_Free(&fileInfo); - VIR_FREE(def.key); + g_free(def.key); =20 return xml; } diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index e9b74f386f..f1e8339fe0 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -55,7 +55,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr= uri) virURIParamPtr queryParam =3D &uri->params[i]; =20 if (STRCASEEQ(queryParam->name, "transport")) { - VIR_FREE((*parsedUri)->transport); + g_free((*parsedUri)->transport); =20 (*parsedUri)->transport =3D g_strdup(queryParam->value); =20 @@ -68,7 +68,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr= uri) goto cleanup; } } else if (STRCASEEQ(queryParam->name, "vcenter")) { - VIR_FREE((*parsedUri)->vCenter); + g_free((*parsedUri)->vCenter); =20 (*parsedUri)->vCenter =3D g_strdup(queryParam->value); } else if (STRCASEEQ(queryParam->name, "no_verify")) { diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 987259be4b..2a999f1cc1 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -4280,7 +4280,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, if (esxVI_WaitForUpdates(ctx, version, &updateSet) < 0) goto cleanup; =20 - VIR_FREE(version); + g_free(version); version =3D g_strdup(updateSet->version); =20 if (!updateSet->filterSet) @@ -4355,7 +4355,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, =20 esxVI_PropertyFilterSpec_Free(&propertyFilterSpec); esxVI_ManagedObjectReference_Free(&propertyFilter); - VIR_FREE(version); + g_free(version); esxVI_UpdateSet_Free(&updateSet); esxVI_TaskInfo_Free(&taskInfo); =20 --=20 2.29.2 From nobody Sun May 5 05:48:51 2024 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=1613167685; cv=none; d=zohomail.com; s=zohoarc; b=XewrkRMshDljdL8UCZ4oiFFKGjdbjFIbu8B0hGbCndy1+bdL96ML/2zcYktQyw+RpcSKezY6dUYrZpxu0WcPQeRYwRAOuFXoOJZ0L0g92RLYosiC0Jeb7DVufV5kScQ40Nblag+D0dlSH72zMkgkmkWmyi2gNOxsqpDs84lBakE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167685; 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=pRUrM8qGtZrciNzTbgbRGzlopDrFT9ozroSgWmvay4U=; b=F2N7iPUdoFC2XNkoRhYy+qpX8gLQTXkzH+Lc32MzUFnwbIFUywxv7VER5ig3+eF3qOkhuWJxc2vZ0Ck9xY4TAIJm7cO0LCGaueHH/fey/cb2tmp6qUNdsAeHmd6npzes83rurRhUWvK88YClJCJLXFmihhE0Nq3QjtrxFr4x1lM= 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 16131676853451010.2555647683406; Fri, 12 Feb 2021 14:08:05 -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-170-YpKMw_-iNJSHQPJZ8rFOVg-1; Fri, 12 Feb 2021 17:07:52 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DBE151966324; Fri, 12 Feb 2021 22:07:45 +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 B1C4019D9F; Fri, 12 Feb 2021 22:07:45 +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 7A93718089C9; Fri, 12 Feb 2021 22:07:45 +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 11CM7OP9006176 for ; Fri, 12 Feb 2021 17:07:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 97D57100239A; Fri, 12 Feb 2021 22:07:24 +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 5FB7E1002388 for ; Fri, 12 Feb 2021 22:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167675; 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=pRUrM8qGtZrciNzTbgbRGzlopDrFT9ozroSgWmvay4U=; b=MCLA4RwOavE5leo39syESZXpd4HbDMqdRKm7oUHJwtMOhwdc9C2arlMu73WFPkUMxzn5QW uB3+4q/xxVCrMy+TBykh1C9xdjxjdQ6t0SHssETzW8TwKmjdWr2cWL3MDcwzC/O/2EAmwH bgVy2fm+lxmp3e56Q53gp4LYNlKrYtM= X-MC-Unique: YpKMw_-iNJSHQPJZ8rFOVg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 8/9] esx: eliminate unnecessary cleanup: labels and result variables Date: Fri, 12 Feb 2021 17:07:16 -0500 Message-Id: <20210212220717.910294-9-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.84 on 10.5.11.23 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" switching to g_autofree left many cleanup: sections empty. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_driver.c | 22 ++++++--------- src/esx/esx_storage_backend_vmfs.c | 22 +++++---------- src/esx/esx_util.c | 8 ++---- src/esx/esx_vi.c | 45 +++++++++++++----------------- src/esx/esx_vi_types.c | 8 ++---- 5 files changed, 38 insertions(+), 67 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index fe98f90ea9..e49975de86 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -690,7 +690,6 @@ esxConnectToVCenter(esxPrivate *priv, const char *hostname, const char *hostSystemIPAddress) { - int result =3D -1; g_autofree char *ipAddress =3D NULL; g_autofree char *username =3D NULL; g_autofree char *password =3D NULL; @@ -711,11 +710,11 @@ esxConnectToVCenter(esxPrivate *priv, } else { if (!(username =3D virAuthGetUsername(conn, auth, "esx", "administ= rator", hostname))) - goto cleanup; + return -1; } =20 if (!(password =3D virAuthGetPassword(conn, auth, "esx", username, hos= tname))) - goto cleanup; + return -1; =20 url =3D g_strdup_printf("%s://%s:%d/sdk", priv->parsedUri->transport, = hostname, conn->uri->port); @@ -723,7 +722,7 @@ esxConnectToVCenter(esxPrivate *priv, if (esxVI_Context_Alloc(&priv->vCenter) < 0 || esxVI_Context_Connect(priv->vCenter, url, ipAddress, username, password, priv->parsedUri) < 0) { - goto cleanup; + return -1; } =20 if (priv->vCenter->productLine !=3D esxVI_ProductLine_VPX) { @@ -732,25 +731,20 @@ esxConnectToVCenter(esxPrivate *priv, hostname, esxVI_ProductLineToDisplayName(esxVI_ProductLine_VP= X), esxVI_ProductLineToDisplayName(priv->vCenter->produ= ctLine)); - goto cleanup; + return -1; } =20 if (hostSystemIPAddress) { - if (esxVI_Context_LookupManagedObjectsByHostSystemIp - (priv->vCenter, hostSystemIPAddress) < 0) { - goto cleanup; - } + if (esxVI_Context_LookupManagedObjectsByHostSystemIp(priv->vCenter= , hostSystemIPAddress) < 0) + return -1; } else { if (esxVI_Context_LookupManagedObjectsByPath(priv->vCenter, priv->parsedUri->path= ) < 0) { - goto cleanup; + return -1; } } =20 - result =3D 0; - - cleanup: - return result; + return 0; } =20 =20 diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 95505d6796..cb2be59a33 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -667,7 +667,6 @@ static virStorageVolPtr esxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) { - virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D pool->conn->privateData; g_autofree char *datastorePath =3D NULL; g_autofree char *key =3D NULL; @@ -676,14 +675,11 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, =20 if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, datastorePath, &key) <= 0) { - goto cleanup; + return NULL; } =20 - volume =3D virGetStorageVol(pool->conn, pool->name, name, key, - &esxStorageBackendVMFS, NULL); - - cleanup: - return volume; + return virGetStorageVol(pool->conn, pool->name, name, key, + &esxStorageBackendVMFS, NULL); } =20 =20 @@ -691,7 +687,6 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, static virStorageVolPtr esxStorageVolLookupByPath(virConnectPtr conn, const char *path) { - virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D conn->privateData; g_autofree char *datastoreName =3D NULL; g_autofree char *directoryAndFileName =3D NULL; @@ -699,19 +694,16 @@ esxStorageVolLookupByPath(virConnectPtr conn, const c= har *path) =20 if (esxUtil_ParseDatastorePath(path, &datastoreName, NULL, &directoryAndFileName) < 0) { - goto cleanup; + return NULL; } =20 if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, path, &key) < 0) { - goto cleanup; + return NULL; } =20 - volume =3D virGetStorageVol(conn, datastoreName, directoryAndFileName,= key, - &esxStorageBackendVMFS, NULL); - - cleanup: - return volume; + return virGetStorageVol(conn, datastoreName, directoryAndFileName, key, + &esxStorageBackendVMFS, NULL); } =20 =20 diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index f1e8339fe0..ef070a4f04 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -429,7 +429,6 @@ esxUtil_EscapeDatastoreItem(const char *string) { g_autofree char *replaced =3D NULL; g_autofree char *escaped1 =3D NULL; - char *escaped2 =3D NULL; =20 replaced =3D g_strdup(string); =20 @@ -438,12 +437,9 @@ esxUtil_EscapeDatastoreItem(const char *string) escaped1 =3D virVMXEscapeHexPercent(replaced); =20 if (!escaped1) - goto cleanup; - - escaped2 =3D esxUtil_EscapeBase64(escaped1); + return NULL; =20 - cleanup: - return escaped2; + return esxUtil_EscapeBase64(escaped1); } =20 =20 diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 2a999f1cc1..db5035c035 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -830,7 +830,6 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, const char *ipAddress, const char *username, const char *password, esxUtil_ParsedUri *parsedUri) { - int result =3D -1; g_autofree char *escapedPassword =3D NULL; =20 if (!ctx || !url || !ipAddress || !username || @@ -844,12 +843,12 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char = *url, if (!escapedPassword) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to escape password for XML")); - goto cleanup; + return -1; } =20 if (esxVI_CURL_Alloc(&ctx->curl) < 0 || esxVI_CURL_Connect(ctx->curl, parsedUri) < 0) { - goto cleanup; + return -1; } =20 ctx->url =3D g_strdup(url); @@ -863,18 +862,18 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char = *url, if (virMutexInit(ctx->sessionLock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not initialize session mutex")); - goto cleanup; + return -1; } =20 if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0) - goto cleanup; + return -1; =20 if (STRNEQ(ctx->service->about->apiType, "HostAgent") && STRNEQ(ctx->service->about->apiType, "VirtualCenter")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting VI API type 'HostAgent' or 'VirtualCen= ter' " "but found '%s'"), ctx->service->about->apiType); - goto cleanup; + return -1; } =20 if (virParseVersionString(ctx->service->about->apiVersion, @@ -882,14 +881,14 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char = *url, virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse VI API version '%s'"), ctx->service->about->apiVersion); - goto cleanup; + return -1; } =20 if (ctx->apiVersion < 1000000 * 2 + 1000 * 5 /* 2.5 */) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Minimum supported %s version is %s but found ver= sion '%s'"), "VI API", "2.5", ctx->service->about->apiVersion); - goto cleanup; + return -1; } =20 if (virParseVersionString(ctx->service->about->version, @@ -897,7 +896,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse product version '%s'"), ctx->service->about->version); - goto cleanup; + return -1; } =20 if (STREQ(ctx->service->about->productLineId, "gsx")) { @@ -906,7 +905,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, _("Minimum supported %s version is %s but found= version '%s'"), esxVI_ProductLineToDisplayName(esxVI_ProductLin= e_GSX), "2.0", ctx->service->about->version); - goto cleanup; + return -1; } =20 ctx->productLine =3D esxVI_ProductLine_GSX; @@ -917,7 +916,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, _("Minimum supported %s version is %s but found= version '%s'"), esxVI_ProductLineToDisplayName(esxVI_ProductLin= e_ESX), "3.5", ctx->service->about->version); - goto cleanup; + return -1; } =20 ctx->productLine =3D esxVI_ProductLine_ESX; @@ -927,7 +926,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, _("Minimum supported %s version is %s but found= version '%s'"), esxVI_ProductLineToDisplayName(esxVI_ProductLin= e_VPX), "2.5", ctx->service->about->version); - goto cleanup; + return -1; } =20 ctx->productLine =3D esxVI_ProductLine_VPX; @@ -936,7 +935,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, _("Expecting product 'gsx' or 'esx' or 'embeddedEsx= ' " "or 'vpx' but found '%s'"), ctx->service->about->productLineId); - goto cleanup; + return -1; } =20 if (ctx->productLine =3D=3D esxVI_ProductLine_ESX) { @@ -957,13 +956,10 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char = *url, =20 if (esxVI_Login(ctx, username, escapedPassword, NULL, &ctx->session) <= 0 || esxVI_BuildSelectSetCollection(ctx) < 0) { - goto cleanup; + return -1; } =20 - result =3D 0; - - cleanup: - return result; + return 0; } =20 int @@ -4093,7 +4089,6 @@ esxVI_HandleVirtualMachineQuestion esxVI_VirtualMachineQuestionInfo *questionInfo, bool autoAnswer, bool *blocked) { - int result =3D -1; esxVI_ElementDescription *elementDescription =3D NULL; g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; esxVI_ElementDescription *answerChoice =3D NULL; @@ -4136,7 +4131,7 @@ esxVI_HandleVirtualMachineQuestion questionInfo->text); =20 *blocked =3D true; - goto cleanup; + return -1; } else if (!answerChoice) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Pending question blocks virtual machine exec= ution, " @@ -4145,7 +4140,7 @@ esxVI_HandleVirtualMachineQuestion possibleAnswers); =20 *blocked =3D true; - goto cleanup; + return -1; } =20 VIR_INFO("Pending question blocks virtual machine execution, " @@ -4155,7 +4150,7 @@ esxVI_HandleVirtualMachineQuestion =20 if (esxVI_AnswerVM(ctx, virtualMachine, questionInfo->id, answerChoice->key) < 0) { - goto cleanup; + return -1; } } else { if (possibleAnswers) { @@ -4171,13 +4166,11 @@ esxVI_HandleVirtualMachineQuestion } =20 *blocked =3D true; - goto cleanup; + return -1; } =20 - result =3D 0; + return 0; =20 - cleanup: - return result; } =20 =20 diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 1af075813e..4dc7c30680 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -700,7 +700,6 @@ static int esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type baseType, esxVI_Type *actualType) { - int result =3D -1; g_autofree char *type =3D NULL; =20 if (!actualType || *actualType !=3D esxVI_Type_Undefined) { @@ -724,13 +723,10 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type= baseType, virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown value '%s' for %s 'type' property"), type, esxVI_Type_ToString(baseType)); - goto cleanup; + return -1; } =20 - result =3D 0; - - cleanup: - return result; + return 0; } =20 =20 --=20 2.29.2 From nobody Sun May 5 05:48:51 2024 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=1613167679; cv=none; d=zohomail.com; s=zohoarc; b=oBwVBlo6qW3m5INnEMefp4FhtcgC6TYoc+9J96nAr4n4ptJqPSr47v2vjZ/Xf5NDx3qmekK0jfRmcVUbtD7UCFkeGOKIj9Kcbxhp4MCxC3orUs8V6qt+JqbmsKnXA+42NEKY7yiFtvKoGLNWLruZuUBR1hZgGrfX2Yu9nf1USRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167679; 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=LP6rGd3l8sUEWj5LgsXbJqVdBDJYmYy/JED/7ZO8fko=; b=XQV0SE8RF865TdCpJQHTtVx+N3L/is/7f9SESmkWuo9ayZfBZVPbcIAe21OSnyYu1L6F0m6Z+nqFjngtBsuZunDmOOt6mWcsch9am3I48Kjj7as9ZBDG9xJ5ZyfdbpHGn7lfKpoPrX2rkR/m4YvB8uM34rPzgRePX5FZaWevsRA= 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) header.from= 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 1613167679861470.3601413053673; Fri, 12 Feb 2021 14:07:59 -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-175-5dNYmCsTPOGdz9m14RV-HA-1; Fri, 12 Feb 2021 17:07:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E89E71966320; Fri, 12 Feb 2021 22:07:44 +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 C5BA96267B; Fri, 12 Feb 2021 22:07:44 +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 8FE67EDCE; Fri, 12 Feb 2021 22:07:44 +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 11CM7PSo006181 for ; Fri, 12 Feb 2021 17:07:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3C831001E73; Fri, 12 Feb 2021 22:07:24 +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 BBCE11002388 for ; Fri, 12 Feb 2021 22:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167673; 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=LP6rGd3l8sUEWj5LgsXbJqVdBDJYmYy/JED/7ZO8fko=; b=d/PEkjpH6XF192WHF6xfNlNJemmtcvmkpx5aP2fNTpBDSP7BEn5lQQq7Sz8cAPWxbJJXVH As05Z9A/YNy/WC/r2f1I3aMEhq8ZomfYH5cielsom4gd81ee75XS2FYnrlo1PhpMMwAxAh mj0haRp8777IhnMRpuyR0MIsZwnRoNc= X-MC-Unique: 5dNYmCsTPOGdz9m14RV-HA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 9/9] esx: replace some VIR_FREE with g_clear_pointer(x, g_free) Date: Fri, 12 Feb 2021 17:07:17 -0500 Message-Id: <20210212220717.910294-10-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.15 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 are all cases when 1) the pointer is passed by reference from the caller (ie.e. **) and expects it to be NULL on return if there is an error, or 2) the variable holding the pointer is being checked or re-used in the same function, but not right away. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/esx/esx_network_driver.c | 2 +- src/esx/esx_util.c | 8 ++++---- src/esx/esx_vi.c | 4 ++-- src/esx/esx_vi_types.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index b489f4de8a..4d0fba8c9f 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -914,7 +914,7 @@ esxConnectListAllNetworks(virConnectPtr conn, if (nets && *nets) { for (i =3D 0; i < count; ++i) g_free((*nets)[i]); - VIR_FREE(*nets); + g_clear_pointer(nets, g_free); } } =20 diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index ef070a4f04..24e1c73ec4 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -95,7 +95,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr= uri) /* Expected format: [://][:] */ (*parsedUri)->proxy =3D true; (*parsedUri)->proxy_type =3D CURLPROXY_HTTP; - VIR_FREE((*parsedUri)->proxy_hostname); + g_clear_pointer(&(*parsedUri)->proxy_hostname, g_free); (*parsedUri)->proxy_port =3D 1080; =20 if ((tmp =3D STRSKIP(queryParam->value, "http://"))) { @@ -261,13 +261,13 @@ esxUtil_ParseDatastorePath(const char *datastorePath,= char **datastoreName, cleanup: if (result < 0) { if (datastoreName) - VIR_FREE(*datastoreName); + g_clear_pointer(datastoreName, g_free); =20 if (directoryName) - VIR_FREE(*directoryName); + g_clear_pointer(directoryName, g_free); =20 if (directoryAndFileName) - VIR_FREE(*directoryAndFileName); + g_clear_pointer(directoryAndFileName, g_free); } =20 return result; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index db5035c035..e1c1a15ab6 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -73,7 +73,7 @@ VIR_LOG_INIT("esx.esx_vi"); \ _body \ \ - VIR_FREE(*ptrptr); \ + g_clear_pointer(ptrptr, g_free); \ } =20 =20 @@ -2516,7 +2516,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *= virtualMachine, =20 failure: if (name) - VIR_FREE(*name); + g_clear_pointer(name, g_free); =20 return -1; } diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 4dc7c30680..59735194ae 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -67,7 +67,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); \ _body \ \ - VIR_FREE(*ptrptr); \ + g_clear_pointer(ptrptr, g_free); \ } =20 =20 --=20 2.29.2