summaryrefslogtreecommitdiff
path: root/src/ch
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2022-01-28 18:42:45 +0100
committerMichal Privoznik <mprivozn@redhat.com>2022-02-08 08:42:07 +0100
commit87a43a907f0ad4897a28ad7c216bc70f37270b93 (patch)
tree77becc044a219aed11f5522edb39fc8aa3cd66ae /src/ch
parent1688d2527f1ae34d57d0b5c01fbea79e40dac7b7 (diff)
downloadlibvirt-87a43a907f0ad4897a28ad7c216bc70f37270b93.tar.gz
lib: Use g_clear_pointer() more
This change was generated using the following spatch: @ rule1 @ expression a; identifier f; @@ <... - f(*a); ... when != a; - *a = NULL; + g_clear_pointer(a, f); ...> @ rule2 @ expression a; identifier f; @@ <... - f(a); ... when != a; - a = NULL; + g_clear_pointer(&a, f); ...> Then, I left some of the changes out, like tools/nss/ (which doesn't link with glib) and put back a comment in qemuBlockJobProcessEventCompletedActiveCommit() which coccinelle decided to remove (I have no idea why). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
Diffstat (limited to 'src/ch')
-rw-r--r--src/ch/ch_driver.c6
-rw-r--r--src/ch/ch_process.c3
2 files changed, 3 insertions, 6 deletions
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
index 3223f31367..e751ddba19 100644
--- a/src/ch/ch_driver.c
+++ b/src/ch/ch_driver.c
@@ -871,8 +871,7 @@ static int chStateCleanup(void)
virObjectUnref(ch_driver->caps);
virObjectUnref(ch_driver->config);
virMutexDestroy(&ch_driver->lock);
- g_free(ch_driver);
- ch_driver = NULL;
+ g_clear_pointer(&ch_driver, g_free);
return 0;
}
@@ -1401,8 +1400,7 @@ chDomainPinEmulator(virDomainPtr dom,
if (virProcessSetAffinity(vm->pid, pcpumap, false) < 0)
goto endjob;
- virBitmapFree(def->cputune.emulatorpin);
- def->cputune.emulatorpin = NULL;
+ g_clear_pointer(&def->cputune.emulatorpin, virBitmapFree);
if (!(def->cputune.emulatorpin = virBitmapNewCopy(pcpumap)))
goto endjob;
diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c
index e4313d1008..6d9a286e8a 100644
--- a/src/ch/ch_process.c
+++ b/src/ch/ch_process.c
@@ -553,8 +553,7 @@ virCHProcessStop(virCHDriver *driver G_GNUC_UNUSED,
vm->def->name, (int)vm->pid, (int)reason);
if (priv->monitor) {
- virCHMonitorClose(priv->monitor);
- priv->monitor = NULL;
+ g_clear_pointer(&priv->monitor, virCHMonitorClose);
}
retry: