[libvirt PATCH 3/8] libxl: libxlDomainStart: use g_auto more

Ján Tomko jtomko at redhat.com
Sun Oct 4 22:21:40 UTC 2020


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

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 034be2ddd7..b49ca83c10 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1266,16 +1266,16 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
     libxlSavefileHeader hdr;
     int ret = -1;
     uint32_t domid = 0;
-    char *dom_xml = NULL;
+    g_autofree char *dom_xml = NULL;
     g_autofree char *managed_save_path = NULL;
-    int managed_save_fd = -1;
+    VIR_AUTOCLOSE managed_save_fd = -1;
     libxlDomainObjPrivatePtr priv = vm->privateData;
     g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
     virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
     libxl_asyncprogress_how aop_console_how;
     libxl_domain_restore_params params;
     unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI;
-    char *config_json = NULL;
+    g_autofree char *config_json = NULL;
 
 #ifdef LIBXL_HAVE_PVUSB
     hostdev_flags |= VIR_HOSTDEV_SP_USB;
@@ -1516,9 +1516,6 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
 
  cleanup:
     libxl_domain_config_dispose(&d_config);
-    VIR_FREE(config_json);
-    VIR_FREE(dom_xml);
-    VIR_FORCE_CLOSE(managed_save_fd);
     return ret;
 }
 
-- 
2.26.2




More information about the libvir-list mailing list