From: William Douglas Date: Fri, 1 Oct 2021 18:12:35 +0000 (-0700) Subject: ch: use g_auto in virCHMonitorBuildMemoryJson X-Git-Tag: v7.9.0-rc1~273 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ba777f5e3df288af008bb39320fc894bd5d3083;p=thirdparty%2Flibvirt.git ch: use g_auto in virCHMonitorBuildMemoryJson Signed-off-by: William Douglas Reviewed-by: Laine Stump --- diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 0ceb711f05..841a2b6c8e 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -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