Convert all the cases where we can unconditionally free the virURI at the end of scope. In libxlDomainMigrationDstPrepare, uri is only filled if uri_in was present, so moving the virURIFree out of the condition is safe. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/esx/esx_driver.c | 3 +-- src/libxl/libxl_migration.c | 7 ++----- src/qemu/qemu_migration.c | 3 +-- src/vmx/vmx.c | 3 +-- src/vz/vz_driver.c | 3 +-- src/vz/vz_sdk.c | 3 +-- tests/viruritest.c | 3 +-- 7 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 79b991f36f..9dc5489411 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -3658,7 +3658,7 @@ esxDomainMigratePerform(virDomainPtr domain, { int result = -1; esxPrivate *priv = domain->conn->privateData; - virURI *parsedUri = NULL; + g_autoptr(virURI) parsedUri = NULL; char *saveptr; char *path_resourcePool; char *path_hostSystem; @@ -3779,7 +3779,6 @@ esxDomainMigratePerform(virDomainPtr domain, result = 0; cleanup: - virURIFree(parsedUri); esxVI_ObjectContent_Free(&virtualMachine); esxVI_Event_Free(&eventList); esxVI_ManagedObjectReference_Free(&task); diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 0fd2b3206e..c5ec80139f 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -637,7 +637,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, char *xmlout = NULL; unsigned short port; char portstr[100]; - virURI *uri = NULL; + g_autoptr(virURI) uri = NULL; virNetSocket **socks = NULL; size_t nsocks = 0; int nsocks_listen = 0; @@ -795,8 +795,6 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, libxlMigrationCookieFree(mig); if (!uri_in) VIR_FREE(hostname); - else - virURIFree(uri); virObjectUnref(args); virDomainObjEndAPI(&vm); virObjectUnref(cfg); @@ -1183,7 +1181,7 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivate *driver, char *hostname = NULL; unsigned short port = 0; char portstr[100]; - virURI *uri = NULL; + g_autoptr(virURI) uri = NULL; virNetSocket *sock; int sockfd = -1; int ret = -1; @@ -1233,7 +1231,6 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivate *driver, cleanup: VIR_FORCE_CLOSE(sockfd); - virURIFree(uri); return ret; } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 6e5b3839fb..3d7d5efda3 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2107,7 +2107,7 @@ qemuMigrationSrcGraphicsRelocate(virQEMUDriver *driver, int ret = -1; const char *listenAddress = NULL; virSocketAddr addr; - virURI *uri = NULL; + g_autoptr(virURI) uri = NULL; int type = -1; int port = -1; int tlsPort = -1; @@ -2192,7 +2192,6 @@ qemuMigrationSrcGraphicsRelocate(virQEMUDriver *driver, } cleanup: - virURIFree(uri); return ret; } diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index e24e9211aa..282e9562e0 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2903,7 +2903,7 @@ virVMXParseSerial(virVMXContext *ctx, virConf *conf, int port, char network_endPoint_name[48] = ""; char *network_endPoint = NULL; - virURI *parsedUri = NULL; + g_autoptr(virURI) parsedUri = NULL; if (def == NULL || *def != NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); @@ -3051,7 +3051,6 @@ virVMXParseSerial(virVMXContext *ctx, virConf *conf, int port, VIR_FREE(fileType); VIR_FREE(fileName); VIR_FREE(network_endPoint); - virURIFree(parsedUri); return result; } diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 82323cb1b2..017c084ede 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3074,7 +3074,7 @@ vzDomainMigratePerformStep(virDomainObj *dom, { int ret = -1; struct vzDomObj *privdom = dom->privateData; - virURI *vzuri = NULL; + g_autoptr(virURI) vzuri = NULL; const char *miguri = NULL; const char *dname = NULL; vzMigrationCookie *mig = NULL; @@ -3117,7 +3117,6 @@ vzDomainMigratePerformStep(virDomainObj *dom, cleanup: if (job) vzDomainObjEndJob(dom); - virURIFree(vzuri); vzMigrationCookieFree(mig); return ret; diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 43d528820e..5ea3f29a8f 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1133,7 +1133,7 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDef *chr) char *friendlyName = NULL; PRL_SERIAL_PORT_SOCKET_OPERATION_MODE socket_mode; char *uristr = NULL; - virURI *uri = NULL; + g_autoptr(virURI) uri = NULL; int ret = -1; chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; @@ -1196,7 +1196,6 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDef *chr) cleanup: VIR_FREE(friendlyName); VIR_FREE(uristr); - virURIFree(uri); return ret; } diff --git a/tests/viruritest.c b/tests/viruritest.c index 94c8aa806d..7eb7c9cb67 100644 --- a/tests/viruritest.c +++ b/tests/viruritest.c @@ -46,7 +46,7 @@ struct URIParseData { static int testURIParse(const void *args) { int ret = -1; - virURI *uri = NULL; + g_autoptr(virURI) uri = NULL; const struct URIParseData *data = args; g_autofree char *uristr = NULL; size_t i; @@ -133,7 +133,6 @@ static int testURIParse(const void *args) ret = 0; cleanup: - virURIFree(uri); return ret; } -- 2.34.1