From 20aee6203be0190860b775b1b30f43042b830cf5 Mon Sep 17 00:00:00 2001 From: Barrett Schonefeld Date: Mon, 23 Nov 2020 16:09:39 -0600 Subject: [PATCH] util: dnsmasq: convert pointers to use g_autofree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Barrett Schonefeld Reviewed-by: Ján Tomko Signed-off-by: Ján Tomko --- src/util/virdnsmasq.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 9030f9218a..5f477c976d 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -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; }