[PATCH v2 2/6] netdev_bandwidth_conf: Use g_autofree where possible

Kristina Hanicova khanicov at redhat.com
Wed Mar 3 10:48:16 UTC 2021


Signed-off-by: Kristina Hanicova <khanicov at redhat.com>
Reviewed-by: Ján Tomko <jtomko at redhat.com>
---
 src/conf/netdev_bandwidth_conf.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
index 4fb7aa4e3d..1ff3785677 100644
--- a/src/conf/netdev_bandwidth_conf.c
+++ b/src/conf/netdev_bandwidth_conf.c
@@ -29,10 +29,10 @@ static int
 virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
 {
     int ret = -1;
-    char *average = NULL;
-    char *peak = NULL;
-    char *burst = NULL;
-    char *floor = NULL;
+    g_autofree char *average = NULL;
+    g_autofree char *peak = NULL;
+    g_autofree char *burst = NULL;
+    g_autofree char *floor = NULL;
 
     if (!node || !rate) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -88,11 +88,6 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
     ret = 0;
 
  cleanup:
-    VIR_FREE(average);
-    VIR_FREE(peak);
-    VIR_FREE(burst);
-    VIR_FREE(floor);
-
     return ret;
 }
 
@@ -119,7 +114,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
     virNetDevBandwidthPtr def = NULL;
     xmlNodePtr cur;
     xmlNodePtr in = NULL, out = NULL;
-    char *class_id_prop = NULL;
+    g_autofree char *class_id_prop = NULL;
 
     def = g_new0(virNetDevBandwidth, 1);
 
@@ -210,7 +205,6 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
     ret = 0;
 
  cleanup:
-    VIR_FREE(class_id_prop);
     virNetDevBandwidthFree(def);
     return ret;
 }
-- 
2.29.2




More information about the libvir-list mailing list