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

[libvirt] [PATCH 28/32] Convert 'int i' to 'size_t i' in src/cpu/ files



From: "Daniel P. Berrange" <berrange 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 redhat com>
---
 src/cpu/cpu.c         | 22 +++++++++++-----------
 src/cpu/cpu_generic.c |  6 +++---
 src/cpu/cpu_powerpc.c |  2 +-
 src/cpu/cpu_x86.c     | 26 +++++++++++++-------------
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 68125a5..45725d7 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -50,8 +50,8 @@ static struct cpuArchDriver *drivers[] = {
 static struct cpuArchDriver *
 cpuGetSubDriver(virArch arch)
 {
-    unsigned int i;
-    unsigned int j;
+    size_t i;
+    size_t j;
 
     if (arch == VIR_ARCH_NONE) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -140,9 +140,9 @@ cpuDecode(virCPUDefPtr cpu,
     VIR_DEBUG("cpu=%p, data=%p, nmodels=%u, preferred=%s",
               cpu, data, nmodels, NULLSTR(preferred));
     if (models) {
-        unsigned int i;
+        size_t i;
         for (i = 0; i < nmodels; i++)
-            VIR_DEBUG("models[%u]=%s", i, NULLSTR(models[i]));
+            VIR_DEBUG("models[%zu]=%s", i, NULLSTR(models[i]));
     }
 
     if (models == NULL && nmodels != 0) {
@@ -284,16 +284,16 @@ cpuBaselineXML(const char **xmlCPUs,
     virCPUDefPtr *cpus = NULL;
     virCPUDefPtr cpu = NULL;
     char *cpustr;
-    unsigned int i;
+    size_t i;
 
     VIR_DEBUG("ncpus=%u, nmodels=%u", ncpus, nmodels);
     if (xmlCPUs) {
         for (i = 0; i < ncpus; i++)
-            VIR_DEBUG("xmlCPUs[%u]=%s", i, NULLSTR(xmlCPUs[i]));
+            VIR_DEBUG("xmlCPUs[%zu]=%s", i, NULLSTR(xmlCPUs[i]));
     }
     if (models) {
         for (i = 0; i < nmodels; i++)
-            VIR_DEBUG("models[%u]=%s", i, NULLSTR(models[i]));
+            VIR_DEBUG("models[%zu]=%s", i, NULLSTR(models[i]));
     }
 
     if (xmlCPUs == NULL && ncpus != 0) {
@@ -356,16 +356,16 @@ cpuBaseline(virCPUDefPtr *cpus,
             unsigned int nmodels)
 {
     struct cpuArchDriver *driver;
-    unsigned int i;
+    size_t i;
 
     VIR_DEBUG("ncpus=%u, nmodels=%u", ncpus, nmodels);
     if (cpus) {
         for (i = 0; i < ncpus; i++)
-            VIR_DEBUG("cpus[%u]=%p", i, cpus[i]);
+            VIR_DEBUG("cpus[%zu]=%p", i, cpus[i]);
     }
     if (models) {
         for (i = 0; i < nmodels; i++)
-            VIR_DEBUG("models[%u]=%s", i, NULLSTR(models[i]));
+            VIR_DEBUG("models[%zu]=%s", i, NULLSTR(models[i]));
     }
 
     if (cpus == NULL && ncpus != 0) {
@@ -448,7 +448,7 @@ cpuModelIsAllowed(const char *model,
                   const char **models,
                   unsigned int nmodels)
 {
-    unsigned int i;
+    size_t i;
 
     if (!models || !nmodels)
         return true;
diff --git a/src/cpu/cpu_generic.c b/src/cpu/cpu_generic.c
index 7e3eda2..1dbaaa7 100644
--- a/src/cpu/cpu_generic.c
+++ b/src/cpu/cpu_generic.c
@@ -37,7 +37,7 @@ static virHashTablePtr
 genericHashFeatures(virCPUDefPtr cpu)
 {
     virHashTablePtr hash;
-    unsigned int i;
+    size_t i;
 
     if ((hash = virHashCreate(cpu->nfeatures, NULL)) == NULL)
         return NULL;
@@ -61,7 +61,7 @@ genericCompare(virCPUDefPtr host,
 {
     virHashTablePtr hash;
     virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
-    unsigned int i;
+    size_t i;
     unsigned int reqfeatures;
 
     if (((cpu->arch != VIR_ARCH_NONE) &&
@@ -121,7 +121,7 @@ genericBaseline(virCPUDefPtr *cpus,
     virCPUFeatureDefPtr features = NULL;
     unsigned int nfeatures;
     unsigned int count;
-    unsigned int i, j;
+    size_t i, j;
 
     if (!cpuModelIsAllowed(cpus[0]->model, models, nmodels)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index d17f9ca..1a2b41c 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -391,7 +391,7 @@ ppcBaseline(virCPUDefPtr *cpus,
     const struct ppc_model *model;
     const struct ppc_vendor *vendor = NULL;
     virCPUDefPtr cpu = NULL;
-    unsigned int i;
+    size_t i;
 
     if (!(map = ppcLoadMap()))
         goto error;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 5d479c2..ce1e15f 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -185,7 +185,7 @@ x86DataCpuid(const union cpuData *data,
 {
     struct cpuX86cpuid *cpuids;
     int len;
-    unsigned int i;
+    size_t i;
 
     if (function < CPUX86_EXTENDED) {
         cpuids = data->x86.basic;
@@ -221,7 +221,7 @@ static union cpuData *
 x86DataCopy(const union cpuData *data)
 {
     union cpuData *copy = NULL;
-    int i;
+    size_t i;
 
     if (VIR_ALLOC(copy) < 0
         || VIR_ALLOC_N(copy->x86.basic, data->x86.basic_len) < 0
@@ -307,7 +307,7 @@ static int
 x86DataAdd(union cpuData *data1,
            const union cpuData *data2)
 {
-    unsigned int i;
+    size_t i;
 
     if (x86DataExpand(data1,
                       data2->x86.basic_len - data1->x86.basic_len,
@@ -332,7 +332,7 @@ static void
 x86DataSubtract(union cpuData *data1,
                 const union cpuData *data2)
 {
-    unsigned int i;
+    size_t i;
     unsigned int len;
 
     len = MIN(data1->x86.basic_len, data2->x86.basic_len);
@@ -656,7 +656,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
     xmlNodePtr ctxt_node = ctxt->node;
     struct x86_feature *feature;
     int ret = 0;
-    int i;
+    size_t i;
     int n;
 
     if (!(feature = x86FeatureNew()))
@@ -695,7 +695,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
         if (ret_fun < 0 || ret_eax == -2 || ret_ebx == -2
             || ret_ecx == -2 || ret_edx == -2) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Invalid cpuid[%d] in %s feature"), i, feature->name);
+                           _("Invalid cpuid[%zu] in %s feature"), i, feature->name);
             goto ignore;
         }
 
@@ -803,7 +803,7 @@ x86ModelFromCPU(const virCPUDefPtr cpu,
                 int policy)
 {
     struct x86_model *model = NULL;
-    int i;
+    size_t i;
 
     if (policy == VIR_CPU_FEATURE_REQUIRE) {
         if ((model = x86ModelFind(map, cpu->model)) == NULL) {
@@ -854,7 +854,7 @@ x86ModelSubtractCPU(struct x86_model *model,
                     const struct x86_map *map)
 {
     const struct x86_model *cpu_model;
-    unsigned int i;
+    size_t i;
 
     if (!(cpu_model = x86ModelFind(map, cpu->model))) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -936,7 +936,7 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
     struct x86_model *model;
     char *vendor = NULL;
     int ret = 0;
-    int i;
+    size_t i;
     int n;
 
     if (!(model = x86ModelNew()))
@@ -1154,7 +1154,7 @@ x86Compute(virCPUDefPtr host,
     struct x86_model *guest_model = NULL;
     virCPUCompareResult ret;
     enum compare_result result;
-    unsigned int i;
+    size_t i;
 
     if (cpu->arch != VIR_ARCH_NONE) {
         bool found = false;
@@ -1309,7 +1309,7 @@ x86Decode(virCPUDefPtr cpu,
     const struct x86_model *candidate;
     virCPUDefPtr cpuCandidate;
     virCPUDefPtr cpuModel = NULL;
-    unsigned int i;
+    size_t i;
 
     if (data == NULL || (map = x86LoadMap()) == NULL)
         return -1;
@@ -1615,7 +1615,7 @@ x86Baseline(virCPUDefPtr *cpus,
     struct x86_map *map = NULL;
     struct x86_model *base_model = NULL;
     virCPUDefPtr cpu = NULL;
-    unsigned int i;
+    size_t i;
     const struct x86_vendor *vendor = NULL;
     struct x86_model *model = NULL;
     bool outputVendor = true;
@@ -1720,7 +1720,7 @@ x86UpdateCustom(virCPUDefPtr guest,
                 const virCPUDefPtr host)
 {
     int ret = -1;
-    unsigned int i;
+    size_t i;
     struct x86_map *map;
     struct x86_model *host_model = NULL;
 
-- 
1.8.1.4


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