[libvirt PATCH 0/8] More VIR_FREE removals

Only 90 this time. These are all functions that behave similar to the *Free() functions, but their names don't end in "Free" so I missed them last time. Laine Stump (8): esx: replace VIR_FREE with g_free in any ESX_VI__TEMPLATE__FREE conf: convert VIR_FREE to g_free in other functions that free their arg locking: convert VIR_FREE to g_free in other functions that free their arg openvz: convert VIR_FREE to g_free in other functions that free their arg remote: convert VIR_FREE to g_free in other functions that free their arg qemu: convert VIR_FREE to g_free in other functions that free their arg util: convert VIR_FREE to g_free in other functions that free their arg vmware: convert VIR_FREE to g_free in other functions that free their arg src/conf/capabilities.c | 38 +++++++++++++++---------------- src/esx/esx_vi.c | 18 +++++++-------- src/esx/esx_vi_types.c | 24 +++++++++---------- src/locking/lock_manager.c | 4 ++-- src/openvz/openvz_conf.c | 2 +- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 8 +++---- src/remote/remote_daemon_stream.c | 2 +- src/util/virconf.c | 4 ++-- src/util/virerror.c | 4 ++-- src/util/virobject.c | 2 +- src/util/virstring.c | 4 ++-- src/vmware/vmware_conf.c | 4 ++-- src/vmware/vmware_driver.c | 4 ++-- 14 files changed, 60 insertions(+), 60 deletions(-) -- 2.29.2

Invocations of the macro ESX_VI__TEMPLATE__FREE() will free the main object (referenced as "item") that's pointing to all the things being VIR_FREEd in the body, so it is safe for all the pointers in item to just be g_freed rather that VIR_FREEd. Signed-off-by: Laine Stump <laine@redhat.com> --- src/esx/esx_vi.c | 18 +++++++++--------- src/esx/esx_vi_types.c | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 7e05318fdc..2eb8048858 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -805,19 +805,19 @@ ESX_VI__TEMPLATE__FREE(Context, virMutexDestroy(item->sessionLock); esxVI_CURL_Free(&item->curl); - VIR_FREE(item->url); - VIR_FREE(item->ipAddress); - VIR_FREE(item->username); - VIR_FREE(item->password); + g_free(item->url); + g_free(item->ipAddress); + g_free(item->username); + g_free(item->password); esxVI_ServiceContent_Free(&item->service); esxVI_UserSession_Free(&item->session); - VIR_FREE(item->sessionLock); + g_free(item->sessionLock); esxVI_Datacenter_Free(&item->datacenter); - VIR_FREE(item->datacenterPath); + g_free(item->datacenterPath); esxVI_ComputeResource_Free(&item->computeResource); - VIR_FREE(item->computeResourcePath); + g_free(item->computeResourcePath); esxVI_HostSystem_Free(&item->hostSystem); - VIR_FREE(item->hostSystemName); + g_free(item->hostSystemName); esxVI_SelectionSpec_Free(&item->selectSet_folderToChildEntity); esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToParent); esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToVm); @@ -1419,7 +1419,7 @@ ESX_VI__TEMPLATE__ALLOC(Response) /* esxVI_Response_Free */ ESX_VI__TEMPLATE__FREE(Response, { - VIR_FREE(item->content); + g_free(item->content); xmlFreeDoc(item->document); }) diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 6821587e44..4d3617e0a8 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -900,8 +900,8 @@ ESX_VI__TEMPLATE__ALLOC(AnyType) ESX_VI__TEMPLATE__FREE(AnyType, { xmlFreeNode(item->node); - VIR_FREE(item->other); - VIR_FREE(item->value); + g_free(item->other); + g_free(item->value); }) const char * @@ -1117,7 +1117,7 @@ ESX_VI__TEMPLATE__FREE(String, { esxVI_String_Free(&item->_next); - VIR_FREE(item->value); + g_free(item->value); }) /* esxVI_String_Validate */ @@ -1421,7 +1421,7 @@ ESX_VI__TEMPLATE__ALLOC(DateTime) /* esxVI_DateTime_Free */ ESX_VI__TEMPLATE__FREE(DateTime, { - VIR_FREE(item->value); + g_free(item->value); }) /* esxVI_DateTime_Validate */ @@ -1564,8 +1564,8 @@ ESX_VI__TEMPLATE__ALLOC(Fault); /* esxVI_Fault_Free */ ESX_VI__TEMPLATE__FREE(Fault, { - VIR_FREE(item->faultcode); - VIR_FREE(item->faultstring); + g_free(item->faultcode); + g_free(item->faultstring); }) /* esxVI_Fault_Validate */ @@ -1595,7 +1595,7 @@ ESX_VI__TEMPLATE__ALLOC(MethodFault); /* esxVI_MethodFault_Free */ ESX_VI__TEMPLATE__FREE(MethodFault, { - VIR_FREE(item->_actualType); + g_free(item->_actualType); }) int @@ -1638,8 +1638,8 @@ ESX_VI__TEMPLATE__FREE(ManagedObjectReference, { esxVI_ManagedObjectReference_Free(&item->_next); - VIR_FREE(item->type); - VIR_FREE(item->value); + g_free(item->type); + g_free(item->value); }) /* esxVI_ManagedObjectReference_DeepCopy */ @@ -1732,17 +1732,17 @@ ESX_VI__TEMPLATE__ALLOC(Event) ESX_VI__TEMPLATE__FREE(Event, { esxVI_Event_Free(&item->_next); - VIR_FREE(item->_actualType); + g_free(item->_actualType); esxVI_Int_Free(&item->key); esxVI_Int_Free(&item->chainId); esxVI_DateTime_Free(&item->createdTime); - VIR_FREE(item->userName); + g_free(item->userName); /* FIXME: datacenter is currently ignored */ /* FIXME: computeResource is currently ignored */ /* FIXME: host is currently ignored */ esxVI_VmEventArgument_Free(&item->vm); - VIR_FREE(item->fullFormattedMessage); + g_free(item->fullFormattedMessage); }) /* esxVI_Event_Validate */ -- 2.29.2

