]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
chExtractVersion: use g_auto*
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Jun 2021 13:06:34 +0000 (15:06 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Jun 2021 14:39:00 +0000 (16:39 +0200)
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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/ch/ch_conf.c

index b2812de7ad59e42a748bee5b0b343979fac11fd4..c67c815d45cf413c5e118dfd5c2623d36002d524 100644 (file)
@@ -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;
 }