[PATCH 1/3] networkcommon_conf: Use g_autofree where possible

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

 



Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/conf/networkcommon_conf.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c
index 26eeb6dbda..e82dbc3d3d 100644
--- a/src/conf/networkcommon_conf.c
+++ b/src/conf/networkcommon_conf.c
@@ -228,9 +228,10 @@ virNetDevIPRouteParseXML(const char *errorDetail,
 
     virNetDevIPRoutePtr def = NULL;
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
-    char *family = NULL;
-    char *address = NULL, *netmask = NULL;
-    char *gateway = NULL;
+    g_autofree char *family = NULL;
+    g_autofree char *address = NULL;
+    g_autofree char *netmask = NULL;
+    g_autofree char *gateway = NULL;
     unsigned long prefix = 0, metric = 0;
     int prefixRc, metricRc;
     bool hasPrefix = false;
@@ -276,10 +277,6 @@ virNetDevIPRouteParseXML(const char *errorDetail,
                                  hasMetric);
 
  cleanup:
-    VIR_FREE(family);
-    VIR_FREE(address);
-    VIR_FREE(netmask);
-    VIR_FREE(gateway);
     return def;
 }
 
@@ -287,7 +284,7 @@ int
 virNetDevIPRouteFormat(virBufferPtr buf,
                        const virNetDevIPRoute *def)
 {
-    char *addr = NULL;
+    g_autofree char *addr = NULL;
 
     virBufferAddLit(buf, "<route");
 
@@ -311,7 +308,6 @@ virNetDevIPRouteFormat(virBufferPtr buf,
     if (!(addr = virSocketAddrFormat(&def->gateway)))
         return -1;
     virBufferAsprintf(buf, " gateway='%s'", addr);
-    VIR_FREE(addr);
 
     if (def->has_metric && def->metric > 0)
         virBufferAsprintf(buf, " metric='%u'", def->metric);
-- 
2.29.2




[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