Previous patches have converted VIR_FREE to g_free in functions with names ending in Free() and Dispose(), but there are a few similar functions with names that don't fit that pattern, but server the same purpose (and thus can survive the same conversion). in particular *Free*(), and *Unref(). Signed-off-by: Laine Stump <laine@redhat.com> --- src/conf/capabilities.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index dd3321db9a..69d9bb0e38 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -118,10 +118,10 @@ virCapabilitiesFreeHostNUMACell(virCapsHostNUMACellPtr cell) virCapabilitiesClearHostNUMACellCPUTopology(cell->cpus, cell->ncpus); - VIR_FREE(cell->cpus); - VIR_FREE(cell->siblings); - VIR_FREE(cell->pageinfo); - VIR_FREE(cell); + g_free(cell->cpus); + g_free(cell->siblings); + g_free(cell->pageinfo); + g_free(cell); } static void @@ -129,9 +129,9 @@ virCapabilitiesFreeGuestMachine(virCapsGuestMachinePtr machine) { if (machine == NULL) return; - VIR_FREE(machine->name); - VIR_FREE(machine->canonical); - VIR_FREE(machine); + g_free(machine->name); + g_free(machine->canonical); + g_free(machine); } static void @@ -141,13 +141,13 @@ virCapabilitiesFreeGuestDomain(virCapsGuestDomainPtr dom) if (dom == NULL) return; - VIR_FREE(dom->info.emulator); - VIR_FREE(dom->info.loader); + g_free(dom->info.emulator); + g_free(dom->info.loader); for (i = 0; i < dom->info.nmachines; i++) virCapabilitiesFreeGuestMachine(dom->info.machines[i]); - VIR_FREE(dom->info.machines); + g_free(dom->info.machines); - VIR_FREE(dom); + g_free(dom); } void @@ -157,17 +157,17 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest) if (guest == NULL) return; - VIR_FREE(guest->arch.defaultInfo.emulator); - VIR_FREE(guest->arch.defaultInfo.loader); + g_free(guest->arch.defaultInfo.emulator); + g_free(guest->arch.defaultInfo.loader); for (i = 0; i < guest->arch.defaultInfo.nmachines; i++) virCapabilitiesFreeGuestMachine(guest->arch.defaultInfo.machines[i]); - VIR_FREE(guest->arch.defaultInfo.machines); + g_free(guest->arch.defaultInfo.machines); for (i = 0; i < guest->arch.ndomains; i++) virCapabilitiesFreeGuestDomain(guest->arch.domains[i]); - VIR_FREE(guest->arch.domains); + g_free(guest->arch.domains); - VIR_FREE(guest); + g_free(guest); } @@ -177,7 +177,7 @@ virCapabilitiesFreeStoragePool(virCapsStoragePoolPtr pool) if (!pool) return; - VIR_FREE(pool); + g_free(pool); } @@ -190,7 +190,7 @@ virCapabilitiesHostNUMAUnref(virCapsHostNUMAPtr caps) if (g_atomic_int_dec_and_test(&caps->refs)) { g_ptr_array_unref(caps->cells); - VIR_FREE(caps); + g_free(caps); } } @@ -409,7 +409,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines, virCapabilitiesFreeGuestMachine(machines[i]); machines[i] = NULL; } - VIR_FREE(machines); + g_free(machines); } /** -- 2.29.2

