mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
don't check for NULL before calling virHashFree
virHashFree follows the convention described in HACKING that XXXFree() functions can be called with a NULL argument.
This commit is contained in:
parent
9905c69e4f
commit
7b9a509953
@ -410,8 +410,7 @@ static void virDomainObjListDeallocator(void *payload, const char *name ATTRIBUT
|
||||
|
||||
void virDomainObjListDeinit(virDomainObjListPtr doms)
|
||||
{
|
||||
if (doms->objs)
|
||||
virHashFree(doms->objs, virDomainObjListDeallocator);
|
||||
virHashFree(doms->objs, virDomainObjListDeallocator);
|
||||
}
|
||||
|
||||
|
||||
@ -8770,8 +8769,7 @@ static void virDomainSnapshotObjListDeallocator(void *payload,
|
||||
|
||||
static void virDomainSnapshotObjListDeinit(virDomainSnapshotObjListPtr snapshots)
|
||||
{
|
||||
if (snapshots->objs)
|
||||
virHashFree(snapshots->objs, virDomainSnapshotObjListDeallocator);
|
||||
virHashFree(snapshots->objs, virDomainSnapshotObjListDeallocator);
|
||||
}
|
||||
|
||||
struct virDomainSnapshotNameData {
|
||||
|
@ -209,22 +209,14 @@ virGetConnect(void) {
|
||||
|
||||
failed:
|
||||
if (ret != NULL) {
|
||||
if (ret->domains != NULL)
|
||||
virHashFree(ret->domains, (virHashDeallocator) virDomainFreeName);
|
||||
if (ret->networks != NULL)
|
||||
virHashFree(ret->networks, (virHashDeallocator) virNetworkFreeName);
|
||||
if (ret->interfaces != NULL)
|
||||
virHashFree(ret->interfaces, (virHashDeallocator) virInterfaceFreeName);
|
||||
if (ret->storagePools != NULL)
|
||||
virHashFree(ret->storagePools, (virHashDeallocator) virStoragePoolFreeName);
|
||||
if (ret->storageVols != NULL)
|
||||
virHashFree(ret->storageVols, (virHashDeallocator) virStorageVolFreeName);
|
||||
if (ret->nodeDevices != NULL)
|
||||
virHashFree(ret->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
|
||||
if (ret->secrets != NULL)
|
||||
virHashFree(ret->secrets, (virHashDeallocator) virSecretFreeName);
|
||||
if (ret->nwfilters != NULL)
|
||||
virHashFree(ret->nwfilters, (virHashDeallocator) virNWFilterFreeName);
|
||||
virHashFree(ret->domains, (virHashDeallocator) virDomainFreeName);
|
||||
virHashFree(ret->networks, (virHashDeallocator) virNetworkFreeName);
|
||||
virHashFree(ret->interfaces, (virHashDeallocator) virInterfaceFreeName);
|
||||
virHashFree(ret->storagePools, (virHashDeallocator) virStoragePoolFreeName);
|
||||
virHashFree(ret->storageVols, (virHashDeallocator) virStorageVolFreeName);
|
||||
virHashFree(ret->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
|
||||
virHashFree(ret->secrets, (virHashDeallocator) virSecretFreeName);
|
||||
virHashFree(ret->nwfilters, (virHashDeallocator) virNWFilterFreeName);
|
||||
|
||||
virMutexDestroy(&ret->lock);
|
||||
VIR_FREE(ret);
|
||||
@ -267,22 +259,14 @@ virReleaseConnect(virConnectPtr conn) {
|
||||
|
||||
virMutexLock(&conn->lock);
|
||||
|
||||
if (conn->domains != NULL)
|
||||
virHashFree(conn->domains, (virHashDeallocator) virDomainFreeName);
|
||||
if (conn->networks != NULL)
|
||||
virHashFree(conn->networks, (virHashDeallocator) virNetworkFreeName);
|
||||
if (conn->interfaces != NULL)
|
||||
virHashFree(conn->interfaces, (virHashDeallocator) virInterfaceFreeName);
|
||||
if (conn->storagePools != NULL)
|
||||
virHashFree(conn->storagePools, (virHashDeallocator) virStoragePoolFreeName);
|
||||
if (conn->storageVols != NULL)
|
||||
virHashFree(conn->storageVols, (virHashDeallocator) virStorageVolFreeName);
|
||||
if (conn->nodeDevices != NULL)
|
||||
virHashFree(conn->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
|
||||
if (conn->secrets != NULL)
|
||||
virHashFree(conn->secrets, (virHashDeallocator) virSecretFreeName);
|
||||
if (conn->nwfilters != NULL)
|
||||
virHashFree(conn->nwfilters, (virHashDeallocator) virNWFilterFreeName);
|
||||
virHashFree(conn->domains, (virHashDeallocator) virDomainFreeName);
|
||||
virHashFree(conn->networks, (virHashDeallocator) virNetworkFreeName);
|
||||
virHashFree(conn->interfaces, (virHashDeallocator) virInterfaceFreeName);
|
||||
virHashFree(conn->storagePools, (virHashDeallocator) virStoragePoolFreeName);
|
||||
virHashFree(conn->storageVols, (virHashDeallocator) virStorageVolFreeName);
|
||||
virHashFree(conn->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
|
||||
virHashFree(conn->secrets, (virHashDeallocator) virSecretFreeName);
|
||||
virHashFree(conn->nwfilters, (virHashDeallocator) virNWFilterFreeName);
|
||||
|
||||
virResetError(&conn->err);
|
||||
|
||||
@ -435,8 +419,7 @@ virReleaseDomain(virDomainPtr domain) {
|
||||
domain->magic = -1;
|
||||
domain->id = -1;
|
||||
VIR_FREE(domain->name);
|
||||
if (domain->snapshots != NULL)
|
||||
virHashFree(domain->snapshots, (virHashDeallocator) virDomainSnapshotFreeName);
|
||||
virHashFree(domain->snapshots, (virHashDeallocator) virDomainSnapshotFreeName);
|
||||
VIR_FREE(domain);
|
||||
|
||||
if (conn) {
|
||||
|
@ -1008,9 +1008,7 @@ qemuProcessWaitForMonitor(struct qemud_driver* driver,
|
||||
ret = qemuProcessFindCharDevicePTYsMonitor(vm, paths);
|
||||
|
||||
cleanup:
|
||||
if (paths) {
|
||||
virHashFree(paths, qemuProcessFreePtyPath);
|
||||
}
|
||||
virHashFree(paths, qemuProcessFreePtyPath);
|
||||
|
||||
if (kill(vm->pid, 0) == -1 && errno == ESRCH) {
|
||||
/* VM is dead, any other error raised in the interim is probably
|
||||
|
Loading…
Reference in New Issue
Block a user