qemuMonitorJSONTransactionAdd: Refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-02-12 11:51:59 +01:00
parent 6431b20c3e
commit 0b236a9260

View File

@ -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;
return -1;
ret = 0;
cleanup:
virJSONValueFree(entry);
virJSONValueFree(data);
va_end(args);
return ret;
return 0;
}