lxc: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Laine Stump 2020-07-02 18:23:25 -04:00
parent 7a6bfea145
commit 28f7ddae05
4 changed files with 4 additions and 8 deletions

View File

@ -174,7 +174,7 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef,
{ {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virCommandPtr cmd; virCommandPtr cmd;
virBuffer buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i; size_t i;
/* 'container_ptys' must exclude the PTY associated with /* 'container_ptys' must exclude the PTY associated with
@ -185,7 +185,6 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expected a /dev path for '%s'"), _("Expected a /dev path for '%s'"),
ttyPaths[i]); ttyPaths[i]);
virBufferFreeAndReset(&buf);
return NULL; return NULL;
} }
virBufferAdd(&buf, ttyPaths[i] + 5, -1); virBufferAdd(&buf, ttyPaths[i] + 5, -1);
@ -219,7 +218,6 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef,
vmDef->os.initenv[i]->value); vmDef->os.initenv[i]->value);
} }
virBufferFreeAndReset(&buf);
return cmd; return cmd;
} }

View File

@ -1378,7 +1378,7 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
int num, int num,
char *path) char *path)
{ {
virBuffer map_value = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) map_value = VIR_BUFFER_INITIALIZER;
size_t i; size_t i;
int ret = -1; int ret = -1;
@ -1402,7 +1402,6 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
ret = 0; ret = 0;
cleanup: cleanup:
virBufferFreeAndReset(&map_value);
return ret; return ret;
} }

View File

@ -4618,7 +4618,7 @@ static char *
lxcConnectGetSysinfo(virConnectPtr conn, unsigned int flags) lxcConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
{ {
virLXCDriverPtr driver = conn->privateData; virLXCDriverPtr driver = conn->privateData;
virBuffer buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);

View File

@ -124,7 +124,7 @@ static int lxcProcReadMeminfo(char *hostpath, virDomainDefPtr def,
g_autofree char *line = NULL; g_autofree char *line = NULL;
size_t n; size_t n;
struct virLXCMeminfo meminfo; struct virLXCMeminfo meminfo;
virBuffer buffer = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
virBufferPtr new_meminfo = &buffer; virBufferPtr new_meminfo = &buffer;
if (virLXCCgroupGetMeminfo(&meminfo) < 0) { if (virLXCCgroupGetMeminfo(&meminfo) < 0) {
@ -223,7 +223,6 @@ static int lxcProcReadMeminfo(char *hostpath, virDomainDefPtr def,
memcpy(buf, virBufferCurrentContent(new_meminfo), res); memcpy(buf, virBufferCurrentContent(new_meminfo), res);
cleanup: cleanup:
virBufferFreeAndReset(new_meminfo);
VIR_FORCE_FCLOSE(fd); VIR_FORCE_FCLOSE(fd);
return res; return res;
} }