[libvirt PATCH 3/7] libxl: StateInitialize: use g_autofree

Ján Tomko jtomko at redhat.com
Sat Feb 22 14:25:07 UTC 2020


Use g_autofree to free the driver config file path.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/libxl/libxl_driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 2b06f1be1e..0b88c9f9d9 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -652,7 +652,7 @@ libxlStateInitialize(bool privileged,
                      void *opaque)
 {
     libxlDriverConfigPtr cfg;
-    char *driverConf = NULL;
+    g_autofree char *driverConf = NULL;
     char ebuf[1024];
     bool autostart = true;
 
@@ -706,7 +706,6 @@ libxlStateInitialize(bool privileged,
 
     if (libxlDriverConfigLoadFile(cfg, driverConf) < 0)
         goto error;
-    VIR_FREE(driverConf);
 
     /* Register the callbacks providing access to libvirt's event loop */
     libxl_osevent_register_hooks(cfg->ctx, &libxl_osevent_callbacks, cfg->ctx);
@@ -822,7 +821,6 @@ libxlStateInitialize(bool privileged,
     return VIR_DRV_STATE_INIT_COMPLETE;
 
  error:
-    VIR_FREE(driverConf);
     libxlStateCleanup();
     return VIR_DRV_STATE_INIT_ERROR;
 }
-- 
2.24.1




More information about the libvir-list mailing list