esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState;
int id_candidate = -1;
- char *name_candidate = NULL;
unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
+ g_autofree char *name_candidate = NULL;
+
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
&powerState) < 0) {
goto cleanup;
if (powerState == esxVI_VirtualMachinePowerState_PoweredOff)
continue;
- VIR_FREE(name_candidate);
-
if (esxVI_GetVirtualMachineIdentity(virtualMachine,
&id_candidate, &name_candidate,
uuid_candidate) < 0) {
cleanup:
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList);
- VIR_FREE(name_candidate);
-
return domain;
}
esxVI_AutoStartPowerInfo *powerInfoList = NULL;
esxVI_AutoStartPowerInfo *powerInfo = NULL;
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
- char *name = NULL;
int id;
unsigned char uuid[VIR_UUID_BUFLEN];
int count = 0;
for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
- if (needIdentity) {
- VIR_FREE(name);
+ g_autofree char *name = NULL;
+ if (needIdentity) {
if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id,
&name, uuid) < 0) {
goto cleanup;
VIR_FREE(doms);
}
- VIR_FREE(name);
esxVI_AutoStartDefaults_Free(&autoStartDefaults);
esxVI_AutoStartPowerInfo_Free(&powerInfoList);
esxVI_String_Free(&propertyNameList);
esxVI_ScsiLun *scsiLunList = NULL;
esxVI_ScsiLun *scsiLun;
esxVI_HostScsiDisk *hostScsiDisk = NULL;
- char *poolName = NULL;
/* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5];
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
goto cleanup;
for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) {
+ g_autofree char *poolName = NULL;
+
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
if (hostScsiDisk && STREQ(hostScsiDisk->devicePath, path)) {
/* Found matching device */
- VIR_FREE(poolName);
if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary,
hostScsiDisk->key,
cleanup:
esxVI_ScsiLun_Free(&scsiLunList);
- VIR_FREE(poolName);
-
return volume;
}
{
virStorageVolPtr volume = NULL;
esxPrivate *priv = conn->privateData;
- char *poolName = NULL;
esxVI_ScsiLun *scsiLunList = NULL;
esxVI_ScsiLun *scsiLun;
/* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) {
+ g_autofree char *poolName = NULL;
+
memset(uuid_string, '\0', sizeof(uuid_string));
memset(md5, '\0', sizeof(md5));
if (STREQ(key, uuid_string)) {
/* Found matching UUID */
- VIR_FREE(poolName);
if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary,
scsiLun->key,
cleanup:
esxVI_ScsiLun_Free(&scsiLunList);
- VIR_FREE(poolName);
-
return volume;
}
esxVI_HostDatastoreBrowserSearchResults *searchResultsList = NULL;
esxVI_HostDatastoreBrowserSearchResults *searchResults = NULL;
esxVI_FileInfo *fileInfo = NULL;
- char *directoryAndFileName = NULL;
size_t length;
int count = 0;
size_t i;
/* Interpret search result */
for (searchResults = searchResultsList; searchResults;
searchResults = searchResults->_next) {
- VIR_FREE(directoryAndFileName);
+ g_autofree char *directoryAndFileName = NULL;
if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, NULL,
&directoryAndFileName) < 0) {
}
esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList);
- VIR_FREE(directoryAndFileName);
-
return count;
}
char *datastoreName = NULL;
esxVI_HostDatastoreBrowserSearchResults *searchResultsList = NULL;
esxVI_HostDatastoreBrowserSearchResults *searchResults = NULL;
- char *directoryAndFileName = NULL;
size_t length;
- char *datastorePath = NULL;
char *volumeName = NULL;
esxVI_FileInfo *fileInfo = NULL;
- char *uuid_string = NULL;
char key_candidate[VIR_UUID_STRING_BUFLEN] = "";
if (STRPREFIX(key, "[")) {
/* Interpret search result */
for (searchResults = searchResultsList; searchResults;
searchResults = searchResults->_next) {
- VIR_FREE(directoryAndFileName);
+ g_autofree char *directoryAndFileName = NULL;
if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL,
NULL, &directoryAndFileName) < 0) {
/* Build datastore path and query the UUID */
for (fileInfo = searchResults->file; fileInfo;
fileInfo = fileInfo->_next) {
- VIR_FREE(datastorePath);
+ g_autofree char *datastorePath = NULL;
+ g_autofree char *uuid_string = NULL;
if (length < 1) {
volumeName = g_strdup(fileInfo->path);
continue;
}
- VIR_FREE(uuid_string);
-
if (esxVI_QueryVirtualDiskUuid
(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&datastoreList);
esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList);
- VIR_FREE(directoryAndFileName);
- VIR_FREE(datastorePath);
VIR_FREE(volumeName);
- VIR_FREE(uuid_string);
return volume;
}
esxVI_String *completePropertyNameList = NULL;
esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *candidate = NULL;
- char *name_candidate = NULL;
ESX_VI_CHECK_ARG_LIST(virtualMachine);
for (candidate = virtualMachineList; candidate;
candidate = candidate->_next) {
- VIR_FREE(name_candidate);
+ g_autofree char *name_candidate = NULL;
if (esxVI_GetVirtualMachineIdentity(candidate, NULL, &name_candidate,
NULL) < 0) {
cleanup:
esxVI_String_Free(&completePropertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList);
- VIR_FREE(name_candidate);
-
return result;
}