[PATCH 5/6] chExtractVersion: use g_auto*

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

 



There are two variables that can be freed automatically: @cmd
(which allows us to drop explicit virCommandFree() call at the
end of the function) and @help which was never freed (and thus
leaked).

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/ch/ch_conf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c
index b2812de7ad..c67c815d45 100644
--- a/src/ch/ch_conf.c
+++ b/src/ch/ch_conf.c
@@ -196,10 +196,10 @@ chExtractVersion(virCHDriver *driver)
 {
     int ret = -1;
     unsigned long version;
-    char *help = NULL;
+    g_autofree char *help = NULL;
     char *tmp = NULL;
     g_autofree char *ch_cmd = g_find_program_in_path(CH_CMD);
-    virCommand *cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (!ch_cmd)
         return -2;
@@ -236,6 +236,5 @@ chExtractVersion(virCHDriver *driver)
     ret = 0;
 
  cleanup:
-    virCommandFree(cmd);
     return ret;
 }
-- 
2.31.1




[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