[PATCH v2 22/22] virDomainChrDefNew: Use automatic memory management

Kirill Shchetiniuk via Devel posted 22 patches 2 weeks, 3 days ago
[PATCH v2 22/22] virDomainChrDefNew: Use automatic memory management
Posted by Kirill Shchetiniuk via Devel 2 weeks, 3 days ago
From: Kirill Shchetiniuk <kshcheti@redhat.com>

Signed-off-by: Kirill Shchetiniuk <kshcheti@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 1d983a636f..01a9b070f6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10949,16 +10949,16 @@ virDomainChrSourceDefNew(virDomainXMLOption *xmlopt)
 virDomainChrDef *
 virDomainChrDefNew(virDomainXMLOption *xmlopt)
 {
-    virDomainChrDef *def = NULL;
+    g_autoptr(virDomainChrDef) def = NULL;
 
     def = g_new0(virDomainChrDef, 1);
 
     def->target.port = -1;
 
     if (!(def->source = virDomainChrSourceDefNew(xmlopt)))
-        VIR_FREE(def);
+        return NULL;
 
-    return def;
+    return g_steal_pointer(&def);
 }
 
 /* Parse the XML definition for a character device
-- 
2.49.0