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

Ján Tomko jtomko at redhat.com
Tue Nov 24 11:49:54 UTC 2020


util: sysinfo:
in the commit summary

On a Monday in 2020, Ryan Gahagan wrote:
>From: Barrett Schonefeld <bschoney at utexas.edu>
>

>- src/util/virsysinfo.c
>

No need to mention the file.

>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;

Unrelated whitespace change.

> }
>
> /* 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;

These two belong in their respective loops below.

Jano

>     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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201124/410149b1/attachment-0001.sig>


More information about the libvir-list mailing list