mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
conf: Clean up some unnecessary goto paths
Now that we're using VIR_AUTOPTR(virBitmap) there's a couple of methods that we can clean up some now unnecessary goto paths. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
e2087c2955
commit
ec0793ded4
@ -2982,7 +2982,6 @@ static int
|
|||||||
virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
|
virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
|
||||||
unsigned int iothreads)
|
unsigned int iothreads)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t nxt = -1;
|
ssize_t nxt = -1;
|
||||||
virDomainIOThreadIDDefPtr iothrid = NULL;
|
virDomainIOThreadIDDefPtr iothrid = NULL;
|
||||||
@ -2996,7 +2995,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
|
|||||||
|
|
||||||
/* iothread's are numbered starting at 1, account for that */
|
/* iothread's are numbered starting at 1, account for that */
|
||||||
if (!(thrmap = virBitmapNew(iothreads + 1)))
|
if (!(thrmap = virBitmapNew(iothreads + 1)))
|
||||||
goto error;
|
return -1;
|
||||||
virBitmapSetAll(thrmap);
|
virBitmapSetAll(thrmap);
|
||||||
|
|
||||||
/* Clear 0 since we don't use it, then mark those which are
|
/* Clear 0 since we don't use it, then mark those which are
|
||||||
@ -3008,26 +3007,23 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
|
|||||||
|
|
||||||
/* resize array */
|
/* resize array */
|
||||||
if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0)
|
if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
/* Populate iothreadids[] using the set bit number from thrmap */
|
/* Populate iothreadids[] using the set bit number from thrmap */
|
||||||
while (def->niothreadids < iothreads) {
|
while (def->niothreadids < iothreads) {
|
||||||
if ((nxt = virBitmapNextSetBit(thrmap, nxt)) < 0) {
|
if ((nxt = virBitmapNextSetBit(thrmap, nxt)) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("failed to populate iothreadids"));
|
_("failed to populate iothreadids"));
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
if (VIR_ALLOC(iothrid) < 0)
|
if (VIR_ALLOC(iothrid) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
iothrid->iothread_id = nxt;
|
iothrid->iothread_id = nxt;
|
||||||
iothrid->autofill = true;
|
iothrid->autofill = true;
|
||||||
def->iothreadids[def->niothreadids++] = iothrid;
|
def->iothreadids[def->niothreadids++] = iothrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -18778,31 +18774,27 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
|
|||||||
virDomainThreadSchedParamPtr sched;
|
virDomainThreadSchedParamPtr sched;
|
||||||
virProcessSchedPolicy policy;
|
virProcessSchedPolicy policy;
|
||||||
int priority;
|
int priority;
|
||||||
int ret = -1;
|
|
||||||
VIR_AUTOPTR(virBitmap) map = NULL;
|
VIR_AUTOPTR(virBitmap) map = NULL;
|
||||||
|
|
||||||
if (!(map = virDomainSchedulerParse(node, name, &policy, &priority)))
|
if (!(map = virDomainSchedulerParse(node, name, &policy, &priority)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
while ((next = virBitmapNextSetBit(map, next)) > -1) {
|
while ((next = virBitmapNextSetBit(map, next)) > -1) {
|
||||||
if (!(sched = func(def, next)))
|
if (!(sched = func(def, next)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (sched->policy != VIR_PROC_POLICY_NONE) {
|
if (sched->policy != VIR_PROC_POLICY_NONE) {
|
||||||
virReportError(VIR_ERR_XML_DETAIL,
|
virReportError(VIR_ERR_XML_DETAIL,
|
||||||
_("%ssched attributes 'vcpus' must not overlap"),
|
_("%ssched attributes 'vcpus' must not overlap"),
|
||||||
name);
|
name);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sched->policy = policy;
|
sched->policy = policy;
|
||||||
sched->priority = priority;
|
sched->priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user