From: "Daniel P. Berrange" <berrange(a)redhat.com>
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int'
or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/esx/esx_driver.c | 10 +++++-----
src/esx/esx_interface_driver.c | 2 +-
src/esx/esx_network_driver.c | 4 ++--
src/esx/esx_storage_backend_iscsi.c | 4 ++--
src/esx/esx_storage_backend_vmfs.c | 4 ++--
src/esx/esx_storage_driver.c | 10 +++++-----
src/esx/esx_util.c | 2 +-
src/esx/esx_vi.c | 18 +++++++++---------
src/vmware/vmware_conf.c | 4 ++--
src/vmx/vmx.c | 24 +++++++++++++-----------
10 files changed, 42 insertions(+), 40 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index a5df810..8030cc0 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2891,7 +2891,7 @@ esxConnectListDefinedDomains(virConnectPtr conn, char **const names,
int maxname
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState;
int count = 0;
- int i;
+ size_t i;
if (maxnames == 0) {
return 0;
@@ -3046,7 +3046,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
esxPrivate *priv = conn->privateData;
virDomainDefPtr def = NULL;
char *vmx = NULL;
- int i;
+ size_t i;
virDomainDiskDefPtr disk = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
int virtualHW_version;
@@ -3583,7 +3583,7 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_SharesInfo *sharesInfo = NULL;
unsigned int mask = 0;
- int i = 0;
+ size_t i = 0;
virCheckFlags(0, -1);
@@ -3707,7 +3707,7 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- int i;
+ size_t i;
virCheckFlags(0, -1);
if (virTypedParamsValidate(params, nparams,
@@ -4871,7 +4871,7 @@ esxDomainSetMemoryParameters(virDomainPtr domain,
virTypedParameterPtr params,
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- int i;
+ size_t i;
virCheckFlags(0, -1);
if (virTypedParamsValidate(params, nparams,
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index 7875ccf..2cee3b7 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -102,7 +102,7 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int
maxnames)
esxVI_PhysicalNic *physicalNicList = NULL;
esxVI_PhysicalNic *physicalNic = NULL;
int count = 0;
- int i;
+ size_t i;
if (maxnames == 0) {
return 0;
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index 9aacffc..35a4bac 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -109,7 +109,7 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int
maxnames)
esxVI_HostVirtualSwitch *hostVirtualSwitchList = NULL;
esxVI_HostVirtualSwitch *hostVirtualSwitch = NULL;
int count = 0;
- int i;
+ size_t i;
if (maxnames == 0) {
return 0;
@@ -330,7 +330,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
esxVI_PhysicalNic *physicalNicList = NULL;
esxVI_PhysicalNic *physicalNic = NULL;
esxVI_HostPortGroupSpec *hostPortGroupSpec = NULL;
- int i;
+ size_t i;
unsigned char md5[MD5_DIGEST_SIZE]; /* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index 6e1095e..c740475 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -103,7 +103,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
esxPrivate *priv = conn->storagePrivateData;
esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL;
esxVI_HostInternetScsiHbaStaticTarget *target;
- int i;
+ size_t i;
if (maxnames == 0) {
return 0;
@@ -394,7 +394,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
esxVI_HostScsiTopologyLun *hostScsiTopologyLun;
esxVI_ScsiLun *scsiLunList = NULL;
esxVI_ScsiLun *scsiLun = NULL;
- int i;
+ size_t i;
if (esxVI_LookupHostScsiTopologyLunListByTargetName
(priv->primary, pool->name, &hostScsiTopologyLunList) < 0) {
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 2966109..6321fe3 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -146,7 +146,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
esxVI_ObjectContent *datastoreList = NULL;
esxVI_ObjectContent *datastore = NULL;
int count = 0;
- int i;
+ size_t i;
if (maxnames == 0) {
return 0;
@@ -573,7 +573,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
char *directoryAndFileName = NULL;
size_t length;
int count = 0;
- int i;
+ size_t i;
if (names == NULL || maxnames < 0) {
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument"));
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index 3c60f00..e692167 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -87,7 +87,7 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
{
int count = 0;
esxPrivate *priv = conn->storagePrivateData;
- int i;
+ size_t i;
int tmp;
if (esxVI_EnsureSession(priv->primary) < 0) {
@@ -115,7 +115,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int
maxnames)
bool success = false;
esxPrivate *priv = conn->storagePrivateData;
int count = 0;
- int i;
+ size_t i;
int tmp;
if (maxnames == 0) {
@@ -176,7 +176,7 @@ static virStoragePoolPtr
esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
{
esxPrivate *priv = conn->storagePrivateData;
- int i;
+ size_t i;
virStoragePoolPtr pool;
virCheckNonNullArgReturn(name, NULL);
@@ -205,7 +205,7 @@ static virStoragePoolPtr
esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
esxPrivate *priv = conn->storagePrivateData;
- int i;
+ size_t i;
virStoragePoolPtr pool;
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
@@ -411,7 +411,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
{
virStorageVolPtr volume;
esxPrivate *priv = conn->storagePrivateData;
- int i;
+ size_t i;
if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index a4b931d..65359ae 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -44,7 +44,7 @@ int
esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
{
int result = -1;
- int i;
+ size_t i;
int noVerify;
int autoAnswer;
char *tmp;
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 8dc2592..c5b1894 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -490,7 +490,7 @@ static void
esxVI_SharedCURL_Lock(CURL *handle ATTRIBUTE_UNUSED, curl_lock_data data,
curl_lock_access access_ ATTRIBUTE_UNUSED, void *userptr)
{
- int i;
+ size_t i;
esxVI_SharedCURL *shared = userptr;
switch (data) {
@@ -518,7 +518,7 @@ static void
esxVI_SharedCURL_Unlock(CURL *handle ATTRIBUTE_UNUSED, curl_lock_data data,
void *userptr)
{
- int i;
+ size_t i;
esxVI_SharedCURL *shared = userptr;
switch (data) {
@@ -548,7 +548,7 @@ ESX_VI__TEMPLATE__ALLOC(SharedCURL)
/* esxVI_SharedCURL_Free */
ESX_VI__TEMPLATE__FREE(SharedCURL,
{
- int i;
+ size_t i;
if (item->count > 0) {
/* Better leak than crash */
@@ -568,7 +568,7 @@ ESX_VI__TEMPLATE__FREE(SharedCURL,
int
esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_CURL *curl)
{
- int i;
+ size_t i;
if (curl->handle == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1438,7 +1438,7 @@ int
esxVI_Enumeration_CastFromAnyType(const esxVI_Enumeration *enumeration,
esxVI_AnyType *anyType, int *value)
{
- int i;
+ size_t i;
if (anyType == NULL || value == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
@@ -1473,7 +1473,7 @@ int
esxVI_Enumeration_Serialize(const esxVI_Enumeration *enumeration,
int value, const char *element, virBufferPtr output)
{
- int i;
+ size_t i;
const char *name = NULL;
if (element == NULL || output == NULL) {
@@ -1511,7 +1511,7 @@ int
esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration,
xmlNodePtr node, int *value)
{
- int i;
+ size_t i;
int result = -1;
char *name = NULL;
@@ -2579,7 +2579,7 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree
*snapshotTreeList,
{
int count = 0;
int result;
- int i;
+ size_t i;
esxVI_VirtualMachineSnapshotTree *snapshotTree;
for (snapshotTree = snapshotTreeList;
@@ -4544,7 +4544,7 @@ esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo
*parsedHostCpuIdInfo,
char *output[4] = { parsedHostCpuIdInfo->eax, parsedHostCpuIdInfo->ebx,
parsedHostCpuIdInfo->ecx, parsedHostCpuIdInfo->edx };
const char *name[4] = { "eax", "ebx", "ecx",
"edx" };
- int r, i, o;
+ size_t r, i, o;
memset(parsedHostCpuIdInfo, 0, sizeof(*parsedHostCpuIdInfo));
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index 9d3d37e..200745e 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -261,7 +261,7 @@ cleanup:
int
vmwareDomainConfigDisplay(vmwareDomainPtr pDomain, virDomainDefPtr def)
{
- int i = 0;
+ size_t i;
if (def->ngraphics == 0) {
pDomain->gui = true;
@@ -336,7 +336,7 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath)
char *directoryName = NULL;
char *fileName = NULL;
int ret = -1;
- int i = 0;
+ size_t i;
/*
* Build VMX URL. Use the source of the first file-based harddisk
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 5464d13..681c8d5 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1058,7 +1058,8 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def,
virDomainDiskDefPtr disk)
{
char *tmp;
- int model, i;
+ int model;
+ size_t i;
virDomainControllerDefPtr controller = NULL;
if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI || disk->driverName == NULL) {
@@ -1114,7 +1115,7 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr
def,
int virtualDev[4], bool present[4])
{
int result = -1;
- int i, k;
+ size_t i, k;
virDomainDiskDefPtr disk;
virDomainControllerDefPtr controller;
bool controllerHasDisksAttached;
@@ -3019,7 +3020,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
virDomainDe
int virtualHW_version)
{
char *vmx = NULL;
- int i;
+ size_t i;
int sched_cpu_affinity_length;
unsigned char zero[VIR_UUID_BUFLEN];
virBuffer buffer = VIR_BUFFER_INITIALIZER;
@@ -3158,12 +3159,13 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr
xmlopt, virDomainDe
/* def:cpumask -> vmx:sched.cpu.affinity */
if (def->cpumask && virBitmapSize(def->cpumask) > 0) {
+ int bit;
virBufferAddLit(&buffer, "sched.cpu.affinity = \"");
sched_cpu_affinity_length = 0;
- i = -1;
- while ((i = virBitmapNextSetBit(def->cpumask, i)) >= 0) {
+ bit = -1;
+ while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0) {
++sched_cpu_affinity_length;
}
@@ -3175,9 +3177,9 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
virDomainDe
goto cleanup;
}
- i = -1;
- while ((i = virBitmapNextSetBit(def->cpumask, i)) >= 0) {
- virBufferAsprintf(&buffer, "%d", i);
+ bit = -1;
+ while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0) {
+ virBufferAsprintf(&buffer, "%d", bit);
if (sched_cpu_affinity_length > 1) {
virBufferAddChar(&buffer, ',');
@@ -3237,10 +3239,10 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr
xmlopt, virDomainDe
for (i = 0; i < 4; ++i) {
if (scsi_present[i]) {
- virBufferAsprintf(&buffer, "scsi%d.present =
\"true\"\n", i);
+ virBufferAsprintf(&buffer, "scsi%zu.present =
\"true\"\n", i);
if (scsi_virtualDev[i] != -1) {
- virBufferAsprintf(&buffer, "scsi%d.virtualDev =
\"%s\"\n", i,
+ virBufferAsprintf(&buffer, "scsi%zu.virtualDev =
\"%s\"\n", i,
virVMXControllerModelSCSITypeToString
(scsi_virtualDev[i]));
}
@@ -3282,7 +3284,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
virDomainDe
for (i = 0; i < 2; ++i) {
/* floppy[0..1].present defaults to true, disable it explicitly */
if (! floppy_present[i]) {
- virBufferAsprintf(&buffer, "floppy%d.present =
\"false\"\n", i);
+ virBufferAsprintf(&buffer, "floppy%zu.present =
\"false\"\n", i);
}
}
--
1.8.1.4