[PATCH 24/32] Convert 'int i' to 'size_t i' in src/libxl/ files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 src/libxl/libxl_conf.c   | 12 ++++++------
 src/libxl/libxl_driver.c | 34 ++++++++++++++++++----------------
 2 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index e170357..aa0588d 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -71,7 +71,7 @@ libxlBuildCapabilities(virArch hostarch,
                        int nr_guest_archs)
 {
     virCapsPtr caps;
-    int i;
+    size_t i;
 
     if ((caps = virCapabilitiesNew(hostarch, 1, 1)) == NULL)
         goto no_memory;
@@ -168,7 +168,7 @@ libxlMakeCapabilitiesInternal(virArch hostarch,
     char *str, *token;
     regmatch_t subs[4];
     char *saveptr = NULL;
-    int i;
+    size_t i;
 
     int host_pae = 0;
     struct guest_arch guest_archs[32];
@@ -336,7 +336,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
 {
     libxl_domain_build_info *b_info = &d_config->b_info;
     int hvm = STREQ(def->os.type, "hvm");
-    int i;
+    size_t i;
 
     libxl_domain_build_info_init(b_info);
 
@@ -574,7 +574,7 @@ libxlMakeDiskList(virDomainDefPtr def, libxl_domain_config *d_config)
     virDomainDiskDefPtr *l_disks = def->disks;
     int ndisks = def->ndisks;
     libxl_device_disk *x_disks;
-    int i;
+    size_t i;
 
     if (VIR_ALLOC_N(x_disks, ndisks) < 0) {
         virReportOOMError();
@@ -646,7 +646,7 @@ libxlMakeNicList(virDomainDefPtr def,  libxl_domain_config *d_config)
     virDomainNetDefPtr *l_nics = def->nets;
     int nnics = def->nnets;
     libxl_device_nic *x_nics;
-    int i;
+    size_t i;
 
     if (VIR_ALLOC_N(x_nics, nnics) < 0) {
         virReportOOMError();
@@ -729,7 +729,7 @@ libxlMakeVfbList(libxlDriverPrivatePtr driver,
     int nvfbs = def->ngraphics;
     libxl_device_vfb *x_vfbs;
     libxl_device_vkb *x_vkbs;
-    int i;
+    size_t i;
 
     if (nvfbs == 0)
         return 0;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ededbbc..0de4e9e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -639,7 +639,7 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
     libxlDomainObjPrivatePtr priv = vm->privateData;
     int vnc_port;
     char *file;
-    int i;
+    size_t i;
 
     if (priv->deathW) {
         libxl_evdisable_domain_death(priv->ctx, priv->deathW);
@@ -833,7 +833,8 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
     uint8_t *cpumap = NULL;
     virNodeInfo nodeinfo;
     size_t cpumaplen;
-    int vcpu, i;
+    int vcpu;
+    size_t i;
     int ret = -1;
 
     if (libxlDoNodeGetInfo(driver, &nodeinfo) < 0)
@@ -881,7 +882,7 @@ libxlFreeMem(libxlDomainObjPrivatePtr priv, libxl_domain_config *d_config)
 {
     uint32_t needed_mem;
     uint32_t free_mem;
-    int i;
+    size_t i;
     int ret = -1;
     int tries = 3;
     int wait_secs = 10;
@@ -2733,7 +2734,8 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
     libxl_bitmap map;
     uint8_t *bitmask = NULL;
     unsigned int maplen;
-    unsigned int i, pos;
+    size_t i;
+    unsigned int pos;
     int max;
     int ret = -1;
 
@@ -3005,7 +3007,7 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
     int ret = -1;
     libxl_vcpuinfo *vcpuinfo;
     int maxcpu, hostcpus;
-    unsigned int i;
+    size_t i;
     unsigned char *cpumap;
 
     libxlDriverLock(driver);
@@ -3417,7 +3419,7 @@ libxlDomainChangeEjectableMedia(libxlDomainObjPrivatePtr priv,
 {
     virDomainDiskDefPtr origdisk = NULL;
     libxl_device_disk x_disk;
-    int i;
+    size_t i;
     int ret = -1;
 
     for (i = 0; i < vm->def->ndisks; i++) {
@@ -3533,22 +3535,22 @@ libxlDomainDetachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
 {
     virDomainDiskDefPtr l_disk = NULL;
     libxl_device_disk x_disk;
-    int i;
+    int idx;
     int ret = -1;
 
     switch (dev->data.disk->device)  {
         case VIR_DOMAIN_DISK_DEVICE_DISK:
             if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_XEN) {
 
-                if ((i = virDomainDiskIndexByName(vm->def,
-                                                  dev->data.disk->dst,
-                                                  false)) < 0) {
+                if ((idx = virDomainDiskIndexByName(vm->def,
+                                                    dev->data.disk->dst,
+                                                    false)) < 0) {
                     virReportError(VIR_ERR_OPERATION_FAILED,
                                    _("disk %s not found"), dev->data.disk->dst);
                     goto cleanup;
                 }
 
-                l_disk = vm->def->disks[i];
+                l_disk = vm->def->disks[idx];
 
                 if (libxlMakeDisk(l_disk, &x_disk) < 0)
                     goto cleanup;
@@ -3561,7 +3563,7 @@ libxlDomainDetachDeviceDiskLive(libxlDomainObjPrivatePtr priv,
                     goto cleanup;
                 }
 
-                virDomainDiskRemove(vm->def, i);
+                virDomainDiskRemove(vm->def, idx);
                 virDomainDiskDefFree(l_disk);
 
             } else {
@@ -3718,18 +3720,18 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
 {
     virDomainDiskDefPtr orig;
     virDomainDiskDefPtr disk;
-    int i;
+    int idx;
     int ret = -1;
 
     switch (dev->type) {
         case VIR_DOMAIN_DEVICE_DISK:
             disk = dev->data.disk;
-            if ((i = virDomainDiskIndexByName(vmdef, disk->dst, false)) < 0) {
+            if ((idx = virDomainDiskIndexByName(vmdef, disk->dst, false)) < 0) {
                 virReportError(VIR_ERR_INVALID_ARG,
                                _("target %s doesn't exist."), disk->dst);
                 goto cleanup;
             }
-            orig = vmdef->disks[i];
+            orig = vmdef->disks[idx];
             if (!(orig->device == VIR_DOMAIN_DISK_DEVICE_CDROM)) {
                 virReportError(VIR_ERR_INVALID_ARG, "%s",
                                _("this disk doesn't support update"));
@@ -4441,7 +4443,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
     virDomainObjPtr vm;
     libxl_domain_sched_params sc_info;
     int sched_id;
-    int i;
+    size_t i;
     int ret = -1;
 
     virCheckFlags(0, -1);
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]