mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
maint: add more free-like functions to the list and deal with fallout
* cfg.mk (useless_free_options): Add many vir*Free* function names, and then remove the useless if-before-free tests exposed by running make syntax-check. * src/conf/interface_conf.c (virInterfaceDefFree): Remove useless "if". (virInterfaceAssignDef): Likewise. * src/conf/network_conf.c (virNetworkAssignDef): Likewise. * src/conf/storage_conf.c (virStoragePoolObjAssignDef): Likewise. * src/node_device/node_device_hal.c (dev_create): Likewise. * src/security/virt-aa-helper.c (vahDeinit): Likewise. * src/test/test_driver.c (testNodeDeviceCreateXML): Likewise. * src/util/conf.c (virConfSetValue): Likewise.
This commit is contained in:
parent
933522a341
commit
a986892e61
163
cfg.mk
163
cfg.mk
@ -64,15 +64,164 @@ local-checks-to-skip = \
|
|||||||
sc_makefile_check \
|
sc_makefile_check \
|
||||||
sc_useless_cpp_parens
|
sc_useless_cpp_parens
|
||||||
|
|
||||||
useless_free_options = \
|
useless_free_options = \
|
||||||
--name=sexpr_free \
|
--name=VIR_FREE \
|
||||||
--name=virCgroupFree \
|
--name=sexpr_free \
|
||||||
--name=VIR_FREE \
|
--name=virCPUDefFree \
|
||||||
--name=xmlFree \
|
--name=virCapabilitiesFree \
|
||||||
--name=xmlXPathFreeContext \
|
--name=virCapabilitiesFreeGuest \
|
||||||
--name=virDomainDefFree \
|
--name=virCapabilitiesFreeGuestDomain \
|
||||||
|
--name=virCapabilitiesFreeGuestFeature \
|
||||||
|
--name=virCapabilitiesFreeGuestMachine \
|
||||||
|
--name=virCapabilitiesFreeHostNUMACell \
|
||||||
|
--name=virCapabilitiesFreeMachines \
|
||||||
|
--name=virCgroupFree \
|
||||||
|
--name=virConfFreeList \
|
||||||
|
--name=virConfFreeValue \
|
||||||
|
--name=virDomainChrDefFree \
|
||||||
|
--name=virDomainControllerDefFree \
|
||||||
|
--name=virDomainDefFree \
|
||||||
|
--name=virDomainDeviceDefFree \
|
||||||
|
--name=virDomainDiskDefFree \
|
||||||
|
--name=virDomainEventCallbackListFree \
|
||||||
|
--name=virDomainEventFree \
|
||||||
|
--name=virDomainEventQueueFree \
|
||||||
|
--name=virDomainFSDefFree \
|
||||||
|
--name=virDomainGraphicsDefFree \
|
||||||
|
--name=virDomainHostdevDefFree \
|
||||||
|
--name=virDomainInputDefFree \
|
||||||
|
--name=virDomainNetDefFree \
|
||||||
|
--name=virDomainObjFree \
|
||||||
|
--name=virDomainSnapshotDefFree \
|
||||||
|
--name=virDomainSnapshotObjFree \
|
||||||
|
--name=virDomainSoundDefFree \
|
||||||
|
--name=virDomainVideoDefFree \
|
||||||
|
--name=virDomainWatchdogDefFree \
|
||||||
|
--name=virInterfaceDefFree \
|
||||||
|
--name=virInterfaceIpDefFree \
|
||||||
|
--name=virInterfaceObjFree \
|
||||||
|
--name=virInterfaceProtocolDefFree \
|
||||||
|
--name=virJSONValueFree \
|
||||||
|
--name=virLastErrFreeData \
|
||||||
|
--name=virNWFilterDefFree \
|
||||||
|
--name=virNWFilterEntryFree \
|
||||||
|
--name=virNWFilterHashTableFree \
|
||||||
|
--name=virNWFilterIPAddrLearnReqFree \
|
||||||
|
--name=virNWFilterIncludeDefFree \
|
||||||
|
--name=virNWFilterPoolObjFree \
|
||||||
|
--name=virNWFilterRuleDefFree \
|
||||||
|
--name=virNWFilterRuleInstFree \
|
||||||
|
--name=virNetworkDefFree \
|
||||||
|
--name=virNetworkObjFree \
|
||||||
|
--name=virNodeDeviceDefFree \
|
||||||
|
--name=virNodeDeviceObjFree \
|
||||||
|
--name=virSecretDefFree \
|
||||||
|
--name=virStorageEncryptionFree \
|
||||||
|
--name=virStorageEncryptionSecretFree \
|
||||||
|
--name=virStoragePoolDefFree \
|
||||||
|
--name=virStoragePoolObjFree \
|
||||||
|
--name=virStoragePoolSourceFree \
|
||||||
|
--name=virStorageVolDefFree \
|
||||||
|
--name=xmlFree \
|
||||||
|
--name=xmlXPathFreeContext \
|
||||||
--name=xmlXPathFreeObject
|
--name=xmlXPathFreeObject
|
||||||
|
|
||||||
|
# The following template was generated by this command:
|
||||||
|
# make ID && aid free|grep '^vi'|sed 's/ .*//;s/^/# /'
|
||||||
|
# N virBufferFreeAndReset
|
||||||
|
# y virCPUDefFree
|
||||||
|
# y virCapabilitiesFree
|
||||||
|
# y virCapabilitiesFreeGuest
|
||||||
|
# y virCapabilitiesFreeGuestDomain
|
||||||
|
# y virCapabilitiesFreeGuestFeature
|
||||||
|
# y virCapabilitiesFreeGuestMachine
|
||||||
|
# y virCapabilitiesFreeHostNUMACell
|
||||||
|
# y virCapabilitiesFreeMachines
|
||||||
|
# N virCapabilitiesFreeNUMAInfo FIXME
|
||||||
|
# y virCgroupFree
|
||||||
|
# N virConfFree (diagnoses the "error")
|
||||||
|
# y virConfFreeList
|
||||||
|
# y virConfFreeValue
|
||||||
|
# y virDomainChrDefFree
|
||||||
|
# y virDomainControllerDefFree
|
||||||
|
# y virDomainDefFree
|
||||||
|
# y virDomainDeviceDefFree
|
||||||
|
# y virDomainDiskDefFree
|
||||||
|
# y virDomainEventCallbackListFree
|
||||||
|
# y virDomainEventFree
|
||||||
|
# y virDomainEventQueueFree
|
||||||
|
# y virDomainFSDefFree
|
||||||
|
# n virDomainFree
|
||||||
|
# n virDomainFreeName (can't fix -- returns int)
|
||||||
|
# y virDomainGraphicsDefFree
|
||||||
|
# y virDomainHostdevDefFree
|
||||||
|
# y virDomainInputDefFree
|
||||||
|
# y virDomainNetDefFree
|
||||||
|
# y virDomainObjFree
|
||||||
|
# y virDomainSnapshotDefFree
|
||||||
|
# n virDomainSnapshotFree (returns int)
|
||||||
|
# n virDomainSnapshotFreeName (returns int)
|
||||||
|
# y virDomainSnapshotObjFree
|
||||||
|
# y virDomainSoundDefFree
|
||||||
|
# y virDomainVideoDefFree
|
||||||
|
# y virDomainWatchdogDefFree
|
||||||
|
# n virDrvNodeGetCellsFreeMemory (returns int)
|
||||||
|
# n virDrvNodeGetFreeMemory (returns long long)
|
||||||
|
# n virFree (dereferences param)
|
||||||
|
# n virFreeError
|
||||||
|
# n virHashFree (takes 2 args)
|
||||||
|
# y virInterfaceDefFree
|
||||||
|
# n virInterfaceFree (returns int)
|
||||||
|
# n virInterfaceFreeName
|
||||||
|
# y virInterfaceIpDefFree
|
||||||
|
# y virInterfaceObjFree
|
||||||
|
# n virInterfaceObjListFree
|
||||||
|
# y virInterfaceProtocolDefFree
|
||||||
|
# y virJSONValueFree
|
||||||
|
# y virLastErrFreeData
|
||||||
|
# y virNWFilterDefFree
|
||||||
|
# y virNWFilterEntryFree
|
||||||
|
# n virNWFilterFree (returns int)
|
||||||
|
# y virNWFilterHashTableFree
|
||||||
|
# y virNWFilterIPAddrLearnReqFree
|
||||||
|
# y virNWFilterIncludeDefFree
|
||||||
|
# n virNWFilterPoolFreeName (returns int)
|
||||||
|
# y virNWFilterPoolObjFree
|
||||||
|
# n virNWFilterPoolObjListFree FIXME
|
||||||
|
# y virNWFilterRuleDefFree
|
||||||
|
# n virNWFilterRuleFreeInstanceData (typedef)
|
||||||
|
# y virNWFilterRuleInstFree
|
||||||
|
# y virNetworkDefFree
|
||||||
|
# n virNetworkFree (returns int)
|
||||||
|
# n virNetworkFreeName (returns int)
|
||||||
|
# y virNetworkObjFree
|
||||||
|
# n virNetworkObjListFree FIXME
|
||||||
|
# n virNodeDevCapsDefFree FIXME
|
||||||
|
# y virNodeDeviceDefFree
|
||||||
|
# n virNodeDeviceFree (returns int)
|
||||||
|
# y virNodeDeviceObjFree
|
||||||
|
# n virNodeDeviceObjListFree FIXME
|
||||||
|
# n virNodeGetCellsFreeMemory (returns int)
|
||||||
|
# n virNodeGetFreeMemory (returns non-void)
|
||||||
|
# y virSecretDefFree
|
||||||
|
# n virSecretFree (returns non-void)
|
||||||
|
# n virSecretFreeName (2 args)
|
||||||
|
# n virSecurityLabelDefFree FIXME
|
||||||
|
# n virStorageBackendDiskMakeFreeExtent (returns non-void)
|
||||||
|
# y virStorageEncryptionFree
|
||||||
|
# y virStorageEncryptionSecretFree
|
||||||
|
# n virStorageFreeType (enum)
|
||||||
|
# y virStoragePoolDefFree
|
||||||
|
# n virStoragePoolFree (returns non-void)
|
||||||
|
# n virStoragePoolFreeName (returns non-void)
|
||||||
|
# y virStoragePoolObjFree
|
||||||
|
# n virStoragePoolObjListFree FIXME
|
||||||
|
# y virStoragePoolSourceFree
|
||||||
|
# y virStorageVolDefFree
|
||||||
|
# n virStorageVolFree (returns non-void)
|
||||||
|
# n virStorageVolFreeName (returns non-void)
|
||||||
|
# n virStreamFree
|
||||||
|
|
||||||
# Avoid uses of write(2). Either switch to streams (fwrite), or use
|
# Avoid uses of write(2). Either switch to streams (fwrite), or use
|
||||||
# the safewrite wrapper.
|
# the safewrite wrapper.
|
||||||
sc_avoid_write:
|
sc_avoid_write:
|
||||||
|
@ -85,20 +85,18 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
|
|||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VIR_INTERFACE_TYPE_BRIDGE:
|
case VIR_INTERFACE_TYPE_BRIDGE:
|
||||||
for (i = 0;i < def->data.bridge.nbItf;i++) {
|
for (i = 0;i < def->data.bridge.nbItf;i++) {
|
||||||
if (def->data.bridge.itf[i] != NULL)
|
if (def->data.bridge.itf[i] == NULL)
|
||||||
virInterfaceDefFree(def->data.bridge.itf[i]);
|
|
||||||
else
|
|
||||||
break; /* to cope with half parsed data on errors */
|
break; /* to cope with half parsed data on errors */
|
||||||
|
virInterfaceDefFree(def->data.bridge.itf[i]);
|
||||||
}
|
}
|
||||||
VIR_FREE(def->data.bridge.itf);
|
VIR_FREE(def->data.bridge.itf);
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_BOND:
|
case VIR_INTERFACE_TYPE_BOND:
|
||||||
VIR_FREE(def->data.bond.target);
|
VIR_FREE(def->data.bond.target);
|
||||||
for (i = 0;i < def->data.bond.nbItf;i++) {
|
for (i = 0;i < def->data.bond.nbItf;i++) {
|
||||||
if (def->data.bond.itf[i] != NULL)
|
if (def->data.bond.itf[i] == NULL)
|
||||||
virInterfaceDefFree(def->data.bond.itf[i]);
|
|
||||||
else
|
|
||||||
break; /* to cope with half parsed data on errors */
|
break; /* to cope with half parsed data on errors */
|
||||||
|
virInterfaceDefFree(def->data.bond.itf[i]);
|
||||||
}
|
}
|
||||||
VIR_FREE(def->data.bond.itf);
|
VIR_FREE(def->data.bond.itf);
|
||||||
break;
|
break;
|
||||||
@ -1227,8 +1225,7 @@ virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces,
|
|||||||
virInterfaceObjPtr iface;
|
virInterfaceObjPtr iface;
|
||||||
|
|
||||||
if ((iface = virInterfaceFindByName(interfaces, def->name))) {
|
if ((iface = virInterfaceFindByName(interfaces, def->name))) {
|
||||||
if (iface->def)
|
virInterfaceDefFree(iface->def);
|
||||||
virInterfaceDefFree(iface->def);
|
|
||||||
iface->def = def;
|
iface->def = def;
|
||||||
|
|
||||||
return iface;
|
return iface;
|
||||||
|
@ -157,8 +157,7 @@ virNetworkObjPtr virNetworkAssignDef(virNetworkObjListPtr nets,
|
|||||||
virNetworkDefFree(network->def);
|
virNetworkDefFree(network->def);
|
||||||
network->def = def;
|
network->def = def;
|
||||||
} else {
|
} else {
|
||||||
if (network->newDef)
|
virNetworkDefFree(network->newDef);
|
||||||
virNetworkDefFree(network->newDef);
|
|
||||||
network->newDef = def;
|
network->newDef = def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,8 +1332,7 @@ virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
|
|||||||
virStoragePoolDefFree(pool->def);
|
virStoragePoolDefFree(pool->def);
|
||||||
pool->def = def;
|
pool->def = def;
|
||||||
} else {
|
} else {
|
||||||
if (pool->newDef)
|
virStoragePoolDefFree(pool->newDef);
|
||||||
virStoragePoolDefFree(pool->newDef);
|
|
||||||
pool->newDef = def;
|
pool->newDef = def;
|
||||||
}
|
}
|
||||||
return pool;
|
return pool;
|
||||||
|
@ -486,8 +486,7 @@ static void dev_create(const char *udi)
|
|||||||
DEBUG("FAILED TO ADD dev %s", name);
|
DEBUG("FAILED TO ADD dev %s", name);
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(privData);
|
VIR_FREE(privData);
|
||||||
if (def)
|
virNodeDeviceDefFree(def);
|
||||||
virNodeDeviceDefFree(def);
|
|
||||||
nodeDeviceUnlock(driverState);
|
nodeDeviceUnlock(driverState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +63,7 @@ vahDeinit(vahControl * ctl)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VIR_FREE(ctl->def);
|
VIR_FREE(ctl->def);
|
||||||
if (ctl->caps)
|
virCapabilitiesFree(ctl->caps);
|
||||||
virCapabilitiesFree(ctl->caps);
|
|
||||||
VIR_FREE(ctl->files);
|
VIR_FREE(ctl->files);
|
||||||
VIR_FREE(ctl->hvm);
|
VIR_FREE(ctl->hvm);
|
||||||
VIR_FREE(ctl->arch);
|
VIR_FREE(ctl->arch);
|
||||||
|
@ -4983,8 +4983,7 @@ testNodeDeviceCreateXML(virConnectPtr conn,
|
|||||||
def = NULL;
|
def = NULL;
|
||||||
cleanup:
|
cleanup:
|
||||||
testDriverUnlock(driver);
|
testDriverUnlock(driver);
|
||||||
if (def)
|
virNodeDeviceDefFree(def);
|
||||||
virNodeDeviceDefFree(def);
|
|
||||||
VIR_FREE(wwnn);
|
VIR_FREE(wwnn);
|
||||||
VIR_FREE(wwpn);
|
VIR_FREE(wwpn);
|
||||||
return dev;
|
return dev;
|
||||||
|
@ -902,9 +902,7 @@ virConfSetValue (virConfPtr conf,
|
|||||||
conf->entries = cur;
|
conf->entries = cur;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cur->value) {
|
virConfFreeValue(cur->value);
|
||||||
virConfFreeValue(cur->value);
|
|
||||||
}
|
|
||||||
cur->value = value;
|
cur->value = value;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user