1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

ch: use g_auto in virCHMonitorBuildMemoryJson

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
William Douglas 2021-10-01 11:12:35 -07:00 committed by Laine Stump
parent 08bbe36fe4
commit 2ba777f5e3

View File

@ -154,22 +154,19 @@ virCHMonitorBuildKernelRelatedJson(virJSONValue *content, virDomainDef *vmdef)
static int
virCHMonitorBuildMemoryJson(virJSONValue *content, virDomainDef *vmdef)
{
virJSONValue *memory;
unsigned long long total_memory = virDomainDefGetMemoryInitial(vmdef) * 1024;
if (total_memory != 0) {
memory = virJSONValueNewObject();
g_autoptr(virJSONValue) memory = virJSONValueNewObject();
if (virJSONValueObjectAppendNumberUlong(memory, "size", total_memory) < 0)
goto cleanup;
return -1;
if (virJSONValueObjectAppend(content, "memory", &memory) < 0)
goto cleanup;
return -1;
}
return 0;
cleanup:
virJSONValueFree(memory);
return -1;
}
static int