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(a)redhat.com>
---
src/conf/domain_conf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5d0d436a40..3b4274e037 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17046,7 +17046,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;
@@ -17054,10 +17055,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);
--
2.35.1