mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-01 06:42:22 +00:00
virDomainResctrlMonDefParse: Refactor temporary variables
Decrease scope of temporary variables so that they don't have to be autofreed and VIR_FREE()d at the same time. Remove unneeded checks and temporary variables. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
13c54c8945
commit
5e4262b9ac
@ -18144,8 +18144,6 @@ virDomainResctrlMonDefParse(virDomainDef *def,
|
|||||||
int rv = -1;
|
int rv = -1;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
g_autofree xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
g_autofree char *tmp = NULL;
|
|
||||||
g_autofree char *id = NULL;
|
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
@ -18153,6 +18151,8 @@ virDomainResctrlMonDefParse(virDomainDef *def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
g_autofree char *id = NULL;
|
||||||
|
|
||||||
domresmon = g_new0(virDomainResctrlMonDef, 1);
|
domresmon = g_new0(virDomainResctrlMonDef, 1);
|
||||||
|
|
||||||
domresmon->tag = tag;
|
domresmon->tag = tag;
|
||||||
@ -18188,12 +18188,9 @@ virDomainResctrlMonDefParse(virDomainDef *def,
|
|||||||
* associated allocation, set monitor's id to the same value
|
* associated allocation, set monitor's id to the same value
|
||||||
* as the allocation. */
|
* as the allocation. */
|
||||||
if (rv == 1) {
|
if (rv == 1) {
|
||||||
const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
|
id = g_strdup(virResctrlAllocGetID(resctrl->alloc));
|
||||||
|
|
||||||
id = g_strdup(alloc_id);
|
|
||||||
} else {
|
} else {
|
||||||
if (!(tmp = virBitmapFormat(domresmon->vcpus)))
|
g_autofree char *tmp = virBitmapFormat(domresmon->vcpus);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
id = g_strdup_printf("vcpus_%s", tmp);
|
id = g_strdup_printf("vcpus_%s", tmp);
|
||||||
}
|
}
|
||||||
@ -18204,9 +18201,6 @@ virDomainResctrlMonDefParse(virDomainDef *def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_APPEND_ELEMENT(resctrl->monitors, resctrl->nmonitors, domresmon);
|
VIR_APPEND_ELEMENT(resctrl->monitors, resctrl->nmonitors, domresmon);
|
||||||
|
|
||||||
VIR_FREE(id);
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user