提交 7b9a5099 编写于 作者: C Christophe Fergeau 提交者: Eric Blake

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.
上级 9905c69e
...@@ -410,8 +410,7 @@ static void virDomainObjListDeallocator(void *payload, const char *name ATTRIBUT ...@@ -410,8 +410,7 @@ static void virDomainObjListDeallocator(void *payload, const char *name ATTRIBUT
void virDomainObjListDeinit(virDomainObjListPtr doms) void virDomainObjListDeinit(virDomainObjListPtr doms)
{ {
if (doms->objs) virHashFree(doms->objs, virDomainObjListDeallocator);
virHashFree(doms->objs, virDomainObjListDeallocator);
} }
...@@ -8770,8 +8769,7 @@ static void virDomainSnapshotObjListDeallocator(void *payload, ...@@ -8770,8 +8769,7 @@ static void virDomainSnapshotObjListDeallocator(void *payload,
static void virDomainSnapshotObjListDeinit(virDomainSnapshotObjListPtr snapshots) static void virDomainSnapshotObjListDeinit(virDomainSnapshotObjListPtr snapshots)
{ {
if (snapshots->objs) virHashFree(snapshots->objs, virDomainSnapshotObjListDeallocator);
virHashFree(snapshots->objs, virDomainSnapshotObjListDeallocator);
} }
struct virDomainSnapshotNameData { struct virDomainSnapshotNameData {
......
...@@ -209,22 +209,14 @@ virGetConnect(void) { ...@@ -209,22 +209,14 @@ virGetConnect(void) {
failed: failed:
if (ret != NULL) { if (ret != NULL) {
if (ret->domains != NULL) virHashFree(ret->domains, (virHashDeallocator) virDomainFreeName);
virHashFree(ret->domains, (virHashDeallocator) virDomainFreeName); virHashFree(ret->networks, (virHashDeallocator) virNetworkFreeName);
if (ret->networks != NULL) virHashFree(ret->interfaces, (virHashDeallocator) virInterfaceFreeName);
virHashFree(ret->networks, (virHashDeallocator) virNetworkFreeName); virHashFree(ret->storagePools, (virHashDeallocator) virStoragePoolFreeName);
if (ret->interfaces != NULL) virHashFree(ret->storageVols, (virHashDeallocator) virStorageVolFreeName);
virHashFree(ret->interfaces, (virHashDeallocator) virInterfaceFreeName); virHashFree(ret->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
if (ret->storagePools != NULL) virHashFree(ret->secrets, (virHashDeallocator) virSecretFreeName);
virHashFree(ret->storagePools, (virHashDeallocator) virStoragePoolFreeName); virHashFree(ret->nwfilters, (virHashDeallocator) virNWFilterFreeName);
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);
virMutexDestroy(&ret->lock); virMutexDestroy(&ret->lock);
VIR_FREE(ret); VIR_FREE(ret);
...@@ -267,22 +259,14 @@ virReleaseConnect(virConnectPtr conn) { ...@@ -267,22 +259,14 @@ virReleaseConnect(virConnectPtr conn) {
virMutexLock(&conn->lock); virMutexLock(&conn->lock);
if (conn->domains != NULL) virHashFree(conn->domains, (virHashDeallocator) virDomainFreeName);
virHashFree(conn->domains, (virHashDeallocator) virDomainFreeName); virHashFree(conn->networks, (virHashDeallocator) virNetworkFreeName);
if (conn->networks != NULL) virHashFree(conn->interfaces, (virHashDeallocator) virInterfaceFreeName);
virHashFree(conn->networks, (virHashDeallocator) virNetworkFreeName); virHashFree(conn->storagePools, (virHashDeallocator) virStoragePoolFreeName);
if (conn->interfaces != NULL) virHashFree(conn->storageVols, (virHashDeallocator) virStorageVolFreeName);
virHashFree(conn->interfaces, (virHashDeallocator) virInterfaceFreeName); virHashFree(conn->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
if (conn->storagePools != NULL) virHashFree(conn->secrets, (virHashDeallocator) virSecretFreeName);
virHashFree(conn->storagePools, (virHashDeallocator) virStoragePoolFreeName); virHashFree(conn->nwfilters, (virHashDeallocator) virNWFilterFreeName);
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);
virResetError(&conn->err); virResetError(&conn->err);
...@@ -435,8 +419,7 @@ virReleaseDomain(virDomainPtr domain) { ...@@ -435,8 +419,7 @@ virReleaseDomain(virDomainPtr domain) {
domain->magic = -1; domain->magic = -1;
domain->id = -1; domain->id = -1;
VIR_FREE(domain->name); VIR_FREE(domain->name);
if (domain->snapshots != NULL) virHashFree(domain->snapshots, (virHashDeallocator) virDomainSnapshotFreeName);
virHashFree(domain->snapshots, (virHashDeallocator) virDomainSnapshotFreeName);
VIR_FREE(domain); VIR_FREE(domain);
if (conn) { if (conn) {
......
...@@ -1008,9 +1008,7 @@ qemuProcessWaitForMonitor(struct qemud_driver* driver, ...@@ -1008,9 +1008,7 @@ qemuProcessWaitForMonitor(struct qemud_driver* driver,
ret = qemuProcessFindCharDevicePTYsMonitor(vm, paths); ret = qemuProcessFindCharDevicePTYsMonitor(vm, paths);
cleanup: cleanup:
if (paths) { virHashFree(paths, qemuProcessFreePtyPath);
virHashFree(paths, qemuProcessFreePtyPath);
}
if (kill(vm->pid, 0) == -1 && errno == ESRCH) { if (kill(vm->pid, 0) == -1 && errno == ESRCH) {
/* VM is dead, any other error raised in the interim is probably /* VM is dead, any other error raised in the interim is probably
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册