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

@@ -1740,8 +1740,7 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
remove_entry:
/* the domain has to be removed as it failed one of the filters */
virshDomainFree(list->domains[i]);
list->domains[i] = NULL;
g_clear_pointer(&list->domains[i], virshDomainFree);
deleted++;
}
@@ -1762,8 +1761,7 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
VIR_FREE(names[i]);
if (!success) {
virshDomainListFree(list);
list = NULL;
g_clear_pointer(&list, virshDomainListFree);
}
VIR_FREE(names);