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>
Reviewed-by: Peter Krempa <pkrempa(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 9f75012f1f..cc1f765ca9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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);
--
2.35.1