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 committed 2022-02-08 08:42:07 +01:00
1 parent 1688d2527f
commit 87a43a907f
100 files changed
+252 -501

No files matched your search

+2 -4
View File
@@ -446,8 +446,7 @@ static int test13(const void *unused G_GNUC_UNUSED)
if (!outactual)
goto cleanup;
virCommandFree(cmd);
cmd = NULL;
g_clear_pointer(&cmd, virCommandFree);
if (STRNEQ(outactual, outexpect)) {
virTestDifference(stderr, outexpect, outactual);
@@ -668,8 +667,7 @@ static int test18(const void *unused G_GNUC_UNUSED)
goto cleanup;
}
virCommandFree(cmd);
cmd = NULL;
g_clear_pointer(&cmd, virCommandFree);
if (kill(pid, 0) != 0) {
printf("daemon should still be running\n");
goto cleanup;