Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_monitor_json.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 94365c775b..76401c4d3c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -510,31 +510,28 @@ qemuMonitorJSONTransactionAdd(virJSONValuePtr actions,
const char *cmdname,
...)
{
- virJSONValuePtr entry = NULL;
- virJSONValuePtr data = NULL;
+ g_autoptr(virJSONValue) entry = NULL;
+ g_autoptr(virJSONValue) data = NULL;
va_list args;
- int ret = -1;
va_start(args, cmdname);
- if (virJSONValueObjectCreateVArgs(&data, args) < 0)
- goto cleanup;
+ if (virJSONValueObjectCreateVArgs(&data, args) < 0) {
+ va_end(args);
+ return -1;
+ }
+
+ va_end(args);
if (virJSONValueObjectCreate(&entry,
"s:type", cmdname,
"A:data", &data, NULL) < 0)
- goto cleanup;
+ return -1;
if (virJSONValueArrayAppend(actions, &entry) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- virJSONValueFree(entry);
- virJSONValueFree(data);
- va_end(args);
- return ret;
+ return 0;
}
--
2.29.2