[PATCH 05/30] util: convert pointers to use g_autofree

Ryan Gahagan rgahagan at cs.utexas.edu
Mon Nov 23 22:09:26 UTC 2020


From: Barrett Schonefeld <bschoney at utexas.edu>

- src/util/virsysinfo.c

Signed-off-by: Barrett Schonefeld <bschoney at utexas.edu>
---
 src/util/virsysinfo.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 217f842a37..36317c97eb 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -393,7 +393,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinfoDefPtr ret)
     const char *cur;
     char *eol, *tmp_base;
     virSysinfoProcessorDefPtr processor;
-    char *processor_type = NULL;
+    g_autofree char *processor_type = NULL;
 
     if (!(tmp_base = strstr(base, "model name")) &&
         !(tmp_base = strstr(base, "Processor")))
@@ -424,12 +424,10 @@ virSysinfoParseARMProcessor(const char *base, virSysinfoDefPtr ret)
         base = cur;
     }
 
-    VIR_FREE(processor_type);
     return 0;
 
  error:
-    VIR_FREE(processor_type);
-    return -1;
+     return -1;
 }
 
 /* virSysinfoRead for ARMv7
@@ -532,9 +530,9 @@ static int
 virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
 {
     const char *tmp_base;
-    char *manufacturer = NULL;
-    char *procline = NULL;
-    char *ncpu = NULL;
+    g_autofree char *manufacturer = NULL;
+    g_autofree char *procline = NULL;
+    g_autofree char *ncpu = NULL;
     int result = -1;
     virSysinfoProcessorDefPtr processor;
 
@@ -593,9 +591,6 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
     result = 0;
 
  error:
-    VIR_FREE(manufacturer);
-    VIR_FREE(procline);
-    VIR_FREE(ncpu);
     return result;
 }
 
-- 
2.29.0




More information about the libvir-list mailing list