}
/* FIXME: code looks for software iSCSI adapter only */
- if (hostInternetScsiHba == NULL) {
+ if (!hostInternetScsiHba) {
/* iSCSI adapter may not be enabled for this host */
return 0;
}
* 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;
}
}
/* FIXME: code looks for software iSCSI adapter only */
- if (hostInternetScsiHba == NULL) {
+ if (!hostInternetScsiHba) {
/* iSCSI adapter may not be enabled for this host */
return 0;
}
* 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;
goto cleanup;
}
- if (target == NULL) {
+ if (!target) {
/* pool not found, error handling done by the base driver */
goto cleanup;
}
}
/* 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) {
}
}
- if (target == NULL) {
+ if (!target) {
/* pool not found, error handling done by the base driver */
goto cleanup;
}
}
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'"),
def.source.hosts[0].name = target->address;
- if (target->port != NULL) {
+ if (target->port) {
def.source.hosts[0].port = target->port->value;
}
}
for (hostScsiTopologyLun = hostScsiTopologyLunList;
- hostScsiTopologyLun != NULL;
+ hostScsiTopologyLun;
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
++count;
}
goto cleanup;
}
- if (hostScsiTopologyLunList == NULL) {
+ if (!hostScsiTopologyLunList) {
/* iSCSI adapter may not be enabled on ESX host */
return 0;
}
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)
goto cleanup;
}
- for (scsiLun = scsiLunList; scsiLun != NULL;
+ for (scsiLun = scsiLunList; scsiLun;
scsiLun = scsiLun->_next) {
if (STREQ(scsiLun->deviceName, name)) {
/*
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);
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));
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;
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,
}
}
- 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",
return -1;
}
- for (datastore = datastoreList; datastore != NULL;
+ for (datastore = datastoreList; datastore;
datastore = datastore->_next) {
++count;
}
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,
goto cleanup;
}
- if (datastore == NULL) {
+ if (!datastore) {
/* Not found, let the base storage driver handle error reporting */
goto cleanup;
}
goto cleanup;
}
- if (hostMount == NULL) {
+ if (!hostMount) {
/* Not found, let the base storage driver handle error reporting */
goto cleanup;
}
goto cleanup;
}
- for (datastore = datastoreList; datastore != NULL;
+ for (datastore = datastoreList; datastore;
datastore = datastore->_next) {
esxVI_DatastoreHostMount_Free(&hostMount);
goto cleanup;
}
- if (hostMount == NULL) {
+ if (!hostMount) {
/*
* Storage pool is not of VMFS type, leave error reporting to the
* base storage driver.
}
}
- if (datastore == NULL) {
+ if (!datastore) {
/* Not found, let the base storage driver handle error reporting */
goto cleanup;
}
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,
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,
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,
}
/* 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;
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
}
/* 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;
}
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;
}
}
/* Interpret search result */
- for (searchResults = searchResultsList; searchResults != NULL;
+ for (searchResults = searchResultsList; searchResults;
searchResults = searchResults->_next) {
VIR_FREE(directoryAndFileName);
}
/* 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)
goto cleanup;
}
- for (datastore = datastoreList; datastore != NULL;
+ for (datastore = datastoreList; datastore;
datastore = datastore->_next) {
datastoreName = NULL;
}
/* Interpret search result */
- for (searchResults = searchResultsList; searchResults != NULL;
+ for (searchResults = searchResultsList; searchResults;
searchResults = searchResults->_next) {
VIR_FREE(directoryAndFileName);
}
/* Build datastore path and query the UUID */
- for (fileInfo = searchResults->file; fileInfo != NULL;
+ for (fileInfo = searchResults->file; fileInfo;
fileInfo = fileInfo->_next) {
VIR_FREE(datastorePath);
volumeName) < 0)
goto cleanup;
- if (esxVI_VmDiskFileInfo_DynamicCast(fileInfo) == NULL) {
+ if (!esxVI_VmDiskFileInfo_DynamicCast(fileInfo)) {
/* Only a VirtualDisk has a UUID */
continue;
}
/* Parse config */
def = virStorageVolDefParseString(&poolDef, xmldesc);
- if (def == NULL) {
+ if (!def) {
goto cleanup;
}
/* 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);
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;
}
goto cleanup;
}
- if (fileInfo == NULL) {
+ if (!fileInfo) {
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
priv->primary->datacenter->_reference,
esxVI_Boolean_True) < 0) {
&esxStorageBackendVMFS, NULL);
cleanup:
- if (virtualDiskSpec != NULL) {
+ if (virtualDiskSpec) {
virtualDiskSpec->diskType = NULL;
virtualDiskSpec->adapterType = NULL;
}
/* Parse config */
def = virStorageVolDefParseString(&poolDef, xmldesc);
- if (def == NULL) {
+ if (!def) {
goto cleanup;
}
/* 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);
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;
}
goto cleanup;
}
- if (fileInfo == NULL) {
+ if (!fileInfo) {
if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName,
priv->primary->datacenter->_reference,
esxVI_Boolean_True) < 0) {
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;
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;