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>
This commit is contained in:
Michal Privoznik
2022-01-28 18:42:45 +01:00
parent 1688d2527f
commit 87a43a907f
100 changed files with 252 additions and 501 deletions

View File

@@ -171,8 +171,7 @@ testUSBList(const void *opaque G_GNUC_UNUSED)
dev = NULL;
}
virObjectUnref(devlist);
devlist = NULL;
g_clear_pointer(&devlist, virObjectUnref);
ndevs = virUSBDeviceListCount(list);
if (testCheckNdevs("After first loop", ndevs, EXPECTED_NDEVS_ONE) < 0)
@@ -210,8 +209,7 @@ testUSBList(const void *opaque G_GNUC_UNUSED)
}
virUSBDeviceListDel(list, dev);
virUSBDeviceFree(dev);
dev = NULL;
g_clear_pointer(&dev, virUSBDeviceFree);
if (testCheckNdevs("After deleting one",
virUSBDeviceListCount(list),