From b4436cc3f50ae8d8a8fca43d0162fb60cf49123c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 22 Sep 2021 22:50:22 +0200 Subject: [PATCH] ch: use g_auto in virCHMonitorBuildNetsJson MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ján Tomko Reviewed-by: Laine Stump --- 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 669eae2dc3..6a1b62b4a2 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -345,7 +345,7 @@ virCHMonitorBuildNetJson(virJSONValue *nets, virDomainNetDef *netdef) static int virCHMonitorBuildNetsJson(virJSONValue *content, virDomainDef *vmdef) { - virJSONValue *nets; + g_autoptr(virJSONValue) nets = NULL; size_t i; if (vmdef->nnets > 0) { @@ -353,17 +353,13 @@ virCHMonitorBuildNetsJson(virJSONValue *content, virDomainDef *vmdef) for (i = 0; i < vmdef->nnets; i++) { if (virCHMonitorBuildNetJson(nets, vmdef->nets[i]) < 0) - goto cleanup; + return -1; } if (virJSONValueObjectAppend(content, "net", &nets) < 0) - goto cleanup; + return -1; } return 0; - - cleanup: - virJSONValueFree(nets); - return -1; } static int