[PATCH 1/3] virdomainobjlist: Use g_autofree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of calling VIR_FREE() explicitly, we can annotate
variables with g_autofree.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/virdomainobjlist.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 9be1e7ad7d..a0cffac1b8 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -423,7 +423,7 @@ virDomainObjListRename(virDomainObjList *doms,
                        void *opaque)
 {
     int ret = -1;
-    char *old_name = NULL;
+    g_autofree char *old_name = NULL;
     int rc;
 
     if (STREQ(dom->def->name, new_name)) {
@@ -468,7 +468,6 @@ virDomainObjListRename(virDomainObjList *doms,
     ret = 0;
  cleanup:
     virObjectRWUnlock(doms);
-    VIR_FREE(old_name);
     return ret;
 }
 
@@ -482,7 +481,8 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
                            virDomainLoadConfigNotify notify,
                            void *opaque)
 {
-    char *configFile = NULL, *autostartLink = NULL;
+    g_autofree char *configFile = NULL;
+    g_autofree char *autostartLink = NULL;
     virDomainDef *def = NULL;
     virDomainObj *dom;
     int autostart;
@@ -511,13 +511,9 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
         (*notify)(dom, oldDef == NULL, opaque);
 
     virDomainDefFree(oldDef);
-    VIR_FREE(configFile);
-    VIR_FREE(autostartLink);
     return dom;
 
  error:
-    VIR_FREE(configFile);
-    VIR_FREE(autostartLink);
     virDomainDefFree(def);
     return NULL;
 }
@@ -531,7 +527,7 @@ virDomainObjListLoadStatus(virDomainObjList *doms,
                            virDomainLoadConfigNotify notify,
                            void *opaque)
 {
-    char *statusFile = NULL;
+    g_autofree char *statusFile = NULL;
     virDomainObj *obj = NULL;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
 
@@ -561,12 +557,10 @@ virDomainObjListLoadStatus(virDomainObjList *doms,
     if (notify)
         (*notify)(obj, 1, opaque);
 
-    VIR_FREE(statusFile);
     return obj;
 
  error:
     virDomainObjEndAPI(&obj);
-    VIR_FREE(statusFile);
     return NULL;
 }
 
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux