1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

util: dnsmasq: convert pointers to use g_autofree

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>
This commit is contained in:
Barrett Schonefeld 2020-11-23 16:09:39 -06:00 committed by Ján Tomko
parent e943f7ddee
commit 20aee6203b

View File

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