static void
esxFreePrivate(esxPrivate **priv)
{
- if (priv == NULL || *priv == NULL) {
+ if (!priv || !(*priv)) {
return;
}
char *copyOfFileName = NULL;
char *directoryAndFileName;
- if (strchr(fileName, '/') == NULL && strchr(fileName, '\\') == NULL) {
+ if (!strchr(fileName, '/') && !strchr(fileName, '\\')) {
/* Plain file name, use same directory as for the .vmx file */
if (virAsprintf(&result, "%s/%s",
data->datastorePathWithoutFileName, fileName) < 0)
}
/* Search for datastore by mount path */
- for (datastore = datastoreList; datastore != NULL;
+ for (datastore = datastoreList; datastore;
datastore = datastore->_next) {
esxVI_DatastoreHostMount_Free(&hostMount);
datastoreName = NULL;
tmp = (char *)STRSKIP(fileName, hostMount->mountInfo->path);
- if (tmp == NULL) {
+ if (!tmp) {
continue;
}
}
/* Fallback to direct datastore name match */
- if (result == NULL && STRPREFIX(fileName, "/vmfs/volumes/")) {
+ if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) {
if (VIR_STRDUP(copyOfFileName, fileName) < 0) {
goto cleanup;
}
/* Expected format: '/vmfs/volumes/<datastore>/<path>' */
- if ((tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) == NULL ||
- (datastoreName = strtok_r(tmp, "/", &saveptr)) == NULL ||
- (directoryAndFileName = strtok_r(NULL, "", &saveptr)) == NULL) {
+ if (!(tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) ||
+ !(datastoreName = strtok_r(tmp, "/", &saveptr)) ||
+ !(directoryAndFileName = strtok_r(NULL, "", &saveptr))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("File name '%s' doesn't have expected format "
"'/vmfs/volumes/<datastore>/<path>'"), fileName);
goto cleanup;
}
- if (datastoreList == NULL) {
+ if (!datastoreList) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("File name '%s' refers to non-existing datastore '%s'"),
fileName, datastoreName);
}
/* If it's an absolute path outside of a datastore just use it as is */
- if (result == NULL && *fileName == '/') {
+ if (!result && *fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
if (VIR_STRDUP(result, fileName) < 0) {
goto cleanup;
}
}
- if (result == NULL) {
+ if (!result) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not handle file name '%s'"), fileName);
goto cleanup;
}
/* Detect separator type */
- if (strchr(hostMount->mountInfo->path, '\\') != NULL) {
+ if (strchr(hostMount->mountInfo->path, '\\')) {
separator = '\\';
}
if (def->device != VIR_DOMAIN_DISK_DEVICE_DISK ||
def->bus != VIR_DOMAIN_DISK_BUS_SCSI ||
def->type != VIR_DOMAIN_DISK_TYPE_FILE ||
- def->src == NULL ||
+ !def->src ||
! STRPREFIX(def->src, "[")) {
/*
* This isn't a file-based SCSI disk device with a datastore related
vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo);
- if (vmDiskFileInfo == NULL || vmDiskFileInfo->controllerType == NULL) {
+ if (!vmDiskFileInfo || !vmDiskFileInfo->controllerType) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not lookup controller model for '%s'"), def->src);
goto cleanup;
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "hardware.cpuFeature")) {
if (esxVI_HostCpuIdInfo_CastListFromAnyType
goto cleanup;
}
- for (hostCpuIdInfo = hostCpuIdInfoList; hostCpuIdInfo != NULL;
+ for (hostCpuIdInfo = hostCpuIdInfoList; hostCpuIdInfo;
hostCpuIdInfo = hostCpuIdInfo->_next) {
if (hostCpuIdInfo->level->value == -2147483647) { /* 0x80000001 */
if (esxVI_ParseHostCpuIdInfo(&parsedHostCpuIdInfo,
caps = virCapabilitiesNew(VIR_ARCH_I686, 1, 1);
}
- if (caps == NULL)
+ if (!caps)
return NULL;
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
NULL, NULL, 0,
NULL);
- if (guest == NULL) {
+ if (!guest) {
goto failure;
}
- if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
- NULL) == NULL) {
+ if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) {
goto failure;
}
NULL, NULL,
0, NULL);
- if (guest == NULL) {
+ if (!guest) {
goto failure;
}
- if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
- NULL) == NULL) {
+ if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) {
goto failure;
}
}
? esxVI_ProductVersion_ESX
: esxVI_ProductVersion_GSX;
- if (vCenterIpAddress == NULL || *vCenterIpAddress != NULL) {
+ if (!vCenterIpAddress || *vCenterIpAddress) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
return -1;
}
- if (conn->uri->user != NULL) {
+ if (conn->uri->user) {
if (VIR_STRDUP(username, conn->uri->user) < 0)
goto cleanup;
} else {
username = virAuthGetUsername(conn, auth, "esx", "root", conn->uri->server);
- if (username == NULL) {
+ if (!username) {
virReportError(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
goto cleanup;
}
unescapedPassword = virAuthGetPassword(conn, auth, "esx", username, conn->uri->server);
- if (unescapedPassword == NULL) {
+ if (!unescapedPassword) {
virReportError(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
goto cleanup;
}
password = esxUtil_EscapeForXml(unescapedPassword);
- if (password == NULL) {
+ if (!password) {
goto cleanup;
}
char *password = NULL;
char *url = NULL;
- if (hostSystemIpAddress == NULL &&
- (priv->parsedUri->path == NULL || STREQ(priv->parsedUri->path, "/"))) {
+ if (!hostSystemIpAddress &&
+ (!priv->parsedUri->path || STREQ(priv->parsedUri->path, "/"))) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Path has to specify the datacenter and compute resource"));
return -1;
return -1;
}
- if (conn->uri->user != NULL) {
+ if (conn->uri->user) {
if (VIR_STRDUP(username, conn->uri->user) < 0) {
goto cleanup;
}
} else {
username = virAuthGetUsername(conn, auth, "esx", "administrator", hostname);
- if (username == NULL) {
+ if (!username) {
virReportError(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
goto cleanup;
}
unescapedPassword = virAuthGetPassword(conn, auth, "esx", username, hostname);
- if (unescapedPassword == NULL) {
+ if (!unescapedPassword) {
virReportError(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
goto cleanup;
}
password = esxUtil_EscapeForXml(unescapedPassword);
- if (password == NULL) {
+ if (!password) {
goto cleanup;
}
goto cleanup;
}
- if (hostSystemIpAddress != NULL) {
+ if (hostSystemIpAddress) {
if (esxVI_Context_LookupManagedObjectsByHostSystemIp
(priv->vCenter, hostSystemIpAddress) < 0) {
goto cleanup;
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Decline if the URI is NULL or the scheme is NULL */
- if (conn->uri == NULL || conn->uri->scheme == NULL) {
+ if (!conn->uri || !conn->uri->scheme) {
return VIR_DRV_OPEN_DECLINED;
}
/* Decline if the scheme is not one of {vpx|esx|gsx} */
plus = strchr(conn->uri->scheme, '+');
- if (plus == NULL) {
+ if (!plus) {
if (STRCASENEQ(conn->uri->scheme, "vpx") &&
STRCASENEQ(conn->uri->scheme, "esx") &&
STRCASENEQ(conn->uri->scheme, "gsx")) {
}
if (STRCASENEQ(conn->uri->scheme, "vpx") &&
- conn->uri->path != NULL && STRNEQ(conn->uri->path, "/")) {
+ conn->uri->path && STRNEQ(conn->uri->path, "/")) {
VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'",
conn->uri->path, conn->uri->scheme);
}
/* Require server part */
- if (conn->uri->server == NULL) {
+ if (!conn->uri->server) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("URI is missing the server part"));
return VIR_DRV_OPEN_ERROR;
}
/* Require auth */
- if (auth == NULL || auth->cb == NULL) {
+ if (!auth || !auth->cb) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Missing or invalid auth pointer"));
return VIR_DRV_OPEN_ERROR;
}
/* Connect to vCenter */
- if (priv->parsedUri->vCenter != NULL) {
+ if (!priv->parsedUri->vCenter) {
if (STREQ(priv->parsedUri->vCenter, "*")) {
- if (potentialVCenterIpAddress == NULL) {
+ if (!potentialVCenterIpAddress) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("This host is not managed by a vCenter"));
goto cleanup;
}
- if (virStrcpyStatic(vCenterIpAddress,
- potentialVCenterIpAddress) == NULL) {
+ if (!virStrcpyStatic(vCenterIpAddress,
+ potentialVCenterIpAddress)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("vCenter IP address %s too big for destination"),
potentialVCenterIpAddress);
goto cleanup;
}
- if (potentialVCenterIpAddress != NULL &&
+ if (potentialVCenterIpAddress &&
STRNEQ(vCenterIpAddress, potentialVCenterIpAddress)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("This host is managed by a vCenter with IP "
/* Setup capabilities */
priv->caps = esxCapsInit(priv);
- if (priv->caps == NULL) {
+ if (!priv->caps) {
goto cleanup;
}
esxPrivate *priv = conn->privateData;
int result = 0;
- if (priv->host != NULL) {
+ if (priv->host) {
if (esxVI_EnsureSession(priv->host) < 0 ||
esxVI_Logout(priv->host) < 0) {
result = -1;
}
}
- if (priv->vCenter != NULL) {
+ if (priv->vCenter) {
if (esxVI_EnsureSession(priv->vCenter) < 0 ||
esxVI_Logout(priv->vCenter) < 0) {
result = -1;
}
/* Migration is only possible via a vCenter and if VMotion is enabled */
- return priv->vCenter != NULL &&
+ return priv->vCenter &&
supportsVMotion == esxVI_Boolean_True ? 1 : 0;
default:
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name,
"config.network.dnsConfig.hostName")) {
}
}
- if (hostName == NULL || strlen(hostName) < 1) {
+ if (!hostName || strlen(hostName) < 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or empty 'hostName' property"));
goto cleanup;
}
- if (domainName == NULL || strlen(domainName) < 1) {
+ if (!domainName || strlen(domainName) < 1) {
if (VIR_STRDUP(complete, hostName) < 0)
goto cleanup;
} else {
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "hardware.cpuInfo.hz")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
++ptr;
}
- if (virStrncpy(nodeinfo->model, dynamicProperty->val->string,
- sizeof(nodeinfo->model) - 1,
- sizeof(nodeinfo->model)) == NULL) {
+ if (!virStrncpy(nodeinfo->model, dynamicProperty->val->string,
+ sizeof(nodeinfo->model) - 1,
+ sizeof(nodeinfo->model))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU Model %s too long for destination"),
dynamicProperty->val->string);
esxPrivate *priv = conn->privateData;
char *xml = virCapabilitiesFormatXML(priv->caps);
- if (xml == NULL) {
+ if (!xml) {
virReportOOMError();
return NULL;
}
goto cleanup;
}
- for (virtualMachine = virtualMachineList; virtualMachine != NULL;
+ for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
&powerState) < 0) {
goto cleanup;
}
- for (virtualMachine = virtualMachineList; virtualMachine != NULL;
+ for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
&powerState) < 0) {
domain = virGetDomain(conn, name_candidate, uuid_candidate);
- if (domain == NULL) {
+ if (!domain) {
goto cleanup;
}
break;
}
- if (domain == NULL) {
+ if (!domain) {
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
}
domain = virGetDomain(conn, name, uuid);
- if (domain == NULL) {
+ if (!domain) {
goto cleanup;
}
goto cleanup;
}
- if (virtualMachine == NULL) {
+ if (!virtualMachine) {
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with name '%s'"), name);
goto cleanup;
}
domain = virGetDomain(conn, name, uuid);
- if (domain == NULL) {
+ if (!domain) {
goto cleanup;
}
virCheckFlags(0, -1);
- if (priv->vCenter != NULL) {
+ if (priv->vCenter) {
ctx = priv->vCenter;
} else {
ctx = priv->host;
goto cleanup;
}
- for (dynamicProperty = virtualMachine->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.hardware.memoryMB")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
info->state = VIR_DOMAIN_NOSTATE;
- for (dynamicProperty = virtualMachine->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.powerState")) {
if (esxVI_VirtualMachinePowerState_CastFromAnyType
#if ESX_QUERY_FOR_USED_CPU_TIME
/* Verify the cached 'used CPU time' performance counter ID */
/* FIXME: Currently no host for a vpx:// connection */
- if (priv->host != NULL) {
+ if (priv->host) {
if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
if (esxVI_Int_Alloc(&counterId) < 0) {
goto cleanup;
goto cleanup;
}
- for (perfMetricId = perfMetricIdList; perfMetricId != NULL;
+ for (perfMetricId = perfMetricIdList; perfMetricId;
perfMetricId = perfMetricId->_next) {
VIR_DEBUG("perfMetricId counterId %d, instance '%s'",
perfMetricId->counterId->value, perfMetricId->instance);
goto cleanup;
}
- for (perfCounterInfo = perfCounterInfoList; perfCounterInfo != NULL;
+ for (perfCounterInfo = perfCounterInfoList; perfCounterInfo;
perfCounterInfo = perfCounterInfo->_next) {
VIR_DEBUG("perfCounterInfo key %d, nameInfo '%s', groupInfo '%s', "
"unitInfo '%s', rollupType %d, statsType %d",
}
for (perfEntityMetricBase = perfEntityMetricBaseList;
- perfEntityMetricBase != NULL;
+ perfEntityMetricBase;
perfEntityMetricBase = perfEntityMetricBase->_next) {
VIR_DEBUG("perfEntityMetric ...");
perfEntityMetric =
esxVI_PerfEntityMetric_DynamicCast(perfEntityMetricBase);
- if (perfEntityMetric == NULL) {
+ if (!perfEntityMetric) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("QueryPerf returned object with unexpected type '%s'"),
esxVI_Type_ToString(perfEntityMetricBase->_type));
perfMetricIntSeries =
esxVI_PerfMetricIntSeries_DynamicCast(perfEntityMetric->value);
- if (perfMetricIntSeries == NULL) {
+ if (!perfMetricIntSeries) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("QueryPerf returned object with unexpected type '%s'"),
esxVI_Type_ToString(perfEntityMetric->value->_type));
goto cleanup;
}
- for (; perfMetricIntSeries != NULL;
+ for (; perfMetricIntSeries;
perfMetricIntSeries = perfMetricIntSeries->_next) {
VIR_DEBUG("perfMetricIntSeries ...");
for (value = perfMetricIntSeries->value;
- value != NULL;
+ value;
value = value->_next) {
VIR_DEBUG("value %lld", (long long int)value->value);
}
* Remove values owned by data structures to prevent them from being freed
* by the call to esxVI_PerfQuerySpec_Free().
*/
- if (querySpec != NULL) {
+ if (querySpec) {
querySpec->entity = NULL;
querySpec->format = NULL;
- if (querySpec->metricId != NULL) {
+ if (querySpec->metricId) {
querySpec->metricId->instance = NULL;
}
}
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "capability.maxSupportedVcpus")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
data.ctx = priv->primary;
- if (directoryName == NULL) {
+ if (!directoryName) {
if (virAsprintf(&data.datastorePathWithoutFileName, "[%s]",
datastoreName) < 0)
goto cleanup;
def = virVMXParseConfig(&ctx, priv->xmlopt, vmx);
- if (def != NULL) {
+ if (def) {
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
def->id = id;
}
}
cleanup:
- if (url == NULL) {
+ if (!url) {
virBufferFreeAndReset(&buffer);
}
def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig);
- if (def != NULL) {
+ if (def) {
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
}
def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt,
1 << VIR_DOMAIN_VIRT_VMWARE, 0);
- if (def == NULL) {
+ if (!def) {
return NULL;
}
goto cleanup;
}
- for (virtualMachine = virtualMachineList; virtualMachine != NULL;
+ for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
&powerState) < 0) {
1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE);
- if (def == NULL) {
+ if (!def) {
return NULL;
}
goto cleanup;
}
- if (virtualMachine == NULL &&
+ if (!virtualMachine &&
esxVI_LookupVirtualMachineByName(priv->primary, def->name, NULL,
&virtualMachine,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
}
- if (virtualMachine != NULL) {
+ if (virtualMachine) {
/* FIXME */
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Domain already exists, editing existing domains is not "
vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version);
- if (vmx == NULL) {
+ if (!vmx) {
goto cleanup;
}
}
}
- if (disk == NULL) {
+ if (!disk) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Domain XML doesn't contain any file-based harddisks, "
"cannot deduce datastore and path for VMX file"));
goto cleanup;
}
- if (disk->src == NULL) {
+ if (!disk->src) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("First file-based harddisk has no source, cannot deduce "
"datastore and path for VMX file"));
virBufferAsprintf(&buffer, "%s://%s:%d/folder/", priv->parsedUri->transport,
conn->uri->server, conn->uri->port);
- if (directoryName != NULL) {
+ if (directoryName) {
virBufferURIEncodeString(&buffer, directoryName);
virBufferAddChar(&buffer, '/');
}
escapedName = esxUtil_EscapeDatastoreItem(def->name);
- if (escapedName == NULL) {
+ if (!escapedName) {
goto cleanup;
}
}
/* Register the domain */
- if (directoryName != NULL) {
+ if (directoryName) {
if (virAsprintf(&datastoreRelatedPath, "[%s] %s/%s.vmx", datastoreName,
directoryName, escapedName) < 0)
goto cleanup;
domain = virGetDomain(conn, def->name, def->uuid);
- if (domain != NULL) {
+ if (domain) {
domain->id = -1;
}
/* FIXME: Add proper rollback in case of an error */
cleanup:
- if (url == NULL) {
+ if (!url) {
virBufferFreeAndReset(&buffer);
}
* ESX, so we can trivially ignore that flag. */
virCheckFlags(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, -1);
- if (priv->vCenter != NULL) {
+ if (priv->vCenter) {
ctx = priv->vCenter;
} else {
ctx = priv->host;
goto cleanup;
}
- if (powerInfoList == NULL) {
+ if (!powerInfoList) {
/* powerInfo list is empty, exit early here */
result = 0;
goto cleanup;
goto cleanup;
}
- for (powerInfo = powerInfoList; powerInfo != NULL;
+ for (powerInfo = powerInfoList; powerInfo;
powerInfo = powerInfo->_next) {
if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) {
if (STRCASEEQ(powerInfo->startAction, "powerOn")) {
goto cleanup;
}
- for (powerInfo = powerInfoList; powerInfo != NULL;
+ for (powerInfo = powerInfoList; powerInfo;
powerInfo = powerInfo->_next) {
if (STRNEQ(powerInfo->key->value, virtualMachine->obj->value)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
result = 0;
cleanup:
- if (newPowerInfo != NULL) {
+ if (newPowerInfo) {
newPowerInfo->key = NULL;
newPowerInfo->startAction = NULL;
newPowerInfo->stopAction = NULL;
if (VIR_STRDUP(type, "allocation") < 0)
return NULL;
- if (nparams != NULL) {
+ if (nparams) {
*nparams = 3; /* reservation, limit, shares */
}
}
for (dynamicProperty = virtualMachine->propSet;
- dynamicProperty != NULL && mask != 7 && i < 3 && i < *nparams;
+ dynamicProperty && mask != 7 && i < 3 && i < *nparams;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.cpuAllocation.reservation") &&
! (mask & (1 << 0))) {
virCheckFlags(ESX_MIGRATION_FLAGS, -1);
- if (uri_in == NULL) {
+ if (!uri_in) {
if (virAsprintf(uri_out, "vpxmigr://%s/%s/%s",
priv->vCenter->ipAddress,
priv->vCenter->computeResource->resourcePool->value,
virCheckFlags(ESX_MIGRATION_FLAGS, -1);
- if (priv->vCenter == NULL) {
+ if (!priv->vCenter) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Migration not possible without a vCenter"));
return -1;
}
- if (dname != NULL) {
+ if (dname) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Renaming domains on migration not supported"));
return -1;
if (!(parsedUri = virURIParse(uri)))
return -1;
- if (parsedUri->scheme == NULL || STRCASENEQ(parsedUri->scheme, "vpxmigr")) {
+ if (!parsedUri->scheme || STRCASENEQ(parsedUri->scheme, "vpxmigr")) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Only vpxmigr:// migration URIs are supported"));
goto cleanup;
path_resourcePool = strtok_r(parsedUri->path, "/", &saveptr);
path_hostSystem = strtok_r(NULL, "", &saveptr);
- if (path_resourcePool == NULL || path_hostSystem == NULL) {
+ if (!path_resourcePool || !path_hostSystem) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Migration URI has to specify resource pool and host system"));
goto cleanup;
goto cleanup;
}
- if (eventList != NULL) {
+ if (eventList) {
/*
* FIXME: Need to report the complete list of events. Limit reporting
* to the first event for now.
*/
- if (eventList->fullFormattedMessage != NULL) {
+ if (eventList->fullFormattedMessage) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not migrate domain, validation reported a "
"problem: %s"), eventList->fullFormattedMessage);
goto cleanup;
}
- for (dynamicProperty = resourcePool->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = resourcePool->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.memory")) {
if (esxVI_ResourcePoolResourceUsage_CastFromAnyType
}
}
- if (resourcePoolResourceUsage == NULL) {
+ if (!resourcePoolResourceUsage) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve memory usage of resource pool"));
goto cleanup;
def = virDomainSnapshotDefParseString(xmlDesc, priv->caps,
priv->xmlopt, 0, 0);
- if (def == NULL) {
+ if (!def) {
return NULL;
}
goto cleanup;
}
- if (snapshotTree != NULL) {
+ if (snapshotTree) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("Snapshot '%s' already exists"), def->name);
goto cleanup;
def.name = snapshot->name;
def.description = snapshotTree->description;
- def.parent = snapshotTreeParent != NULL ? snapshotTreeParent->name : NULL;
+ def.parent = snapshotTreeParent ? snapshotTreeParent->name : NULL;
if (esxVI_DateTime_ConvertToCalendarTime(snapshotTree->createTime,
&def.creationTime) < 0) {
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0;
leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
- if (names == NULL || nameslen < 0) {
+ if (!names || nameslen < 0) {
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) != 0;
leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0;
- if (names == NULL || nameslen < 0) {
+ if (!names || nameslen < 0) {
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
return -1;
}
- if (currentSnapshotTree != NULL) {
+ if (currentSnapshotTree) {
esxVI_VirtualMachineSnapshotTree_Free(¤tSnapshotTree);
return 1;
}
}
needIdentity = MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT) ||
- domains != NULL;
+ domains;
if (needIdentity) {
/* Request required data for esxVI_GetVirtualMachineIdentity */
needPowerState = MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) ||
MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE) ||
- domains != NULL;
+ domains;
if (needPowerState) {
if (esxVI_String_AppendValueToList(&propertyNameList,
ndoms = 1;
}
- for (virtualMachine = virtualMachineList; virtualMachine != NULL;
+ for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
if (needIdentity) {
VIR_FREE(name);
}
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) &&
- rootSnapshotTreeList != NULL) ||
+ rootSnapshotTreeList) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT) &&
- rootSnapshotTreeList == NULL)))
+ !rootSnapshotTreeList)))
continue;
}
autostart = false;
if (autoStartDefaults->enabled == esxVI_Boolean_True) {
- for (powerInfo = powerInfoList; powerInfo != NULL;
+ for (powerInfo = powerInfoList; powerInfo;
powerInfo = powerInfo->_next) {
if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) {
if (STRCASEEQ(powerInfo->startAction, "powerOn"))
int \
esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \
{ \
- if (ptrptr == NULL || *ptrptr != NULL) { \
+ if (!ptrptr || *ptrptr) { \
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
return -1; \
} \
{ \
esxVI_##_type *item ATTRIBUTE_UNUSED; \
\
- if (ptrptr == NULL || *ptrptr == NULL) { \
+ if (!ptrptr || !(*ptrptr)) { \
return; \
} \
\
esxVI_SharedCURL *shared = item->shared;
esxVI_MultiCURL *multi = item->multi;
- if (shared != NULL) {
+ if (shared) {
esxVI_SharedCURL_Remove(shared, item);
if (shared->count == 0) {
}
}
- if (multi != NULL) {
+ if (multi) {
esxVI_MultiCURL_Remove(multi, item);
if (multi->count == 0) {
}
}
- if (item->handle != NULL) {
+ if (item->handle) {
curl_easy_cleanup(item->handle);
}
- if (item->headers != NULL) {
+ if (item->headers) {
curl_slist_free_all(item->headers);
}
size_t available = 0;
size_t requested = size * nmemb;
- if (content == NULL) {
+ if (!content) {
return 0;
}
{
virBufferPtr buffer = userdata;
- if (buffer != NULL) {
+ if (buffer) {
/*
* Using a virBuffer to store the download data limits the downloadable
* size. This is no problem as esxVI_CURL_Download and esxVI_CURL_Perform
return 0;
}
- if (virStrncpy(buffer, info, size, size + 1) == NULL) {
+ if (!virStrncpy(buffer, info, size, size + 1)) {
VIR_FREE(buffer);
return 0;
}
int
esxVI_CURL_Connect(esxVI_CURL *curl, esxUtil_ParsedUri *parsedUri)
{
- if (curl->handle != NULL) {
+ if (curl->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call"));
return -1;
}
curl->handle = curl_easy_init();
- if (curl->handle == NULL) {
+ if (!curl->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not initialize CURL"));
return -1;
*/
curl->headers = curl_slist_append(curl->headers, "Expect:");
- if (curl->headers == NULL) {
+ if (!curl->headers) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not build CURL header list"));
return -1;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
int responseCode = 0;
- if (content == NULL || *content != NULL) {
+ if (!content || *content) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (length != NULL && *length > 0) {
+ if (length && *length > 0) {
/*
* Using a virBuffer to store the download data limits the downloadable
* size. This is no problem as esxVI_CURL_Download is meant to download
goto cleanup;
}
- if (length != NULL) {
+ if (length) {
*length = virBufferUse(&buffer);
}
cleanup:
VIR_FREE(range);
- if (*content == NULL) {
+ if (!(*content)) {
virBufferFreeAndReset(&buffer);
return -1;
}
{
int responseCode = 0;
- if (content == NULL) {
+ if (!content) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
return;
}
- if (item->handle != NULL) {
+ if (item->handle) {
curl_share_cleanup(item->handle);
}
{
size_t i;
- if (curl->handle == NULL) {
+ if (!curl->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot share uninitialized CURL handle"));
return -1;
}
- if (curl->shared != NULL) {
+ if (curl->shared) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot share CURL handle that is already shared"));
return -1;
}
- if (shared->handle == NULL) {
+ if (!shared->handle) {
shared->handle = curl_share_init();
- if (shared->handle == NULL) {
+ if (!shared->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not initialize CURL (share)"));
return -1;
int
esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl)
{
- if (curl->handle == NULL) {
+ if (!curl->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot unshare uninitialized CURL handle"));
return -1;
}
- if (curl->shared == NULL) {
+ if (!curl->shared) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot unshare CURL handle that is not shared"));
return -1;
return;
}
- if (item->handle != NULL) {
+ if (item->handle) {
curl_multi_cleanup(item->handle);
}
})
int
esxVI_MultiCURL_Add(esxVI_MultiCURL *multi, esxVI_CURL *curl)
{
- if (curl->handle == NULL) {
+ if (!curl->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot add uninitialized CURL handle to a multi handle"));
return -1;
}
- if (curl->multi != NULL) {
+ if (curl->multi) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot add CURL handle to a multi handle twice"));
return -1;
}
- if (multi->handle == NULL) {
+ if (!multi->handle) {
multi->handle = curl_multi_init();
- if (multi->handle == NULL) {
+ if (!multi->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not initialize CURL (multi)"));
return -1;
int
esxVI_MultiCURL_Remove(esxVI_MultiCURL *multi, esxVI_CURL *curl)
{
- if (curl->handle == NULL) {
+ if (!curl->handle) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot remove uninitialized CURL handle from a "
"multi handle"));
return -1;
}
- if (curl->multi == NULL) {
+ if (!curl->multi) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot remove CURL handle from a multi handle when it "
"wasn't added before"));
/* esxVI_Context_Free */
ESX_VI__TEMPLATE__FREE(Context,
{
- if (item->sessionLock != NULL) {
+ if (item->sessionLock) {
virMutexDestroy(item->sessionLock);
}
const char *ipAddress, const char *username,
const char *password, esxUtil_ParsedUri *parsedUri)
{
- if (ctx == NULL || url == NULL || ipAddress == NULL || username == NULL ||
- password == NULL || ctx->url != NULL || ctx->service != NULL ||
- ctx->curl != NULL) {
+ if (!ctx || !url || !ipAddress || !username ||
+ !password || ctx->url || ctx->service || ctx->curl) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
return -1;
}
- if (ctx->computeResource->resourcePool == NULL) {
+ if (!ctx->computeResource->resourcePool) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve resource pool"));
return -1;
/* Lookup Datacenter */
item = strtok_r(tmp, "/", &saveptr);
- if (item == NULL) {
+ if (!item) {
virReportError(VIR_ERR_INVALID_ARG,
_("Path '%s' does not specify a datacenter"), path);
goto cleanup;
root = ctx->service->rootFolder;
- while (ctx->datacenter == NULL && item != NULL) {
+ while (!ctx->datacenter && item) {
esxVI_Folder_Free(&folder);
/* Try to lookup item as a folder */
goto cleanup;
}
- if (folder != NULL) {
+ if (folder) {
/* It's a folder, use it as new lookup root */
if (root != ctx->service->rootFolder) {
esxVI_ManagedObjectReference_Free(&root);
item = strtok_r(NULL, "/", &saveptr);
}
- if (ctx->datacenter == NULL) {
+ if (!ctx->datacenter) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find datacenter specified in '%s'"), path);
goto cleanup;
ctx->datacenterPath = virBufferContentAndReset(&buffer);
/* Lookup (Cluster)ComputeResource */
- if (item == NULL) {
+ if (!item) {
virReportError(VIR_ERR_INVALID_ARG,
_("Path '%s' does not specify a compute resource"), path);
goto cleanup;
root = ctx->datacenter->hostFolder;
- while (ctx->computeResource == NULL && item != NULL) {
+ while (!ctx->computeResource && item) {
esxVI_Folder_Free(&folder);
/* Try to lookup item as a folder */
goto cleanup;
}
- if (folder != NULL) {
+ if (folder) {
/* It's a folder, use it as new lookup root */
if (root != ctx->datacenter->hostFolder) {
esxVI_ManagedObjectReference_Free(&root);
item = strtok_r(NULL, "/", &saveptr);
}
- if (ctx->computeResource == NULL) {
+ if (!ctx->computeResource) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find compute resource specified in '%s'"),
path);
goto cleanup;
}
- if (ctx->computeResource->resourcePool == NULL) {
+ if (!ctx->computeResource->resourcePool) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve resource pool"));
goto cleanup;
/* Lookup HostSystem */
if (STREQ(ctx->computeResource->_reference->type,
"ClusterComputeResource")) {
- if (item == NULL) {
+ if (!item) {
virReportError(VIR_ERR_INVALID_ARG,
_("Path '%s' does not specify a host system"), path);
goto cleanup;
item = strtok_r(NULL, "/", &saveptr);
}
- if (item != NULL) {
+ if (item) {
virReportError(VIR_ERR_INVALID_ARG,
_("Path '%s' ends with an excess item"), path);
goto cleanup;
goto cleanup;
}
- if (ctx->hostSystem == NULL) {
+ if (!ctx->hostSystem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find host system specified in '%s'"), path);
goto cleanup;
}
if (root != ctx->service->rootFolder &&
- (ctx->datacenter == NULL || root != ctx->datacenter->hostFolder)) {
+ (!ctx->datacenter || root != ctx->datacenter->hostFolder)) {
esxVI_ManagedObjectReference_Free(&root);
}
goto cleanup;
}
- if (ctx->computeResource->resourcePool == NULL) {
+ if (!ctx->computeResource->resourcePool) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve resource pool"));
goto cleanup;
xmlXPathContextPtr xpathContext = NULL;
xmlNodePtr responseNode = NULL;
- if (request == NULL || response == NULL || *response != NULL) {
+ if (!request || !response || *response) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
_("(esx execute response)"),
&xpathContext);
- if ((*response)->document == NULL) {
+ if (!(*response)->document) {
goto cleanup;
}
virXPathNode("/soapenv:Envelope/soapenv:Body/soapenv:Fault",
xpathContext);
- if ((*response)->node == NULL) {
+ if (!(*response)->node) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("HTTP response code %d for call to '%s'. "
"Fault is unknown, XPath evaluation failed"),
responseNode = virXPathNode(xpathExpression, xpathContext);
- if (responseNode == NULL) {
+ if (!responseNode) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("XPath evaluation of response for call to '%s' "
"failed"), methodName);
switch (occurrence) {
case esxVI_Occurrence_RequiredItem:
- if ((*response)->node == NULL) {
+ if (!(*response)->node) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Call to '%s' returned an empty result, "
"expecting a non-empty result"), methodName);
goto cleanup;
- } else if ((*response)->node->next != NULL) {
+ } else if ((*response)->node->next) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Call to '%s' returned a list, expecting "
"exactly one item"), methodName);
break;
case esxVI_Occurrence_RequiredList:
- if ((*response)->node == NULL) {
+ if (!(*response)->node) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Call to '%s' returned an empty result, "
"expecting a non-empty result"), methodName);
break;
case esxVI_Occurrence_OptionalItem:
- if ((*response)->node != NULL &&
- (*response)->node->next != NULL) {
+ if ((*response)->node &&
+ (*response)->node->next) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Call to '%s' returned a list, expecting "
"exactly one item"), methodName);
break;
case esxVI_Occurrence_None:
- if ((*response)->node != NULL) {
+ if ((*response)->node) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Call to '%s' returned something, expecting "
"an empty result"), methodName);
{
size_t i;
- if (anyType == NULL || value == NULL) {
+ if (!anyType || !value) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
return -1;
}
- for (i = 0; enumeration->values[i].name != NULL; ++i) {
+ for (i = 0; enumeration->values[i].name; ++i) {
if (STREQ(anyType->value, enumeration->values[i].name)) {
*value = enumeration->values[i].value;
return 0;
size_t i;
const char *name = NULL;
- if (element == NULL || output == NULL) {
+ if (!element || !output) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
return 0;
}
- for (i = 0; enumeration->values[i].name != NULL; ++i) {
+ for (i = 0; enumeration->values[i].name; ++i) {
if (value == enumeration->values[i].value) {
name = enumeration->values[i].name;
break;
}
}
- if (name == NULL) {
+ if (!name) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
int result = -1;
char *name = NULL;
- if (value == NULL) {
+ if (!value) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
return -1;
}
- for (i = 0; enumeration->values[i].name != NULL; ++i) {
+ for (i = 0; enumeration->values[i].name; ++i) {
if (STREQ(name, enumeration->values[i].name)) {
*value = enumeration->values[i].value;
result = 0;
{
esxVI_List *next = NULL;
- if (list == NULL || item == NULL) {
+ if (!list || !item) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (*list == NULL) {
+ if (!(*list)) {
*list = item;
return 0;
}
next = *list;
- while (next->_next != NULL) {
+ while (next->_next) {
next = next->_next;
}
esxVI_List *dest = NULL;
esxVI_List *src = NULL;
- if (destList == NULL || *destList != NULL) {
+ if (!destList || *destList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (src = srcList; src != NULL; src = src->_next) {
+ for (src = srcList; src; src = src->_next) {
if (deepCopyFunc(&dest, src) < 0 ||
esxVI_List_Append(destList, dest) < 0) {
goto failure;
esxVI_AnyType *childAnyType = NULL;
esxVI_List *item = NULL;
- if (list == NULL || *list != NULL ||
- castFromAnyTypeFunc == NULL || freeFunc == NULL) {
+ if (!list || *list || !castFromAnyTypeFunc || !freeFunc) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (anyType == NULL) {
+ if (!anyType) {
return 0;
}
return -1;
}
- for (childNode = anyType->node->children; childNode != NULL;
+ for (childNode = anyType->node->children; childNode;
childNode = childNode->next) {
if (childNode->type != XML_ELEMENT_NODE) {
virReportError(VIR_ERR_INTERNAL_ERROR,
{
esxVI_List *item = NULL;
- if (element == NULL || output == NULL || serializeFunc == NULL) {
+ if (!element || !output || !serializeFunc) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (list == NULL) {
+ if (!list) {
return 0;
}
- for (item = list; item != NULL; item = item->_next) {
+ for (item = list; item; item = item->_next) {
if (serializeFunc(item, element, output) < 0) {
return -1;
}
{
esxVI_List *item = NULL;
- if (list == NULL || *list != NULL ||
- deserializeFunc == NULL || freeFunc == NULL) {
+ if (!list || *list || !deserializeFunc || !freeFunc) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- if (node == NULL) {
+ if (!node) {
return 0;
}
- for (; node != NULL; node = node->next) {
+ for (; node; node = node->next) {
if (node->type != XML_ELEMENT_NODE) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Wrong XML element type %d"), node->type);
esxVI_SelectionSpec *selectionSpec = NULL;
const char *currentSelectSetName = NULL;
- if (selectSet == NULL) {
+ if (!selectSet) {
/*
* Don't check for *selectSet != NULL here because selectSet is a list
* and might contain items already. This function appends to selectSet.
traversalSpec->skip = esxVI_Boolean_False;
- if (selectSetNames != NULL) {
+ if (selectSetNames) {
currentSelectSetName = selectSetNames;
- while (currentSelectSetName != NULL && *currentSelectSetName != '\0') {
+ while (currentSelectSetName && *currentSelectSetName != '\0') {
if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 ||
VIR_STRDUP(selectionSpec->name, currentSelectSetName) < 0 ||
esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet,
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_UserSession *currentSession = NULL;
- if (ctx->sessionLock == NULL) {
+ if (!ctx->sessionLock) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call, no mutex"));
return -1;
}
virMutexLock(ctx->sessionLock);
- if (ctx->session == NULL) {
+ if (!ctx->session) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid call, no session"));
goto cleanup;
}
goto cleanup;
}
- for (dynamicProperty = sessionManager->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = sessionManager->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "currentSession")) {
if (esxVI_UserSession_CastFromAnyType(dynamicProperty->val,
}
}
- if (currentSession == NULL) {
+ if (!currentSession) {
esxVI_UserSession_Free(&ctx->session);
if (esxVI_Login(ctx, ctx->username, ctx->password, NULL,
bool propertySpec_isAppended = false;
esxVI_PropertyFilterSpec *propertyFilterSpec = NULL;
- if (objectContentList == NULL || *objectContentList != NULL) {
+ if (!objectContentList || *objectContentList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- if (*objectContentList == NULL) {
+ if (!(*objectContentList)) {
switch (occurrence) {
case esxVI_Occurrence_OptionalItem:
case esxVI_Occurrence_OptionalList:
objectSpec->obj = NULL;
objectSpec->selectSet = NULL;
- if (propertySpec != NULL) {
+ if (propertySpec) {
propertySpec->type = NULL;
propertySpec->pathSet = NULL;
}
{
esxVI_DynamicProperty *dynamicProperty;
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
return esxVI_ManagedEntityStatus_CastFromAnyType
{
esxVI_DynamicProperty *dynamicProperty;
- for (dynamicProperty = virtualMachine->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.powerState")) {
return esxVI_VirtualMachinePowerState_CastFromAnyType
{
esxVI_DynamicProperty *dynamicProperty;
- if (questionInfo == NULL || *questionInfo != NULL) {
+ if (!questionInfo || *questionInfo) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (dynamicProperty = virtualMachine->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.question")) {
if (esxVI_VirtualMachineQuestionInfo_CastFromAnyType
{
esxVI_DynamicProperty *dynamicProperty;
- if (value == NULL || *value != esxVI_Boolean_Undefined) {
+ if (!value || *value != esxVI_Boolean_Undefined) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
{
esxVI_DynamicProperty *dynamicProperty;
- if (value == NULL || *value != NULL) {
+ if (!value || *value) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_Long_CastFromAnyType(dynamicProperty->val, value) < 0) {
}
}
- if (*value == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
+ if (!(*value) && occurrence == esxVI_Occurrence_RequiredItem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
{
esxVI_DynamicProperty *dynamicProperty;
- if (value == NULL || *value != NULL) {
+ if (!value || *value) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
}
}
- if (*value == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
+ if (!(*value) && occurrence == esxVI_Occurrence_RequiredItem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
{
esxVI_DynamicProperty *dynamicProperty;
- if (value == NULL || *value != NULL) {
+ if (!value || *value) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_ManagedObjectReference_CastFromAnyType
}
}
- if (*value == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
+ if (!(*value) && occurrence == esxVI_Occurrence_RequiredItem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
goto cleanup;
}
- for (virtualMachine = virtualMachineList; virtualMachine != NULL;
+ for (virtualMachine = virtualMachineList; virtualMachine;
virtualMachine = virtualMachine->_next) {
for (dynamicProperty = virtualMachine->propSet;
- dynamicProperty != NULL;
+ dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "runtime.powerState")) {
if (esxVI_VirtualMachinePowerState_CastFromAnyType
return -1;
}
- if (id != NULL) {
+ if (id) {
if (esxUtil_ParseVirtualMachineIDString
(virtualMachine->obj->value, id) < 0 || *id <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
}
}
- if (name != NULL) {
- if (*name != NULL) {
+ if (name) {
+ if (*name) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
goto failure;
}
for (dynamicProperty = virtualMachine->propSet;
- dynamicProperty != NULL;
+ dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "name")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
}
}
- if (*name == NULL) {
+ if (!(*name)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not get name of virtual machine"));
goto failure;
}
}
- if (uuid != NULL) {
+ if (uuid) {
if (esxVI_GetManagedEntityStatus(virtualMachine, "configStatus",
&configStatus) < 0) {
goto failure;
if (configStatus == esxVI_ManagedEntityStatus_Green) {
for (dynamicProperty = virtualMachine->propSet;
- dynamicProperty != NULL;
+ dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.uuid")) {
if (esxVI_AnyType_ExpectType(dynamicProperty->val,
}
}
- if (uuid_string == NULL) {
+ if (!uuid_string) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not get UUID of virtual machine"));
goto failure;
return 0;
failure:
- if (name != NULL) {
+ if (name) {
VIR_FREE(*name);
}
int count = 0;
esxVI_VirtualMachineSnapshotTree *snapshotTree;
- for (snapshotTree = snapshotTreeList; snapshotTree != NULL;
+ for (snapshotTree = snapshotTreeList; snapshotTree;
snapshotTree = snapshotTree->_next) {
if (!(leaves && snapshotTree->childSnapshotList))
count++;
esxVI_VirtualMachineSnapshotTree *snapshotTree;
for (snapshotTree = snapshotTreeList;
- snapshotTree != NULL && count < nameslen;
+ snapshotTree && count < nameslen;
snapshotTree = snapshotTree->_next) {
if (!(leaves && snapshotTree->childSnapshotList)) {
if (VIR_STRDUP(names[count], snapshotTree->name) < 0)
{
esxVI_VirtualMachineSnapshotTree *candidate;
- if (snapshotTree == NULL || *snapshotTree != NULL ||
- (snapshotTreeParent && *snapshotTreeParent != NULL)) {
+ if (!snapshotTree || *snapshotTree ||
+ (snapshotTreeParent && *snapshotTreeParent)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (candidate = snapshotTreeList; candidate != NULL;
+ for (candidate = snapshotTreeList; candidate;
candidate = candidate->_next) {
if (STREQ(candidate->name, name)) {
*snapshotTree = candidate;
if (esxVI_GetSnapshotTreeByName(candidate->childSnapshotList, name,
snapshotTree, snapshotTreeParent,
occurrence) > 0) {
- if (snapshotTreeParent && *snapshotTreeParent == NULL) {
+ if (snapshotTreeParent && !(*snapshotTreeParent)) {
*snapshotTreeParent = candidate;
}
{
esxVI_VirtualMachineSnapshotTree *candidate;
- if (snapshotTree == NULL || *snapshotTree != NULL) {
+ if (!snapshotTree || *snapshotTree) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
- for (candidate = snapshotTreeList; candidate != NULL;
+ for (candidate = snapshotTreeList; candidate;
candidate = candidate->_next) {
if (STREQ(candidate->snapshot->value, snapshot->value)) {
*snapshotTree = candidate;
esxVI_ManagedObjectReference *managedObjectReference = NULL;
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
- if (virtualMachine == NULL || *virtualMachine != NULL) {
+ if (!virtualMachine || *virtualMachine) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
return -1;
}
- if (managedObjectReference == NULL) {
+ if (!managedObjectReference) {
if (occurrence == esxVI_Occurrence_OptionalItem) {
result = 0;
esxVI_ObjectContent *candidate = NULL;
char *name_candidate = NULL;
- if (virtualMachine == NULL || *virtualMachine != NULL) {
+ if (!virtualMachine || *virtualMachine) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (candidate = virtualMachineList; candidate != NULL;
+ for (candidate = virtualMachineList; candidate;
candidate = candidate->_next) {
VIR_FREE(name_candidate);
break;
}
- if (*virtualMachine == NULL) {
+ if (!(*virtualMachine)) {
if (occurrence == esxVI_Occurrence_OptionalItem) {
result = 0;
goto cleanup;
}
- if (questionInfo != NULL &&
+ if (questionInfo &&
esxVI_HandleVirtualMachineQuestion(ctx, (*virtualMachine)->obj,
questionInfo, autoAnswer,
&blocked) < 0) {
goto cleanup;
}
- if (pendingTaskInfoList != NULL) {
+ if (pendingTaskInfoList) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Other tasks are pending for this domain"));
goto cleanup;
esxVI_ObjectContent *candidate = NULL;
char *name_candidate;
- if (datastore == NULL || *datastore != NULL) {
+ if (!datastore || *datastore) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
/* Search for a matching datastore */
- for (candidate = datastoreList; candidate != NULL;
+ for (candidate = datastoreList; candidate;
candidate = candidate->_next) {
name_candidate = NULL;
}
}
- if (*datastore == NULL && occurrence != esxVI_Occurrence_OptionalItem) {
+ if (!(*datastore) && occurrence != esxVI_Occurrence_OptionalItem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find datastore with name '%s'"), name);
goto cleanup;
esxVI_DatastoreHostMount *datastoreHostMountList = NULL;
esxVI_DatastoreHostMount *datastoreHostMount = NULL;
- if (datastore == NULL || *datastore != NULL) {
+ if (!datastore || *datastore) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
/* Search for a matching datastore */
- for (candidate = datastoreList; candidate != NULL;
+ for (candidate = datastoreList; candidate;
candidate = candidate->_next) {
esxVI_DatastoreHostMount_Free(&datastoreHostMountList);
- for (dynamicProperty = candidate->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = candidate->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "host")) {
if (esxVI_DatastoreHostMount_CastListFromAnyType
}
}
- if (datastoreHostMountList == NULL) {
+ if (!datastoreHostMountList) {
continue;
}
for (datastoreHostMount = datastoreHostMountList;
- datastoreHostMount != NULL;
+ datastoreHostMount;
datastoreHostMount = datastoreHostMount->_next) {
if (STRNEQ(ctx->hostSystem->_reference->value,
datastoreHostMount->key->value)) {
}
}
- if (*datastore == NULL && occurrence != esxVI_Occurrence_OptionalItem) {
+ if (!(*datastore) && occurrence != esxVI_Occurrence_OptionalItem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find datastore containing absolute path '%s'"),
absolutePath);
esxVI_DatastoreHostMount *hostMountList = NULL;
esxVI_DatastoreHostMount *candidate = NULL;
- if (hostMount == NULL || *hostMount != NULL) {
+ if (!hostMount || *hostMount) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "host")) {
if (esxVI_DatastoreHostMount_CastListFromAnyType
}
}
- for (candidate = hostMountList; candidate != NULL;
+ for (candidate = hostMountList; candidate;
candidate = candidate->_next) {
if (STRNEQ(ctx->hostSystem->_reference->value, candidate->key->value)) {
continue;
break;
}
- if (*hostMount == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
+ if (!(*hostMount) && occurrence == esxVI_Occurrence_RequiredItem) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not lookup datastore host mount"));
goto cleanup;
esxVI_ObjectContent *objectContent = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (taskInfo == NULL || *taskInfo != NULL) {
+ if (!taskInfo || *taskInfo) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "info")) {
if (esxVI_TaskInfo_CastFromAnyType(dynamicProperty->val,
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_TaskInfo *taskInfo = NULL;
- if (pendingTaskInfoList == NULL || *pendingTaskInfoList != NULL) {
+ if (!pendingTaskInfoList || *pendingTaskInfoList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
/* Get list of recent tasks */
- for (dynamicProperty = virtualMachine->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "recentTask")) {
if (esxVI_ManagedObjectReference_CastListFromAnyType
}
/* Lookup task info for each task */
- for (recentTask = recentTaskList; recentTask != NULL;
+ for (recentTask = recentTaskList; recentTask;
recentTask = recentTask->_next) {
if (esxVI_LookupTaskInfoByTask(ctx, recentTask, &taskInfo) < 0) {
goto cleanup;
goto cleanup;
}
- if (virtualMachine != NULL) {
+ if (virtualMachine) {
if (esxVI_GetVirtualMachineQuestionInfo(virtualMachine,
&questionInfo) < 0) {
goto cleanup;
}
- if (questionInfo != NULL &&
+ if (questionInfo &&
esxVI_HandleVirtualMachineQuestion(ctx, virtualMachine->obj,
questionInfo, autoAnswer,
blocked) < 0) {
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (rootSnapshotTreeList == NULL || *rootSnapshotTreeList != NULL) {
+ if (!rootSnapshotTreeList || *rootSnapshotTreeList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = virtualMachine->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "snapshot.rootSnapshotList")) {
if (esxVI_VirtualMachineSnapshotTree_CastListFromAnyType
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
- if (currentSnapshotTree == NULL || *currentSnapshotTree != NULL) {
+ if (!currentSnapshotTree || *currentSnapshotTree) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = virtualMachine->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "snapshot.currentSnapshot")) {
if (esxVI_ManagedObjectReference_CastFromAnyType
}
}
- if (currentSnapshot == NULL) {
+ if (!currentSnapshot) {
if (occurrence == esxVI_Occurrence_OptionalItem) {
result = 0;
}
}
- if (rootSnapshotTreeList == NULL) {
+ if (!rootSnapshotTreeList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not lookup root snapshot list"));
goto cleanup;
esxVI_TaskInfo *taskInfo = NULL;
esxVI_HostDatastoreBrowserSearchResults *searchResults = NULL;
- if (fileInfo == NULL || *fileInfo != NULL) {
+ if (!fileInfo || *fileInfo) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
/* Interpret search result */
- if (searchResults->file == NULL) {
+ if (!searchResults->file) {
if (occurrence == esxVI_Occurrence_OptionalItem) {
result = 0;
cleanup:
/* Don't double free fileName */
- if (searchSpec != NULL && searchSpec->matchPattern != NULL) {
+ if (searchSpec && searchSpec->matchPattern) {
searchSpec->matchPattern->value = NULL;
}
char *taskInfoErrorMessage = NULL;
esxVI_TaskInfo *taskInfo = NULL;
- if (searchResultsList == NULL || *searchResultsList != NULL) {
+ if (!searchResultsList || *searchResultsList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
esxVI_FileInfo *fileInfo = NULL;
char *uuid_string = NULL;
- if (key == NULL || *key != NULL) {
+ if (!key || *key) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- if (esxVI_VmDiskFileInfo_DynamicCast(fileInfo) != NULL) {
+ if (esxVI_VmDiskFileInfo_DynamicCast(fileInfo)) {
/* VirtualDisks have a UUID, use it as key */
if (esxVI_QueryVirtualDiskUuid(ctx, datastorePath,
ctx->datacenter->_reference,
}
}
- if (*key == NULL) {
+ if (!(*key)) {
/* Other files don't have a UUID, fall back to the path as key */
if (VIR_STRDUP(*key, datastorePath) < 0) {
goto cleanup;
esxVI_ObjectContent *hostAutoStartManager = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (defaults == NULL || *defaults != NULL) {
+ if (!defaults || *defaults) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
for (dynamicProperty = hostAutoStartManager->propSet;
- dynamicProperty != NULL; dynamicProperty = dynamicProperty->_next) {
+ dynamicProperty; dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.defaults")) {
if (esxVI_AutoStartDefaults_CastFromAnyType(dynamicProperty->val,
defaults) < 0) {
}
}
- if (*defaults == NULL) {
+ if (!(*defaults)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve the AutoStartDefaults object"));
goto cleanup;
esxVI_ObjectContent *hostAutoStartManager = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (powerInfoList == NULL || *powerInfoList != NULL) {
+ if (!powerInfoList || *powerInfoList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
for (dynamicProperty = hostAutoStartManager->propSet;
- dynamicProperty != NULL; dynamicProperty = dynamicProperty->_next) {
+ dynamicProperty; dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.powerInfo")) {
if (esxVI_AutoStartPowerInfo_CastListFromAnyType
(dynamicProperty->val, powerInfoList) < 0) {
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (physicalNicList == NULL || *physicalNicList != NULL) {
+ if (!physicalNicList || *physicalNicList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.network.pnic")) {
if (esxVI_PhysicalNic_CastListFromAnyType(dynamicProperty->val,
esxVI_PhysicalNic *physicalNicList = NULL;
esxVI_PhysicalNic *candidate = NULL;
- if (physicalNic == NULL || *physicalNic != NULL) {
+ if (!physicalNic || *physicalNic) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
/* Search for a matching physical NIC */
- for (candidate = physicalNicList; candidate != NULL;
+ for (candidate = physicalNicList; candidate;
candidate = candidate->_next) {
if (STRCASEEQ(candidate->device, name)) {
if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) {
}
}
- if (*physicalNic == NULL && occurrence != esxVI_Occurrence_OptionalItem) {
+ if (!(*physicalNic) && occurrence != esxVI_Occurrence_OptionalItem) {
virReportError(VIR_ERR_NO_INTERFACE,
_("Could not find physical NIC with name '%s'"), name);
goto cleanup;
esxVI_PhysicalNic *physicalNicList = NULL;
esxVI_PhysicalNic *candidate = NULL;
- if (physicalNic == NULL || *physicalNic != NULL) {
+ if (!physicalNic || *physicalNic) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
/* Search for a matching physical NIC */
- for (candidate = physicalNicList; candidate != NULL;
+ for (candidate = physicalNicList; candidate;
candidate = candidate->_next) {
if (STRCASEEQ(candidate->mac, mac)) {
if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) {
}
}
- if (*physicalNic == NULL && occurrence != esxVI_Occurrence_OptionalItem) {
+ if (!(*physicalNic) && occurrence != esxVI_Occurrence_OptionalItem) {
virReportError(VIR_ERR_NO_INTERFACE,
_("Could not find physical NIC with MAC address '%s'"), mac);
goto cleanup;
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (hostVirtualSwitchList == NULL || *hostVirtualSwitchList != NULL) {
+ if (!hostVirtualSwitchList || *hostVirtualSwitchList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.network.vswitch")) {
if (esxVI_HostVirtualSwitch_CastListFromAnyType
esxVI_HostVirtualSwitch *hostVirtualSwitchList = NULL;
esxVI_HostVirtualSwitch *candidate = NULL;
- if (hostVirtualSwitch == NULL || *hostVirtualSwitch != NULL) {
+ if (!hostVirtualSwitch || *hostVirtualSwitch) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
/* Search for a matching HostVirtualSwitch */
- for (candidate = hostVirtualSwitchList; candidate != NULL;
+ for (candidate = hostVirtualSwitchList; candidate;
candidate = candidate->_next) {
if (STREQ(candidate->name, name)) {
if (esxVI_HostVirtualSwitch_DeepCopy(hostVirtualSwitch,
}
}
- if (*hostVirtualSwitch == NULL &&
+ if (!(*hostVirtualSwitch) &&
occurrence != esxVI_Occurrence_OptionalItem) {
virReportError(VIR_ERR_NO_NETWORK,
_("Could not find HostVirtualSwitch with name '%s'"),
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
- if (hostPortGroupList == NULL || *hostPortGroupList != NULL) {
+ if (!hostPortGroupList || *hostPortGroupList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.network.portgroup")) {
if (esxVI_HostPortGroup_CastListFromAnyType
int answerIndex = 0;
char *possibleAnswers = NULL;
- if (blocked == NULL) {
+ if (!blocked) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
*blocked = false;
- if (questionInfo->choice->choiceInfo != NULL) {
+ if (questionInfo->choice->choiceInfo) {
for (elementDescription = questionInfo->choice->choiceInfo;
- elementDescription != NULL;
+ elementDescription;
elementDescription = elementDescription->_next) {
virBufferAsprintf(&buffer, "'%s'", elementDescription->label);
- if (elementDescription->_next != NULL) {
+ if (elementDescription->_next) {
virBufferAddLit(&buffer, ", ");
}
- if (answerChoice == NULL &&
- questionInfo->choice->defaultIndex != NULL &&
+ if (!answerChoice &&
+ questionInfo->choice->defaultIndex &&
questionInfo->choice->defaultIndex->value == answerIndex) {
answerChoice = elementDescription;
}
}
if (autoAnswer) {
- if (possibleAnswers == NULL) {
+ if (!possibleAnswers) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Pending question blocks virtual machine execution, "
"question is '%s', no possible answers"),
*blocked = true;
goto cleanup;
- } else if (answerChoice == NULL) {
+ } else if (!answerChoice) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Pending question blocks virtual machine execution, "
"question is '%s', possible answers are %s, but no "
goto cleanup;
}
} else {
- if (possibleAnswers != NULL) {
+ if (possibleAnswers) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Pending question blocks virtual machine execution, "
"question is '%s', possible answers are %s"),
bool blocked;
esxVI_TaskInfo *taskInfo = NULL;
- if (errorMessage == NULL || *errorMessage != NULL) {
+ if (!errorMessage || *errorMessage) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
state != esxVI_TaskInfoState_Error) {
esxVI_UpdateSet_Free(&updateSet);
- if (virtualMachineUuid != NULL) {
+ if (virtualMachineUuid) {
if (esxVI_LookupAndHandleVirtualMachineQuestion
(ctx, virtualMachineUuid, virtualMachineOccurrence,
autoAnswer, &blocked) < 0) {
if (VIR_STRDUP(version, updateSet->version) < 0)
goto cleanup;
- if (updateSet->filterSet == NULL) {
+ if (!updateSet->filterSet) {
continue;
}
for (propertyFilterUpdate = updateSet->filterSet;
- propertyFilterUpdate != NULL;
+ propertyFilterUpdate;
propertyFilterUpdate = propertyFilterUpdate->_next) {
for (objectUpdate = propertyFilterUpdate->objectSet;
- objectUpdate != NULL; objectUpdate = objectUpdate->_next) {
+ objectUpdate; objectUpdate = objectUpdate->_next) {
for (propertyChange = objectUpdate->changeSet;
- propertyChange != NULL;
+ propertyChange;
propertyChange = propertyChange->_next) {
if (STREQ(propertyChange->name, "info.state")) {
if (propertyChange->op == esxVI_PropertyChangeOp_Add ||
}
}
- if (propertyValue == NULL) {
+ if (!propertyValue) {
continue;
}
goto cleanup;
}
- if (taskInfo->error == NULL) {
+ if (!taskInfo->error) {
if (VIR_STRDUP(*errorMessage, _("Unknown error")) < 0)
goto cleanup;
- } else if (taskInfo->error->localizedMessage == NULL) {
+ } else if (!taskInfo->error->localizedMessage) {
if (VIR_STRDUP(*errorMessage, taskInfo->error->fault->_actualType) < 0)
goto cleanup;
} else {
* Remove values given by the caller from the data structures to prevent
* them from being freed by the call to esxVI_PropertyFilterSpec_Free().
*/
- if (objectSpec != NULL) {
+ if (objectSpec) {
objectSpec->obj = NULL;
}
- if (propertySpec != NULL) {
+ if (propertySpec) {
propertySpec->type = NULL;
}
goto cleanup;
}
- if (hostInternetScsiHba == NULL) {
+ if (!hostInternetScsiHba) {
/* iSCSI adapter may not be enabled for this host */
return 0;
}
for (candidate = hostInternetScsiHba->configuredStaticTarget;
- candidate != NULL; candidate = candidate->_next) {
+ candidate; candidate = candidate->_next) {
if (STREQ(candidate->iScsiName, name)) {
break;
}
}
- if (candidate == NULL) {
+ if (!candidate) {
if (occurrence == esxVI_Occurrence_RequiredItem) {
virReportError(VIR_ERR_NO_STORAGE_POOL,
_("Could not find storage pool with name: %s"), name);
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name,
"config.storageDevice.hostBusAdapter")) {
if (esxVI_HostHostBusAdapter_CastListFromAnyType
- (dynamicProperty->val, &hostHostBusAdapterList) < 0 ||
- hostHostBusAdapterList == NULL) {
+ (dynamicProperty->val, &hostHostBusAdapterList) < 0 ||
+ !hostHostBusAdapterList) {
goto cleanup;
}
} else {
/* See vSphere API documentation about HostInternetScsiHba for details */
for (hostHostBusAdapter = hostHostBusAdapterList;
- hostHostBusAdapter != NULL;
+ hostHostBusAdapter;
hostHostBusAdapter = hostHostBusAdapter->_next) {
esxVI_HostInternetScsiHba *candidate=
esxVI_HostInternetScsiHba_DynamicCast(hostHostBusAdapter);
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, "config.storageDevice.scsiLun")) {
if (esxVI_ScsiLun_CastListFromAnyType(dynamicProperty->val,
bool found = false;
esxVI_HostInternetScsiTargetTransport *candidate = NULL;
- if (hostScsiTopologyLunList == NULL || *hostScsiTopologyLunList != NULL) {
+ if (!hostScsiTopologyLunList || *hostScsiTopologyLunList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name,
"config.storageDevice.scsiTopology.adapter")) {
/* See vSphere API documentation about HostScsiTopologyInterface */
for (hostScsiInterface = hostScsiInterfaceList;
- hostScsiInterface != NULL && !found;
+ hostScsiInterface && !found;
hostScsiInterface = hostScsiInterface->_next) {
for (hostScsiTopologyTarget = hostScsiInterface->target;
- hostScsiTopologyTarget != NULL;
+ hostScsiTopologyTarget;
hostScsiTopologyTarget = hostScsiTopologyTarget->_next) {
candidate = esxVI_HostInternetScsiTargetTransport_DynamicCast
(hostScsiTopologyTarget->transport);
- if (candidate != NULL && STREQ(candidate->iScsiName, name)) {
+ if (candidate && STREQ(candidate->iScsiName, name)) {
found = true;
break;
}
}
}
- if (!found || hostScsiTopologyTarget == NULL) {
+ if (!found || !hostScsiTopologyTarget) {
goto cleanup;
}
- if (hostScsiTopologyTarget->lun == NULL) {
+ if (!hostScsiTopologyTarget->lun) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Target not found"));
goto cleanup;
esxVI_HostScsiTopologyLun *hostScsiTopologyLun;
bool found = false;
- if (poolName == NULL || *poolName != NULL) {
+ if (!poolName || *poolName) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
goto cleanup;
}
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name,
"config.storageDevice.scsiTopology.adapter")) {
}
}
- if (hostScsiInterfaceList == NULL) {
+ if (!hostScsiInterfaceList) {
/* iSCSI adapter may not be enabled */
return 0;
}
/* See vSphere API documentation about HostScsiTopologyInterface */
for (hostScsiInterface = hostScsiInterfaceList;
- hostScsiInterface != NULL && !found;
+ hostScsiInterface && !found;
hostScsiInterface = hostScsiInterface->_next) {
for (hostScsiTopologyTarget = hostScsiInterface->target;
- hostScsiTopologyTarget != NULL;
+ hostScsiTopologyTarget;
hostScsiTopologyTarget = hostScsiTopologyTarget->_next) {
candidate = esxVI_HostInternetScsiTargetTransport_DynamicCast
(hostScsiTopologyTarget->transport);
- if (candidate != NULL) {
+ if (candidate) {
/* iterate hostScsiTopologyLun list to find matching key */
for (hostScsiTopologyLun = hostScsiTopologyTarget->lun;
- hostScsiTopologyLun != NULL;
+ hostScsiTopologyLun;
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
if (STREQ(hostScsiTopologyLun->scsiLun, key) &&
VIR_STRDUP(*poolName, candidate->iScsiName) < 0)
esxVI_ObjectContent *objectContentList = NULL; \
esxVI_DynamicProperty *dynamicProperty = NULL; \
\
- if (ptrptr == NULL || *ptrptr != NULL) { \
+ if (!ptrptr || *ptrptr) { \
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \
\
propertyNameList = selectedPropertyNameList; \
\
- if (propertyNameList == NULL && \
+ if (!propertyNameList && \
esxVI_String_AppendValueListToList \
(&propertyNameList, completePropertyNameValueList) < 0) { \
goto cleanup; \
goto cleanup; \
} \
\
- if (objectContent == NULL) { \
+ if (!objectContent) { \
/* not found, exit early */ \
result = 0; \
goto cleanup; \
} \
\
for (dynamicProperty = objectContent->propSet; \
- dynamicProperty != NULL; \
+ dynamicProperty; \
dynamicProperty = dynamicProperty->_next) { \
_cast_from_anytype \
\
esxVI_ObjectContent *candidate = NULL;
char *name_candidate;
- if (objectContent == NULL || *objectContent != NULL ||
- objectContentList == NULL || *objectContentList != NULL) {
+ if (!objectContent || *objectContent ||
+ !objectContentList || *objectContentList) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
}
/* Search for a matching item */
- if (name != NULL) {
- for (candidate = *objectContentList; candidate != NULL;
+ if (name) {
+ for (candidate = *objectContentList; candidate;
candidate = candidate->_next) {
name_candidate = NULL;
candidate = *objectContentList;
}
- if (candidate == NULL) {
+ if (!candidate) {
if (occurrence != esxVI_Occurrence_OptionalItem) {
- if (name != NULL) {
+ if (name) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find %s with name '%s'"), type, name);
} else {