mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
esx: Remove unnecessary NULL comparisons (3/3)
Code cleanup: remove explicit NULL comparisons like ptr == NULL and ptr != NULL from the ESX code, replacing them with the simpler ptr and !ptr. Part three of three.
This commit is contained in:
parent
42c20d4bef
commit
7ab40c5d09
@ -67,7 +67,7 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: code looks for software iSCSI adapter only */
|
/* FIXME: code looks for software iSCSI adapter only */
|
||||||
if (hostInternetScsiHba == NULL) {
|
if (!hostInternetScsiHba) {
|
||||||
/* iSCSI adapter may not be enabled for this host */
|
/* iSCSI adapter may not be enabled for this host */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
|
|||||||
* return iSCSI names for all static targets to avoid duplicate names.
|
* return iSCSI names for all static targets to avoid duplicate names.
|
||||||
*/
|
*/
|
||||||
for (target = hostInternetScsiHba->configuredStaticTarget;
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
||||||
target != NULL; target = target->_next) {
|
target; target = target->_next) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: code looks for software iSCSI adapter only */
|
/* FIXME: code looks for software iSCSI adapter only */
|
||||||
if (hostInternetScsiHba == NULL) {
|
if (!hostInternetScsiHba) {
|
||||||
/* iSCSI adapter may not be enabled for this host */
|
/* iSCSI adapter may not be enabled for this host */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
|
|||||||
* return iSCSI names for all static targets to avoid duplicate names.
|
* return iSCSI names for all static targets to avoid duplicate names.
|
||||||
*/
|
*/
|
||||||
for (target = hostInternetScsiHba->configuredStaticTarget;
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
||||||
target != NULL && count < maxnames; target = target->_next) {
|
target && count < maxnames; target = target->_next) {
|
||||||
if (VIR_STRDUP(names[count], target->iScsiName) < 0)
|
if (VIR_STRDUP(names[count], target->iScsiName) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ esxStoragePoolLookupByName(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == NULL) {
|
if (!target) {
|
||||||
/* pool not found, error handling done by the base driver */
|
/* pool not found, error handling done by the base driver */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -214,13 +214,13 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: code just looks for software iSCSI adapter */
|
/* FIXME: code just looks for software iSCSI adapter */
|
||||||
if (hostInternetScsiHba == NULL) {
|
if (!hostInternetScsiHba) {
|
||||||
/* iSCSI adapter may not be enabled for this host */
|
/* iSCSI adapter may not be enabled for this host */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (target = hostInternetScsiHba->configuredStaticTarget;
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
||||||
target != NULL; target = target->_next) {
|
target; target = target->_next) {
|
||||||
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5);
|
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5);
|
||||||
|
|
||||||
if (memcmp(uuid, md5, VIR_UUID_STRING_BUFLEN) == 0) {
|
if (memcmp(uuid, md5, VIR_UUID_STRING_BUFLEN) == 0) {
|
||||||
@ -228,7 +228,7 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == NULL) {
|
if (!target) {
|
||||||
/* pool not found, error handling done by the base driver */
|
/* pool not found, error handling done by the base driver */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -310,13 +310,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (target = hostInternetScsiHba->configuredStaticTarget;
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
||||||
target != NULL; target = target->_next) {
|
target; target = target->_next) {
|
||||||
if (STREQ(target->iScsiName, pool->name)) {
|
if (STREQ(target->iScsiName, pool->name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == NULL) {
|
if (!target) {
|
||||||
/* pool not found */
|
/* pool not found */
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not find storage pool with name '%s'"),
|
_("Could not find storage pool with name '%s'"),
|
||||||
@ -339,7 +339,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
|||||||
|
|
||||||
def.source.hosts[0].name = target->address;
|
def.source.hosts[0].name = target->address;
|
||||||
|
|
||||||
if (target->port != NULL) {
|
if (target->port) {
|
||||||
def.source.hosts[0].port = target->port->value;
|
def.source.hosts[0].port = target->port->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (hostScsiTopologyLun = hostScsiTopologyLunList;
|
for (hostScsiTopologyLun = hostScsiTopologyLunList;
|
||||||
hostScsiTopologyLun != NULL;
|
hostScsiTopologyLun;
|
||||||
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
|
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@ -399,7 +399,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostScsiTopologyLunList == NULL) {
|
if (!hostScsiTopologyLunList) {
|
||||||
/* iSCSI adapter may not be enabled on ESX host */
|
/* iSCSI adapter may not be enabled on ESX host */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -408,10 +408,10 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (scsiLun = scsiLunList; scsiLun != NULL && count < maxnames;
|
for (scsiLun = scsiLunList; scsiLun && count < maxnames;
|
||||||
scsiLun = scsiLun->_next) {
|
scsiLun = scsiLun->_next) {
|
||||||
for (hostScsiTopologyLun = hostScsiTopologyLunList;
|
for (hostScsiTopologyLun = hostScsiTopologyLunList;
|
||||||
hostScsiTopologyLun != NULL && count < maxnames;
|
hostScsiTopologyLun && count < maxnames;
|
||||||
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
|
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
|
||||||
if (STREQ(hostScsiTopologyLun->scsiLun, scsiLun->key)) {
|
if (STREQ(hostScsiTopologyLun->scsiLun, scsiLun->key)) {
|
||||||
if (VIR_STRDUP(names[count], scsiLun->deviceName) < 0)
|
if (VIR_STRDUP(names[count], scsiLun->deviceName) < 0)
|
||||||
@ -457,7 +457,7 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (scsiLun = scsiLunList; scsiLun != NULL;
|
for (scsiLun = scsiLunList; scsiLun;
|
||||||
scsiLun = scsiLun->_next) {
|
scsiLun = scsiLun->_next) {
|
||||||
if (STREQ(scsiLun->deviceName, name)) {
|
if (STREQ(scsiLun->deviceName, name)) {
|
||||||
/*
|
/*
|
||||||
@ -505,10 +505,10 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (scsiLun = scsiLunList; scsiLun != NULL; scsiLun = scsiLun->_next) {
|
for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) {
|
||||||
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
|
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
|
||||||
|
|
||||||
if (hostScsiDisk != NULL && STREQ(hostScsiDisk->devicePath, path)) {
|
if (hostScsiDisk && STREQ(hostScsiDisk->devicePath, path)) {
|
||||||
/* Found matching device */
|
/* Found matching device */
|
||||||
VIR_FREE(poolName);
|
VIR_FREE(poolName);
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (scsiLun = scsiLunList; scsiLun != NULL;
|
for (scsiLun = scsiLunList; scsiLun;
|
||||||
scsiLun = scsiLun->_next) {
|
scsiLun = scsiLun->_next) {
|
||||||
memset(uuid_string, '\0', sizeof(uuid_string));
|
memset(uuid_string, '\0', sizeof(uuid_string));
|
||||||
memset(md5, '\0', sizeof(md5));
|
memset(md5, '\0', sizeof(md5));
|
||||||
@ -646,17 +646,17 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (scsiLun = scsiLunList; scsiLun != NULL;
|
for (scsiLun = scsiLunList; scsiLun;
|
||||||
scsiLun = scsiLun->_next) {
|
scsiLun = scsiLun->_next) {
|
||||||
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
|
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
|
||||||
|
|
||||||
if (hostScsiDisk != NULL &&
|
if (hostScsiDisk &&
|
||||||
STREQ(hostScsiDisk->deviceName, volume->name)) {
|
STREQ(hostScsiDisk->deviceName, volume->name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostScsiDisk == NULL) {
|
if (!hostScsiDisk) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could find volume with name: %s"), volume->name);
|
_("Could find volume with name: %s"), volume->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -70,12 +70,12 @@ esxLookupVMFSStoragePoolType(esxVI_Context *ctx, const char *poolName,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datastore == NULL) {
|
if (!datastore) {
|
||||||
/* Not found, let the base storage driver handle error reporting */
|
/* Not found, let the base storage driver handle error reporting */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
|
for (dynamicProperty = datastore->propSet; dynamicProperty;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, "info")) {
|
if (STREQ(dynamicProperty->name, "info")) {
|
||||||
if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val,
|
if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val,
|
||||||
@ -87,11 +87,11 @@ esxLookupVMFSStoragePoolType(esxVI_Context *ctx, const char *poolName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esxVI_LocalDatastoreInfo_DynamicCast(datastoreInfo) != NULL) {
|
if (esxVI_LocalDatastoreInfo_DynamicCast(datastoreInfo)) {
|
||||||
*poolType = VIR_STORAGE_POOL_DIR;
|
*poolType = VIR_STORAGE_POOL_DIR;
|
||||||
} else if (esxVI_NasDatastoreInfo_DynamicCast(datastoreInfo) != NULL) {
|
} else if (esxVI_NasDatastoreInfo_DynamicCast(datastoreInfo)) {
|
||||||
*poolType = VIR_STORAGE_POOL_NETFS;
|
*poolType = VIR_STORAGE_POOL_NETFS;
|
||||||
} else if (esxVI_VmfsDatastoreInfo_DynamicCast(datastoreInfo) != NULL) {
|
} else if (esxVI_VmfsDatastoreInfo_DynamicCast(datastoreInfo)) {
|
||||||
*poolType = VIR_STORAGE_POOL_FS;
|
*poolType = VIR_STORAGE_POOL_FS;
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -123,7 +123,7 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (datastore = datastoreList; datastore != NULL;
|
for (datastore = datastoreList; datastore;
|
||||||
datastore = datastore->_next) {
|
datastore = datastore->_next) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@ -159,9 +159,9 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (datastore = datastoreList; datastore != NULL;
|
for (datastore = datastoreList; datastore;
|
||||||
datastore = datastore->_next) {
|
datastore = datastore->_next) {
|
||||||
for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
|
for (dynamicProperty = datastore->propSet; dynamicProperty;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, "summary.name")) {
|
if (STREQ(dynamicProperty->name, "summary.name")) {
|
||||||
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
|
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
|
||||||
@ -215,7 +215,7 @@ esxStoragePoolLookupByName(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datastore == NULL) {
|
if (!datastore) {
|
||||||
/* Not found, let the base storage driver handle error reporting */
|
/* Not found, let the base storage driver handle error reporting */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ esxStoragePoolLookupByName(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostMount == NULL) {
|
if (!hostMount) {
|
||||||
/* Not found, let the base storage driver handle error reporting */
|
/* Not found, let the base storage driver handle error reporting */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -273,7 +273,7 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (datastore = datastoreList; datastore != NULL;
|
for (datastore = datastoreList; datastore;
|
||||||
datastore = datastore->_next) {
|
datastore = datastore->_next) {
|
||||||
esxVI_DatastoreHostMount_Free(&hostMount);
|
esxVI_DatastoreHostMount_Free(&hostMount);
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostMount == NULL) {
|
if (!hostMount) {
|
||||||
/*
|
/*
|
||||||
* Storage pool is not of VMFS type, leave error reporting to the
|
* Storage pool is not of VMFS type, leave error reporting to the
|
||||||
* base storage driver.
|
* base storage driver.
|
||||||
@ -299,7 +299,7 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datastore == NULL) {
|
if (!datastore) {
|
||||||
/* Not found, let the base storage driver handle error reporting */
|
/* Not found, let the base storage driver handle error reporting */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool,
|
|||||||
if (accessible == esxVI_Boolean_True) {
|
if (accessible == esxVI_Boolean_True) {
|
||||||
info->state = VIR_STORAGE_POOL_RUNNING;
|
info->state = VIR_STORAGE_POOL_RUNNING;
|
||||||
|
|
||||||
for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
|
for (dynamicProperty = datastore->propSet; dynamicProperty;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, "summary.capacity")) {
|
if (STREQ(dynamicProperty->name, "summary.capacity")) {
|
||||||
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
|
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
|
||||||
@ -446,7 +446,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
|||||||
def.target.path = hostMount->mountInfo->path;
|
def.target.path = hostMount->mountInfo->path;
|
||||||
|
|
||||||
if (accessible == esxVI_Boolean_True) {
|
if (accessible == esxVI_Boolean_True) {
|
||||||
for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
|
for (dynamicProperty = datastore->propSet; dynamicProperty;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, "summary.capacity")) {
|
if (STREQ(dynamicProperty->name, "summary.capacity")) {
|
||||||
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
|
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
|
||||||
@ -468,7 +468,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
|||||||
def.allocation = def.capacity - def.available;
|
def.allocation = def.capacity - def.available;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
|
for (dynamicProperty = datastore->propSet; dynamicProperty;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, "info")) {
|
if (STREQ(dynamicProperty->name, "info")) {
|
||||||
if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val,
|
if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val,
|
||||||
@ -481,9 +481,9 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* See vSphere API documentation about HostDatastoreSystem for details */
|
/* See vSphere API documentation about HostDatastoreSystem for details */
|
||||||
if (esxVI_LocalDatastoreInfo_DynamicCast(info) != NULL) {
|
if (esxVI_LocalDatastoreInfo_DynamicCast(info)) {
|
||||||
def.type = VIR_STORAGE_POOL_DIR;
|
def.type = VIR_STORAGE_POOL_DIR;
|
||||||
} else if ((nasInfo = esxVI_NasDatastoreInfo_DynamicCast(info)) != NULL) {
|
} else if ((nasInfo = esxVI_NasDatastoreInfo_DynamicCast(info))) {
|
||||||
if (VIR_ALLOC_N(def.source.hosts, 1) < 0)
|
if (VIR_ALLOC_N(def.source.hosts, 1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def.type = VIR_STORAGE_POOL_NETFS;
|
def.type = VIR_STORAGE_POOL_NETFS;
|
||||||
@ -500,7 +500,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
|||||||
nasInfo->nas->type);
|
nasInfo->nas->type);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else if (esxVI_VmfsDatastoreInfo_DynamicCast(info) != NULL) {
|
} else if (esxVI_VmfsDatastoreInfo_DynamicCast(info)) {
|
||||||
def.type = VIR_STORAGE_POOL_FS;
|
def.type = VIR_STORAGE_POOL_FS;
|
||||||
/*
|
/*
|
||||||
* FIXME: I'm not sure how to represent the source and target of a
|
* FIXME: I'm not sure how to represent the source and target of a
|
||||||
@ -541,9 +541,9 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Interpret search result */
|
/* Interpret search result */
|
||||||
for (searchResults = searchResultsList; searchResults != NULL;
|
for (searchResults = searchResultsList; searchResults;
|
||||||
searchResults = searchResults->_next) {
|
searchResults = searchResults->_next) {
|
||||||
for (fileInfo = searchResults->file; fileInfo != NULL;
|
for (fileInfo = searchResults->file; fileInfo;
|
||||||
fileInfo = fileInfo->_next) {
|
fileInfo = fileInfo->_next) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@ -573,7 +573,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (names == NULL || maxnames < 0) {
|
if (!names || maxnames < 0) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
|
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -588,7 +588,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Interpret search result */
|
/* Interpret search result */
|
||||||
for (searchResults = searchResultsList; searchResults != NULL;
|
for (searchResults = searchResultsList; searchResults;
|
||||||
searchResults = searchResults->_next) {
|
searchResults = searchResults->_next) {
|
||||||
VIR_FREE(directoryAndFileName);
|
VIR_FREE(directoryAndFileName);
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build volume names */
|
/* Build volume names */
|
||||||
for (fileInfo = searchResults->file; fileInfo != NULL;
|
for (fileInfo = searchResults->file; fileInfo;
|
||||||
fileInfo = fileInfo->_next) {
|
fileInfo = fileInfo->_next) {
|
||||||
if (length < 1) {
|
if (length < 1) {
|
||||||
if (VIR_STRDUP(names[count], fileInfo->path) < 0)
|
if (VIR_STRDUP(names[count], fileInfo->path) < 0)
|
||||||
@ -738,7 +738,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (datastore = datastoreList; datastore != NULL;
|
for (datastore = datastoreList; datastore;
|
||||||
datastore = datastore->_next) {
|
datastore = datastore->_next) {
|
||||||
datastoreName = NULL;
|
datastoreName = NULL;
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Interpret search result */
|
/* Interpret search result */
|
||||||
for (searchResults = searchResultsList; searchResults != NULL;
|
for (searchResults = searchResultsList; searchResults;
|
||||||
searchResults = searchResults->_next) {
|
searchResults = searchResults->_next) {
|
||||||
VIR_FREE(directoryAndFileName);
|
VIR_FREE(directoryAndFileName);
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build datastore path and query the UUID */
|
/* Build datastore path and query the UUID */
|
||||||
for (fileInfo = searchResults->file; fileInfo != NULL;
|
for (fileInfo = searchResults->file; fileInfo;
|
||||||
fileInfo = fileInfo->_next) {
|
fileInfo = fileInfo->_next) {
|
||||||
VIR_FREE(datastorePath);
|
VIR_FREE(datastorePath);
|
||||||
|
|
||||||
@ -791,7 +791,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
|
|||||||
volumeName) < 0)
|
volumeName) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (esxVI_VmDiskFileInfo_DynamicCast(fileInfo) == NULL) {
|
if (!esxVI_VmDiskFileInfo_DynamicCast(fileInfo)) {
|
||||||
/* Only a VirtualDisk has a UUID */
|
/* Only a VirtualDisk has a UUID */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -871,7 +871,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
/* Parse config */
|
/* Parse config */
|
||||||
def = virStorageVolDefParseString(&poolDef, xmldesc);
|
def = virStorageVolDefParseString(&poolDef, xmldesc);
|
||||||
|
|
||||||
if (def == NULL) {
|
if (!def) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,7 +884,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
/* Validate config */
|
/* Validate config */
|
||||||
tmp = strrchr(def->name, '/');
|
tmp = strrchr(def->name, '/');
|
||||||
|
|
||||||
if (tmp == NULL || *def->name == '/' || tmp[1] == '\0') {
|
if (!tmp || *def->name == '/' || tmp[1] == '\0') {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Volume name '%s' doesn't have expected format "
|
_("Volume name '%s' doesn't have expected format "
|
||||||
"'<directory>/<file>'"), def->name);
|
"'<directory>/<file>'"), def->name);
|
||||||
@ -912,14 +912,14 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
|
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
|
||||||
|
|
||||||
if (directoryName == NULL) {
|
if (!directoryName) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
|
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
|
||||||
strlen(unescapedDirectoryName) + 1);
|
strlen(unescapedDirectoryName) + 1);
|
||||||
|
|
||||||
if (fileName == NULL) {
|
if (!fileName) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,7 +938,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileInfo == NULL) {
|
if (!fileInfo) {
|
||||||
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
|
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
|
||||||
priv->primary->datacenter->_reference,
|
priv->primary->datacenter->_reference,
|
||||||
esxVI_Boolean_True) < 0) {
|
esxVI_Boolean_True) < 0) {
|
||||||
@ -1030,7 +1030,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
&esxStorageBackendVMFS, NULL);
|
&esxStorageBackendVMFS, NULL);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (virtualDiskSpec != NULL) {
|
if (virtualDiskSpec) {
|
||||||
virtualDiskSpec->diskType = NULL;
|
virtualDiskSpec->diskType = NULL;
|
||||||
virtualDiskSpec->adapterType = NULL;
|
virtualDiskSpec->adapterType = NULL;
|
||||||
}
|
}
|
||||||
@ -1097,7 +1097,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
/* Parse config */
|
/* Parse config */
|
||||||
def = virStorageVolDefParseString(&poolDef, xmldesc);
|
def = virStorageVolDefParseString(&poolDef, xmldesc);
|
||||||
|
|
||||||
if (def == NULL) {
|
if (!def) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,7 +1110,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
/* Validate config */
|
/* Validate config */
|
||||||
tmp = strrchr(def->name, '/');
|
tmp = strrchr(def->name, '/');
|
||||||
|
|
||||||
if (tmp == NULL || *def->name == '/' || tmp[1] == '\0') {
|
if (!tmp || *def->name == '/' || tmp[1] == '\0') {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Volume name '%s' doesn't have expected format "
|
_("Volume name '%s' doesn't have expected format "
|
||||||
"'<directory>/<file>'"), def->name);
|
"'<directory>/<file>'"), def->name);
|
||||||
@ -1138,14 +1138,14 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
|
directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName);
|
||||||
|
|
||||||
if (directoryName == NULL) {
|
if (!directoryName) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
|
fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName +
|
||||||
strlen(unescapedDirectoryName) + 1);
|
strlen(unescapedDirectoryName) + 1);
|
||||||
|
|
||||||
if (fileName == NULL) {
|
if (!fileName) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1164,7 +1164,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileInfo == NULL) {
|
if (!fileInfo) {
|
||||||
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
|
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
|
||||||
priv->primary->datacenter->_reference,
|
priv->primary->datacenter->_reference,
|
||||||
esxVI_Boolean_True) < 0) {
|
esxVI_Boolean_True) < 0) {
|
||||||
@ -1353,7 +1353,7 @@ esxStorageVolGetInfo(virStorageVolPtr volume,
|
|||||||
|
|
||||||
info->type = VIR_STORAGE_VOL_FILE;
|
info->type = VIR_STORAGE_VOL_FILE;
|
||||||
|
|
||||||
if (vmDiskFileInfo != NULL) {
|
if (vmDiskFileInfo) {
|
||||||
/* Scale from kilobyte to byte */
|
/* Scale from kilobyte to byte */
|
||||||
info->capacity = vmDiskFileInfo->capacityKb->value * 1024;
|
info->capacity = vmDiskFileInfo->capacityKb->value * 1024;
|
||||||
info->allocation = vmDiskFileInfo->fileSize->value;
|
info->allocation = vmDiskFileInfo->fileSize->value;
|
||||||
@ -1421,18 +1421,18 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
|
|||||||
def.type = VIR_STORAGE_VOL_FILE;
|
def.type = VIR_STORAGE_VOL_FILE;
|
||||||
def.target.path = datastorePath;
|
def.target.path = datastorePath;
|
||||||
|
|
||||||
if (vmDiskFileInfo != NULL) {
|
if (vmDiskFileInfo) {
|
||||||
/* Scale from kilobyte to byte */
|
/* Scale from kilobyte to byte */
|
||||||
def.capacity = vmDiskFileInfo->capacityKb->value * 1024;
|
def.capacity = vmDiskFileInfo->capacityKb->value * 1024;
|
||||||
def.allocation = vmDiskFileInfo->fileSize->value;
|
def.allocation = vmDiskFileInfo->fileSize->value;
|
||||||
|
|
||||||
def.target.format = VIR_STORAGE_FILE_VMDK;
|
def.target.format = VIR_STORAGE_FILE_VMDK;
|
||||||
} else if (isoImageFileInfo != NULL) {
|
} else if (isoImageFileInfo) {
|
||||||
def.capacity = fileInfo->fileSize->value;
|
def.capacity = fileInfo->fileSize->value;
|
||||||
def.allocation = fileInfo->fileSize->value;
|
def.allocation = fileInfo->fileSize->value;
|
||||||
|
|
||||||
def.target.format = VIR_STORAGE_FILE_ISO;
|
def.target.format = VIR_STORAGE_FILE_ISO;
|
||||||
} else if (floppyImageFileInfo != NULL) {
|
} else if (floppyImageFileInfo) {
|
||||||
def.capacity = fileInfo->fileSize->value;
|
def.capacity = fileInfo->fileSize->value;
|
||||||
def.allocation = fileInfo->fileSize->value;
|
def.allocation = fileInfo->fileSize->value;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
|
|||||||
for (i = 0; i < LAST_BACKEND; ++i) {
|
for (i = 0; i < LAST_BACKEND; ++i) {
|
||||||
pool = backends[i]->storagePoolLookupByName(conn, name);
|
pool = backends[i]->storagePoolLookupByName(conn, name);
|
||||||
|
|
||||||
if (pool != NULL) {
|
if (pool) {
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||||||
for (i = 0; i < LAST_BACKEND; ++i) {
|
for (i = 0; i < LAST_BACKEND; ++i) {
|
||||||
pool = backends[i]->storagePoolLookupByUUID(conn, uuid);
|
pool = backends[i]->storagePoolLookupByUUID(conn, uuid);
|
||||||
|
|
||||||
if (pool != NULL) {
|
if (pool) {
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
|
|||||||
for (i = 0; i < LAST_BACKEND; ++i) {
|
for (i = 0; i < LAST_BACKEND; ++i) {
|
||||||
volume = backends[i]->storageVolLookupByKey(conn, key);
|
volume = backends[i]->storageVolLookupByKey(conn, key);
|
||||||
|
|
||||||
if (volume != NULL) {
|
if (volume) {
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user