diff options
author | Michal Privoznik <mprivozn@redhat.com> | 2022-01-28 18:42:45 +0100 |
---|---|---|
committer | Michal Privoznik <mprivozn@redhat.com> | 2022-02-08 08:42:07 +0100 |
commit | 87a43a907f0ad4897a28ad7c216bc70f37270b93 (patch) | |
tree | 77becc044a219aed11f5522edb39fc8aa3cd66ae /src/libxl | |
parent | 1688d2527f1ae34d57d0b5c01fbea79e40dac7b7 (diff) | |
download | libvirt-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/libxl')
-rw-r--r-- | src/libxl/libxl_capabilities.c | 3 | ||||
-rw-r--r-- | src/libxl/libxl_migration.c | 6 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 970ad37306..6c7dfcb15e 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -305,8 +305,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps) for (i = 0; cpus && i < nr_nodes; i++) VIR_FREE(cpus[i]); if (caps->host.numa) { - virCapabilitiesHostNUMAUnref(caps->host.numa); - caps->host.numa = NULL; + g_clear_pointer(&caps->host.numa, virCapabilitiesHostNUMAUnref); } VIR_FREE(distances); } diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index bc2b5401da..6944c77eed 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -262,8 +262,7 @@ libxlDoMigrateDstReceive(void *opaque) for (i = 0; i < nsocks; i++) { virNetSocketRemoveIOCallback(socks[i]); virNetSocketClose(socks[i]); - virObjectUnref(socks[i]); - socks[i] = NULL; + g_clear_pointer(&socks[i], virObjectUnref); } args->nsocks = 0; VIR_FORCE_CLOSE(recvfd); @@ -323,8 +322,7 @@ libxlMigrateDstReceive(virNetSocket *sock, for (i = 0; i < nsocks; i++) { virNetSocketUpdateIOCallback(socks[i], 0); virNetSocketRemoveIOCallback(socks[i]); - virNetSocketClose(socks[i]); - socks[i] = NULL; + g_clear_pointer(&socks[i], virNetSocketClose); } args->nsocks = 0; VIR_FORCE_CLOSE(recvfd); |