mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
Use g_auto for virURI almost everywhere
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@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
84543b2878
commit
8d9bd178e2
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user