virDomainDefParseIOThreads: Use g_autoptr() for @iothrid

Using g_autoptr() for @iothrid variable inside
virDomainDefParseIOThreads() allows us to drop explicit call to
virDomainIOThreadIDDefFree() in one case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Michal Privoznik 2022-05-16 11:48:15 +02:00
parent 95c95f1b75
commit d10b6b4c89

View File

@ -17047,7 +17047,8 @@ virDomainDefParseIOThreads(virDomainDef *def,
def->iothreadids = g_new0(virDomainIOThreadIDDef *, n);
for (i = 0; i < n; i++) {
virDomainIOThreadIDDef *iothrid = NULL;
g_autoptr(virDomainIOThreadIDDef) iothrid = NULL;
if (!(iothrid = virDomainIOThreadIDDefParseXML(nodes[i])))
return -1;
@ -17055,10 +17056,9 @@ virDomainDefParseIOThreads(virDomainDef *def,
virReportError(VIR_ERR_XML_ERROR,
_("duplicate iothread id '%u' found"),
iothrid->iothread_id);
virDomainIOThreadIDDefFree(iothrid);
return -1;
}
def->iothreadids[def->niothreadids++] = iothrid;
def->iothreadids[def->niothreadids++] = g_steal_pointer(&iothrid);
}
return virDomainIOThreadIDDefArrayInit(def, iothreads);