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