mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
test_virCapabilitiesGetCpusForNodemask: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f89c929b1e
commit
628be89e87
@ -33,28 +33,21 @@ static int
|
|||||||
test_virCapabilitiesGetCpusForNodemask(const void *data G_GNUC_UNUSED)
|
test_virCapabilitiesGetCpusForNodemask(const void *data G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
const char *nodestr = "3,4,5,6";
|
const char *nodestr = "3,4,5,6";
|
||||||
virBitmap *nodemask = NULL;
|
g_autoptr(virBitmap) nodemask = NULL;
|
||||||
virBitmap *cpumap = NULL;
|
g_autoptr(virBitmap) cpumap = NULL;
|
||||||
g_autoptr(virCapsHostNUMA) caps = NULL;
|
g_autoptr(virCapsHostNUMA) caps = NULL;
|
||||||
int mask_size = 8;
|
int mask_size = 8;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(caps = virTestCapsBuildNUMATopology(3)))
|
if (!(caps = virTestCapsBuildNUMATopology(3)))
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (virBitmapParse(nodestr, &nodemask, mask_size) < 0)
|
if (virBitmapParse(nodestr, &nodemask, mask_size) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!(cpumap = virCapabilitiesHostNUMAGetCpus(caps, nodemask)))
|
if (!(cpumap = virCapabilitiesHostNUMAGetCpus(caps, nodemask)))
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
virBitmapFree(nodemask);
|
|
||||||
virBitmapFree(cpumap);
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user