Using a doulble pointer prevents the function from being used as the
automatic cleanup function for the given type.
Remove the double pointer use by replacing the calls with
g_clear_pointer which ensures that the pointer is cleared.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 30 +++++++++++++-----------------
src/qemu/qemu_domain.h | 2 +-
src/qemu/qemu_migration_params.c | 2 +-
3 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 33c2158eb5..bd32949e9b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1099,14 +1099,10 @@ qemuDomainSecretInfoClear(qemuDomainSecretInfoPtr secinfo,
void
-qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
+qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr secinfo)
{
- if (!*secinfo)
- return;
-
- qemuDomainSecretInfoClear(*secinfo, false);
-
- VIR_FREE(*secinfo);
+ qemuDomainSecretInfoClear(secinfo, false);
+ g_free(secinfo);
}
@@ -1196,8 +1192,8 @@ qemuDomainStorageSourcePrivateDispose(void *obj)
{
qemuDomainStorageSourcePrivatePtr priv = obj;
- qemuDomainSecretInfoFree(&priv->secinfo);
- qemuDomainSecretInfoFree(&priv->encinfo);
+ g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
+ g_clear_pointer(&priv->encinfo, qemuDomainSecretInfoFree);
}
@@ -1276,7 +1272,7 @@ qemuDomainChrSourcePrivateDispose(void *obj)
{
qemuDomainChrSourcePrivatePtr priv = obj;
- qemuDomainSecretInfoFree(&priv->secinfo);
+ g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
}
@@ -1355,7 +1351,7 @@ qemuDomainGraphicsPrivateDispose(void *obj)
qemuDomainGraphicsPrivatePtr priv = obj;
VIR_FREE(priv->tlsAlias);
- qemuDomainSecretInfoFree(&priv->secinfo);
+ g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
}
@@ -1631,7 +1627,7 @@ qemuDomainSecretInfoNewPlain(virSecretUsageType usageType,
return NULL;
if (qemuDomainSecretPlainSetup(secinfo, usageType, username, lookupDef) < 0) {
- qemuDomainSecretInfoFree(&secinfo);
+ g_clear_pointer(&secinfo, qemuDomainSecretInfoFree);
return NULL;
}
@@ -1674,7 +1670,7 @@ qemuDomainSecretInfoNew(qemuDomainObjPrivatePtr priv,
if (qemuDomainSecretAESSetup(priv, secinfo, srcAlias, usageType, username,
lookupDef, isLuks) < 0) {
- qemuDomainSecretInfoFree(&secinfo);
+ g_clear_pointer(&secinfo, qemuDomainSecretInfoFree);
return NULL;
}
@@ -1836,7 +1832,7 @@ qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr hostdev)
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
if (srcPriv && srcPriv->secinfo)
- qemuDomainSecretInfoFree(&srcPriv->secinfo);
+ g_clear_pointer(&srcPriv->secinfo, qemuDomainSecretInfoFree);
}
}
}
@@ -1880,7 +1876,7 @@ qemuDomainSecretChardevDestroy(virDomainChrSourceDefPtr dev)
if (!chrSourcePriv || !chrSourcePriv->secinfo)
return;
- qemuDomainSecretInfoFree(&chrSourcePriv->secinfo);
+ g_clear_pointer(&chrSourcePriv->secinfo, qemuDomainSecretInfoFree);
}
@@ -1935,7 +1931,7 @@ qemuDomainSecretGraphicsDestroy(virDomainGraphicsDefPtr graphics)
return;
VIR_FREE(gfxPriv->tlsAlias);
- qemuDomainSecretInfoFree(&gfxPriv->secinfo);
+ g_clear_pointer(&gfxPriv->secinfo, qemuDomainSecretInfoFree);
}
@@ -2283,7 +2279,7 @@ qemuDomainObjPrivateFree(void *data)
}
VIR_FREE(priv->cleanupCallbacks);
- qemuDomainSecretInfoFree(&priv->migSecinfo);
+ g_clear_pointer(&priv->migSecinfo, qemuDomainSecretInfoFree);
qemuDomainMasterKeyFree(priv);
virHashFree(priv->blockjobs);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 476056c73f..10d6264e46 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1032,7 +1032,7 @@ void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);
bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv);
-void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
+void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr secinfo)
ATTRIBUTE_NONNULL(1);
void qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo);
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index a92bb2fa2b..a36c6a4aea 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -1086,7 +1086,7 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE, false);
qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
- qemuDomainSecretInfoFree(&QEMU_DOMAIN_PRIVATE(vm)->migSecinfo);
+ g_clear_pointer(&QEMU_DOMAIN_PRIVATE(vm)->migSecinfo,
qemuDomainSecretInfoFree);
VIR_FREE(tlsAlias);
VIR_FREE(secAlias);
--
2.24.1