mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
virResctrlAllocNewFromInfo: Restrict variable scope and use automatic freeing
Move variables into the loop which uses them and use automatic freeing for temporarily allocated variables. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
01c335f7db
commit
25d45433b8
@ -1811,27 +1811,26 @@ static virResctrlAllocPtr
|
|||||||
virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
|
virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
size_t j = 0;
|
|
||||||
size_t k = 0;
|
|
||||||
virResctrlAllocPtr ret = virResctrlAllocNew();
|
virResctrlAllocPtr ret = virResctrlAllocNew();
|
||||||
virBitmapPtr mask = NULL;
|
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < info->nlevels; i++) {
|
for (i = 0; i < info->nlevels; i++) {
|
||||||
virResctrlInfoPerLevelPtr i_level = info->levels[i];
|
virResctrlInfoPerLevelPtr i_level = info->levels[i];
|
||||||
|
size_t j = 0;
|
||||||
|
|
||||||
if (!i_level)
|
if (!i_level)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
|
for (j = 0; j < VIR_CACHE_TYPE_LAST; j++) {
|
||||||
virResctrlInfoPerTypePtr i_type = i_level->types[j];
|
virResctrlInfoPerTypePtr i_type = i_level->types[j];
|
||||||
|
g_autoptr(virBitmap) mask = NULL;
|
||||||
|
size_t k = 0;
|
||||||
|
|
||||||
if (!i_type)
|
if (!i_type)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
virBitmapFree(mask);
|
|
||||||
mask = virBitmapNew(i_type->bits);
|
mask = virBitmapNew(i_type->bits);
|
||||||
virBitmapSetAll(mask);
|
virBitmapSetAll(mask);
|
||||||
|
|
||||||
@ -1856,7 +1855,6 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virBitmapFree(mask);
|
|
||||||
return ret;
|
return ret;
|
||||||
error:
|
error:
|
||||||
virObjectUnref(ret);
|
virObjectUnref(ret);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user