[PATCH 1/2] openvz_driver: use g_autofree instead of VIR_FREE in openvz_driver.c

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

 



Signed-off-by: Karim Taha <kariem.taha2.7@xxxxxxxxx>
---
 src/openvz/openvz_driver.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 1bd96dfb56..fd3c25a393 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -615,7 +615,7 @@ openvzGenerateVethName(int veid, char *dev_name_ve)
 static char *
 openvzGenerateContainerVethName(int veid)
 {
-    char *temp = NULL;
+    g_autofree char *temp = NULL;
     char *name = NULL;
 
     /* try to get line "^NETIF=..." from config */
@@ -638,8 +638,6 @@ openvzGenerateContainerVethName(int veid)
         name = g_strdup_printf("eth%d", max + 1);
     }
 
-    VIR_FREE(temp);
-
     return name;
 }
 
@@ -750,7 +748,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
 {
     size_t i;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    char *param;
+    g_autofree char *param = NULL;
     int first = 1;
     struct openvz_driver *driver =  conn->privateData;
 
@@ -774,12 +772,10 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
         param = virBufferContentAndReset(&buf);
         if (param) {
             if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
-                VIR_FREE(param);
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("cannot replace NETIF config"));
                 return -1;
             }
-            VIR_FREE(param);
         }
     }
 
@@ -1075,7 +1071,7 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
 {
     struct openvz_driver *driver = dom->conn->privateData;
     virDomainObj *vm;
-    char *value = NULL;
+    g_autofree char *value = NULL;
     int ret = -1;
 
     if (!(vm = openvzDomObjFromDomain(driver, dom->uuid)))
@@ -1093,8 +1089,6 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
     ret = 0;
 
  cleanup:
-    VIR_FREE(value);
-
     virDomainObjEndAPI(&vm);
     return ret;
 }
@@ -1405,7 +1399,7 @@ static int openvzConnectListDefinedDomains(virConnectPtr conn G_GNUC_UNUSED,
 static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid)
 {
     FILE *fp;
-    char *line = NULL;
+    g_autofree char *line = NULL;
     size_t line_size = 0;
     unsigned long long usertime, systime, nicetime;
     int readvps = vpsid + 1;  /* ensure readvps is initially different */
@@ -1442,7 +1436,6 @@ Version: 2.2
         }
     }
 
-    VIR_FREE(line);
     VIR_FORCE_FCLOSE(fp);
     if (err)
         return -1;
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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