]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virConnectOpenInternal: Switch to automatic memory cleanup
authorPeter Krempa <pkrempa@redhat.com>
Thu, 8 Sep 2022 14:36:28 +0000 (16:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 13 Sep 2022 08:50:02 +0000 (10:50 +0200)
Use automatic cleanup for 'ret' and 'uristr'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt.c

index 19379a2a53506bd326dff03767534e22c1516ca0..2d32f8f2e863effe9020fa5c4a244c4d9f546761 100644 (file)
@@ -882,9 +882,9 @@ virConnectOpenInternal(const char *name,
 {
     size_t i;
     int res;
-    virConnectPtr ret;
+    g_autoptr(virConnect) ret = NULL;
     g_autoptr(virConf) conf = NULL;
-    char *uristr = NULL;
+    g_autofree char *uristr = NULL;
     bool embed = false;
 
     ret = virGetConnect();
@@ -1151,14 +1151,9 @@ virConnectOpenInternal(const char *name,
         goto failed;
     }
 
-    VIR_FREE(uristr);
-
-    return ret;
+    return g_steal_pointer(&ret);
 
  failed:
-    VIR_FREE(uristr);
-    virObjectUnref(ret);
-
     return NULL;
 }