mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
qemuMigrationParamsToJSON: Refactor variable cleanup
Use automatic memory allocation and move variables into correct scope to simplify the code and remove the need for a 'error:' label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f2108c790c
commit
47a9f078f0
@ -718,20 +718,17 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params)
|
||||
virJSONValuePtr
|
||||
qemuMigrationParamsToJSON(qemuMigrationParamsPtr migParams)
|
||||
{
|
||||
virJSONValuePtr params = virJSONValueNewObject();
|
||||
qemuMigrationParamValuePtr pv;
|
||||
const char *name;
|
||||
g_autoptr(virJSONValue) params = virJSONValueNewObject();
|
||||
size_t i;
|
||||
int rc;
|
||||
|
||||
for (i = 0; i < QEMU_MIGRATION_PARAM_LAST; i++) {
|
||||
name = qemuMigrationParamTypeToString(i);
|
||||
pv = &migParams->params[i];
|
||||
const char *name = qemuMigrationParamTypeToString(i);
|
||||
qemuMigrationParamValuePtr pv = &migParams->params[i];
|
||||
int rc = 0;
|
||||
|
||||
if (!pv->set)
|
||||
continue;
|
||||
|
||||
rc = 0;
|
||||
switch (qemuMigrationParamTypes[i]) {
|
||||
case QEMU_MIGRATION_PARAM_TYPE_INT:
|
||||
rc = virJSONValueObjectAppendNumberInt(params, name, pv->value.i);
|
||||
@ -751,14 +748,10 @@ qemuMigrationParamsToJSON(qemuMigrationParamsPtr migParams)
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return params;
|
||||
|
||||
error:
|
||||
virJSONValueFree(params);
|
||||
return NULL;
|
||||
return g_steal_pointer(¶ms);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user