]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: dnsmasq: convert pointers to use g_autofree
authorBarrett Schonefeld <bschoney@utexas.edu>
Mon, 23 Nov 2020 22:09:39 +0000 (16:09 -0600)
committerJán Tomko <jtomko@redhat.com>
Tue, 24 Nov 2020 13:17:08 +0000 (14:17 +0100)
Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/util/virdnsmasq.c

index 9030f9218ad2a1523317df882356e3e02dadd069..5f477c976d20ea3813d53d722733241aaabca6e4 100644 (file)
@@ -164,7 +164,7 @@ addnhostsWrite(const char *path,
                dnsmasqAddnHost *hosts,
                unsigned int nhosts)
 {
-    char *tmp;
+    g_autofree char *tmp = NULL;
     FILE *f;
     bool istmp = true;
     size_t i, j;
@@ -230,8 +230,6 @@ addnhostsWrite(const char *path,
     }
 
  cleanup:
-    VIR_FREE(tmp);
-
     return rc;
 }
 
@@ -364,7 +362,7 @@ hostsfileWrite(const char *path,
                dnsmasqDhcpHost *hosts,
                unsigned int nhosts)
 {
-    char *tmp;
+    g_autofree char *tmp = NULL;
     FILE *f;
     bool istmp = true;
     size_t i;
@@ -408,8 +406,6 @@ hostsfileWrite(const char *path,
     }
 
  cleanup:
-    VIR_FREE(tmp);
-
     return rc;
 }
 
@@ -686,7 +682,7 @@ static int
 dnsmasqCapsSetFromFile(dnsmasqCapsPtr caps, const char *path)
 {
     int ret = -1;
-    char *buf = NULL;
+    g_autofree char *buf = NULL;
 
     if (virFileReadAll(path, 1024 * 1024, &buf) < 0)
         goto cleanup;
@@ -694,7 +690,6 @@ dnsmasqCapsSetFromFile(dnsmasqCapsPtr caps, const char *path)
     ret = dnsmasqCapsSetFromBuffer(caps, buf);
 
  cleanup:
-    VIR_FREE(buf);
     return ret;
 }
 
@@ -704,7 +699,9 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
     int ret = -1;
     struct stat sb;
     virCommandPtr cmd = NULL;
-    char *help = NULL, *version = NULL, *complete = NULL;
+    g_autofree char *help = NULL;
+    g_autofree char *version = NULL;
+    g_autofree char *complete = NULL;
 
     if (!caps || caps->noRefresh)
         return 0;
@@ -749,9 +746,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
 
  cleanup:
     virCommandFree(cmd);
-    VIR_FREE(help);
-    VIR_FREE(version);
-    VIR_FREE(complete);
     return ret;
 }