Signed-off-by: Laine Stump <laine@redhat.com> --- src/locking/lock_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c index db724eb30f..90ec5cdfbe 100644 --- a/src/locking/lock_manager.c +++ b/src/locking/lock_manager.c @@ -245,8 +245,8 @@ void virLockManagerPluginUnref(virLockManagerPluginPtr plugin) return; } - VIR_FREE(plugin->name); - VIR_FREE(plugin); + g_free(plugin->name); + g_free(plugin); } #else /* !WITH_DLFCN_H */ void virLockManagerPluginUnref(virLockManagerPluginPtr plugin G_GNUC_UNUSED) -- 2.29.2

Signed-off-by: Laine Stump <laine@redhat.com> --- src/openvz/openvz_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 1783dce233..041a031a3a 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -478,7 +478,7 @@ openvzFreeDriver(struct openvz_driver *driver) virObjectUnref(driver->xmlopt); virObjectUnref(driver->domains); virObjectUnref(driver->caps); - VIR_FREE(driver); + g_free(driver); } -- 2.29.2

Signed-off-by: Laine Stump <laine@redhat.com> --- src/remote/remote_daemon_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c index b4a3cb6741..57816eb10e 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -419,7 +419,7 @@ int daemonFreeClientStream(virNetServerClientPtr client, } virObjectUnref(stream->st); - VIR_FREE(stream); + g_free(stream); return ret; } -- 2.29.2

Signed-off-by: Laine Stump <laine@redhat.com> --- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 14d05cfe3b..13efdcbad1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -95,7 +95,7 @@ qemuJobFreePrivate(void *opaque) return; qemuMigrationParamsFree(priv->migParams); - VIR_FREE(priv); + g_free(priv); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 53ac3b0c17..58236f1ae2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17677,12 +17677,12 @@ qemuDomainFreeResctrlMonData(virQEMUResctrlMonDataPtr resdata) { size_t i = 0; - VIR_FREE(resdata->name); - VIR_FREE(resdata->vcpus); + g_free(resdata->name); + g_free(resdata->vcpus); for (i = 0; i < resdata->nstats; i++) virResctrlMonitorStatsFree(resdata->stats[i]); - VIR_FREE(resdata->stats); - VIR_FREE(resdata); + g_free(resdata->stats); + g_free(resdata); } -- 2.29.2

