On 9/22/21 4:55 PM, Ján Tomko wrote:
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/ch/ch_monitor.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
index d241d30b10..9c562fdd0f 100644
--- a/src/ch/ch_monitor.c
+++ b/src/ch/ch_monitor.c
@@ -149,22 +149,18 @@ virCHMonitorBuildKernelRelatedJson(virJSONValue *content,
virDomainDef *vmdef)
static int
virCHMonitorBuildMemoryJson(virJSONValue *content, virDomainDef *vmdef)
{
- virJSONValue *memory;
+ g_autoptr(virJSONValue) memory = NULL;
unsigned long long total_memory = virDomainDefGetMemoryInitial(vmdef) * 1024;
if (total_memory != 0) {
memory = virJSONValueNewObject();
You could have moved this initialization into the definition line for
memory to eliminate one more line (that is your goal, right? :-)
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