Signed-off-by: Laine Stump <laine@redhat.com> --- src/util/virconf.c | 4 ++-- src/util/virerror.c | 4 ++-- src/util/virobject.c | 2 +- src/util/virstring.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index d85fc32b64..16107bce96 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -151,11 +151,11 @@ virConfFreeValue(virConfValuePtr val) return; if (val->type == VIR_CONF_STRING && val->str != NULL) - VIR_FREE(val->str); + g_free(val->str); if (val->type == VIR_CONF_LIST && val->list != NULL) virConfFreeList(val->list); - VIR_FREE(val); + g_free(val); } virConfPtr diff --git a/src/util/virerror.c b/src/util/virerror.c index 14054add41..708081414a 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -158,7 +158,7 @@ virLastErrFreeData(void *data) if (!err) return; virResetError(err); - VIR_FREE(err); + g_free(err); } @@ -477,7 +477,7 @@ void virFreeError(virErrorPtr err) { virResetError(err); - VIR_FREE(err); + g_free(err); } /** diff --git a/src/util/virobject.c b/src/util/virobject.c index ce40ffae22..370a64bd6d 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -655,5 +655,5 @@ virObjectListFreeCount(void *list, for (i = 0; i < count; i++) virObjectUnref(((void **)list)[i]); - VIR_FREE(list); + g_free(list); } diff --git a/src/util/virstring.c b/src/util/virstring.c index c98435388a..c3e64007fe 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -108,9 +108,9 @@ virStringListFreeCount(char **strings, return; for (i = 0; i < count; i++) - VIR_FREE(strings[i]); + g_free(strings[i]); - VIR_FREE(strings); + g_free(strings); } -- 2.29.2

Signed-off-by: Laine Stump <laine@redhat.com> --- src/vmware/vmware_conf.c | 4 ++-- src/vmware/vmware_driver.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 55cd1d6f2d..f905962b85 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -56,8 +56,8 @@ vmwareFreeDriver(struct vmware_driver *driver) virObjectUnref(driver->domains); virObjectUnref(driver->caps); virObjectUnref(driver->xmlopt); - VIR_FREE(driver->vmrun); - VIR_FREE(driver); + g_free(driver->vmrun); + g_free(driver); } diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 481c59ef3c..5f1edeb7f5 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -110,8 +110,8 @@ vmwareDataFreeFunc(void *data) { vmwareDomainPtr dom = data; - VIR_FREE(dom->vmxPath); - VIR_FREE(dom); + g_free(dom->vmxPath); + g_free(dom); } static int -- 2.29.2

On 2/12/21 6:28 AM, Laine Stump wrote:
Only 90 this time. These are all functions that behave similar to the *Free() functions, but their names don't end in "Free" so I missed them last time.
Laine Stump (8): esx: replace VIR_FREE with g_free in any ESX_VI__TEMPLATE__FREE conf: convert VIR_FREE to g_free in other functions that free their arg locking: convert VIR_FREE to g_free in other functions that free their arg openvz: convert VIR_FREE to g_free in other functions that free their arg remote: convert VIR_FREE to g_free in other functions that free their arg qemu: convert VIR_FREE to g_free in other functions that free their arg util: convert VIR_FREE to g_free in other functions that free their arg vmware: convert VIR_FREE to g_free in other functions that free their arg
src/conf/capabilities.c | 38 +++++++++++++++---------------- src/esx/esx_vi.c | 18 +++++++-------- src/esx/esx_vi_types.c | 24 +++++++++---------- src/locking/lock_manager.c | 4 ++-- src/openvz/openvz_conf.c | 2 +- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 8 +++---- src/remote/remote_daemon_stream.c | 2 +- src/util/virconf.c | 4 ++-- src/util/virerror.c | 4 ++-- src/util/virobject.c | 2 +- src/util/virstring.c | 4 ++-- src/vmware/vmware_conf.c | 4 ++-- src/vmware/vmware_driver.c | 4 ++-- 14 files changed, 60 insertions(+), 60 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Laine Stump
-
Michal Privoznik