]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Convert 'int i' to 'size_t i' in tests/ files
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 8 Jul 2013 14:09:33 +0000 (15:09 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 10 Jul 2013 16:40:13 +0000 (17:40 +0100)
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>
18 files changed:
tests/commandhelper.c
tests/cputest.c
tests/esxutilstest.c
tests/eventtest.c
tests/nodeinfotest.c
tests/openvzutilstest.c
tests/qemuhelptest.c
tests/qemumonitorjsontest.c
tests/qemumonitortest.c
tests/ssh.c
tests/testutils.c
tests/utiltest.c
tests/viratomictest.c
tests/virbitmaptest.c
tests/vircgrouptest.c
tests/virhashtest.c
tests/virnetsockettest.c
tests/virstoragetest.c

index 10d20462d283b6577f52f3f939025230a4f33961..0c5aa82d15d94fc16938c3409be0f444c930aef3 100644 (file)
@@ -57,7 +57,7 @@ static int envsort(const void *a, const void *b) {
 }
 
 int main(int argc, char **argv) {
-    int i, n;
+    size_t i, n;
     char **origenv;
     char **newenv;
     char *cwd;
@@ -104,7 +104,7 @@ int main(int argc, char **argv) {
         closed = fcntl(i, F_GETFD, &f) == -1 &&
             errno == EBADF;
         if (!closed)
-            fprintf(log, "FD:%d\n", i);
+            fprintf(log, "FD:%zu\n", i);
     }
 
     fprintf(log, "DAEMON:%s\n", getpgrp() == getsid(0) ? "yes" : "no");
index 01054407726f2572b2bda125789afb26fcfc6d13..d08550d429c9df50557520e4a6569d03f9ad076d 100644 (file)
@@ -114,7 +114,7 @@ cpuTestLoadMultiXML(const char *arch,
     xmlNodePtr *nodes = NULL;
     virCPUDefPtr *cpus = NULL;
     int n;
-    int i;
+    size_t i;
 
     if (virAsprintf(&xml, "%s/cputestdata/%s-%s.xml", abs_srcdir, arch, name) < 0)
         goto cleanup;
@@ -326,7 +326,7 @@ cpuTestBaseline(const void *arg)
     virCPUDefPtr baseline = NULL;
     unsigned int ncpus = 0;
     char *result = NULL;
-    unsigned int i;
+    size_t i;
 
     if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
         goto cleanup;
@@ -359,7 +359,7 @@ cpuTestBaseline(const void *arg)
             cmp != VIR_CPU_COMPARE_IDENTICAL) {
             if (virTestGetVerbose()) {
                 fprintf(stderr,
-                        "\nbaseline CPU is incompatible with CPU %u\n", i);
+                        "\nbaseline CPU is incompatible with CPU %zu\n", i);
                 fprintf(stderr, "%74s", "... ");
             }
             ret = -1;
index bb58a3ab287dde33c82606b7cdfa59cc141f2b23..221c46ac5a9a8e4b6e9317b7458aba3c87e6f50e 100644 (file)
@@ -47,7 +47,8 @@ static struct testPath paths[] = {
 static int
 testParseDatastorePath(const void *data ATTRIBUTE_UNUSED)
 {
-    int i, result = 0;
+    int result = 0;
+    size_t i;
     char *datastoreName = NULL;
     char *directoryName = NULL;
     char *directoryAndFileName = NULL;
@@ -135,7 +136,7 @@ static struct testDateTime times[] = {
 static int
 testConvertDateTimeToCalendarTime(const void *data ATTRIBUTE_UNUSED)
 {
-    int i;
+    size_t i;
     esxVI_DateTime dateTime;
     long long calendarTime;
 
@@ -187,7 +188,7 @@ static struct testDatastoreItem datastoreItems[] = {
 static int
 testEscapeDatastoreItem(const void *data ATTRIBUTE_UNUSED)
 {
-    int i;
+    size_t i;
     char *escaped = NULL;
 
     for (i = 0; i < ARRAY_CARDINALITY(datastoreItems); ++i) {
@@ -228,7 +229,7 @@ static struct testWindows1252ToUTF8 windows1252ToUTF8[] = {
 static int
 testConvertWindows1252ToUTF8(const void *data ATTRIBUTE_UNUSED)
 {
-    int i;
+    size_t i;
     char *utf8 = NULL;
 
     for (i = 0; i < ARRAY_CARDINALITY(windows1252ToUTF8); ++i) {
index 97d805a3e80cf3178147ed9e5596a365d4f18a9a..821745faf4b3ba8d26ce09705dea41a8583c6517 100644 (file)
@@ -143,18 +143,18 @@ verifyFired(const char *name, int handle, int timer)
 {
     int handleFired = 0;
     int timerFired = 0;
-    int i;
+    size_t i;
     for (i = 0; i < NUM_FDS; i++) {
         if (handles[i].fired) {
             if (i != handle) {
                 virtTestResult(name, 1,
-                               "Handle %d fired, but expected %d\n", i,
+                               "Handle %zu fired, but expected %d\n", i,
                                handle);
                 return EXIT_FAILURE;
             } else {
                 if (handles[i].error != EV_ERROR_NONE) {
                     virtTestResult(name, 1,
-                                   "Handle %d fired, but had error %d\n", i,
+                                   "Handle %zu fired, but had error %d\n", i,
                                    handles[i].error);
                     return EXIT_FAILURE;
                 }
@@ -181,12 +181,12 @@ verifyFired(const char *name, int handle, int timer)
         if (timers[i].fired) {
             if (i != timer) {
                 virtTestResult(name, 1,
-                               "Timer %d fired, but expected %d\n", i, timer);
+                               "Timer %zu fired, but expected %d\n", i, timer);
                 return EXIT_FAILURE;
             } else {
                 if (timers[i].error != EV_ERROR_NONE) {
                     virtTestResult(name, 1,
-                                   "Timer %d fired, but had error %d\n", i,
+                                   "Timer %zu fired, but had error %d\n", i,
                                    timers[i].error);
                     return EXIT_FAILURE;
                 }
@@ -247,7 +247,7 @@ finishJob(const char *name, int handle, int timer)
 static void
 resetAll(void)
 {
-    int i;
+    size_t i;
     for (i = 0; i < NUM_FDS; i++) {
         handles[i].fired = 0;
         handles[i].error = EV_ERROR_NONE;
@@ -261,7 +261,7 @@ resetAll(void)
 static int
 mymain(void)
 {
-    int i;
+    size_t i;
     pthread_t eventThread;
     char one = '1';
 
index def366cad8b397c200603a9d01898ec5f144b48b..db637cec142cd922d687388ab8247d75b1771831 100644 (file)
@@ -123,7 +123,7 @@ static int
 mymain(void)
 {
     int ret = 0;
-    int i;
+    size_t i;
     const char *nodeData[] = {
         "test1",
 # if !(defined(__powerpc__) ||                  \
index 48500177c55bf6a154d08ec0755bed304073f674..ee68c06ad94f0ffc99e5d7843c900315180e5a2b 100644 (file)
@@ -38,7 +38,7 @@ static int
 testReadConfigParam(const void *data ATTRIBUTE_UNUSED)
 {
     int result = -1;
-    int i;
+    size_t i;
     char *conf = NULL;
     char *value = NULL;
 
index 3826849db3ef773c0023c37a426f427d92130e86..d2fd79407f06a16685e53c56725a316701937181 100644 (file)
@@ -24,15 +24,15 @@ struct testInfo {
 static void printMismatchedFlags(virQEMUCapsPtr got,
                                  virQEMUCapsPtr expect)
 {
-    int i;
+    size_t i;
 
     for (i = 0; i < QEMU_CAPS_LAST; i++) {
         bool gotFlag = virQEMUCapsGet(got, i);
         bool expectFlag = virQEMUCapsGet(expect, i);
         if (gotFlag && !expectFlag)
-            fprintf(stderr, "Extra flag %i\n", i);
+            fprintf(stderr, "Extra flag %zu\n", i);
         if (!gotFlag && expectFlag)
-            fprintf(stderr, "Missing flag %i\n", i);
+            fprintf(stderr, "Missing flag %zu\n", i);
     }
 }
 
index acc94ca611bb9f366e4560ecf89cb07f0e82feb9..14d37000b0637b10a360598970b47a062dd9538c 100644 (file)
@@ -236,7 +236,7 @@ testQemuMonitorJSONGetMachines(const void *data)
     qemuMonitorMachineInfoPtr *info;
     int ninfo = 0;
     const char *null = NULL;
-    int i;
+    size_t i;
 
     if (!test)
         return -1;
@@ -317,7 +317,7 @@ testQemuMonitorJSONGetCPUDefinitions(const void *data)
     int ret = -1;
     char **cpus = NULL;
     int ncpus = 0;
-    int i;
+    size_t i;
 
     if (!test)
         return -1;
@@ -383,7 +383,7 @@ testQemuMonitorJSONGetCommands(const void *data)
     int ret = -1;
     char **commands = NULL;
     int ncommands = 0;
-    int i;
+    size_t i;
 
     if (!test)
         return -1;
index 61ac2d69f1917f2f0d7a9a4142dd40810da88e37..3851251fe08114dcbc6973a556015db50681cc91 100644 (file)
@@ -34,7 +34,7 @@ static struct testEscapeString escapeStrings[] = {
 
 static int testEscapeArg(const void *data ATTRIBUTE_UNUSED)
 {
-    int i;
+    size_t i;
     char *escaped = NULL;
     for (i = 0; i < ARRAY_CARDINALITY(escapeStrings); ++i) {
         escaped = qemuMonitorEscapeArg(escapeStrings[i].unescaped);
@@ -61,7 +61,7 @@ static int testEscapeArg(const void *data ATTRIBUTE_UNUSED)
 
 static int testUnescapeArg(const void *data ATTRIBUTE_UNUSED)
 {
-    int i;
+    size_t i;
     char *unescaped = NULL;
     for (i = 0; i < ARRAY_CARDINALITY(escapeStrings); ++i) {
         unescaped = qemuMonitorUnescapeArg(escapeStrings[i].escaped);
index 56b2e9b6c58edf06cbbd41d8def2019321c42003..76c60d31330a0ed5f935f276985729f70f097247 100644 (file)
@@ -28,7 +28,7 @@
 
 int main(int argc, char **argv)
 {
-    int i;
+    size_t i;
     bool failConnect = false; /* Exit -1, with no data on stdout, msg on stderr */
     bool dieEarly = false;    /* Exit -1, with partial data on stdout, msg on stderr */
 
index 5fc2a9c3f6058d42ea6ecb9b0f75dfcd063e5b4e..ec0fe529e07e479e057963d850b2e7afc95676e0 100644 (file)
@@ -77,7 +77,7 @@ double
 virtTestCountAverage(double *items, int nitems)
 {
     long double sum = 0;
-    int i;
+    size_t i;
 
     for (i=1; i < nitems; i++)
         sum += items[i];
@@ -132,7 +132,8 @@ void virtTestResult(const char *name, int ret, const char *msg, ...)
 int
 virtTestRun(const char *title, int nloops, int (*body)(const void *data), const void *data)
 {
-    int i, ret = 0;
+    int ret = 0;
+    size_t i;
     double *ts = NULL;
 
     if (testCounter == 0 && !virTestGetVerbose())
@@ -265,7 +266,7 @@ virtTestLoadFile(const char *file, char **buf)
 static
 void virtTestCaptureProgramExecChild(const char *const argv[],
                                      int pipefd) {
-    int i;
+    size_t i;
     int open_max;
     int stdinfd = -1;
     const char *const env[] = {
@@ -283,7 +284,8 @@ void virtTestCaptureProgramExecChild(const char *const argv[],
     for (i = 0; i < open_max; i++) {
         if (i != stdinfd &&
             i != pipefd) {
-            int tmpfd = i;
+            int tmpfd;
+            tmpfd = i;
             VIR_FORCE_CLOSE(tmpfd);
         }
     }
@@ -523,7 +525,7 @@ virtTestErrorHook(int n, void *data ATTRIBUTE_UNUSED)
 {
     void *trace[30];
     int ntrace = ARRAY_CARDINALITY(trace);
-    int i;
+    size_t i;
     char **symbols = NULL;
 
     ntrace = backtrace(trace, ntrace);
@@ -665,7 +667,7 @@ int virtTestMain(int argc,
             fprintf(stderr, "%d) OOM of %d allocs ", testCounter, approxAlloc);
 
         if (mp) {
-            int i;
+            size_t i;
             for (i = 0; i < mp; i++) {
                 workers[i] = fork();
                 if (workers[i] == 0) {
@@ -700,7 +702,7 @@ int virtTestMain(int argc,
             if (worker) {
                 _exit(ret);
             } else {
-                int i;
+                size_t i;
                 for (i = 0; i < mp; i++) {
                     if (virProcessWait(workers[i], NULL) < 0)
                         ret = EXIT_FAILURE;
index 9d186526783d4d4c6aa3f5175d8da6803b3b84e0..0cbf3f3dc9f8579bcfb83981ed11833606659213 100644 (file)
@@ -36,7 +36,7 @@ static const char* diskNames[] = {
 static int
 testIndexToDiskName(const void *data ATTRIBUTE_UNUSED)
 {
-    int i;
+    size_t i;
     char *diskName = NULL;
 
     for (i = 0; i < ARRAY_CARDINALITY(diskNames); ++i) {
@@ -62,19 +62,20 @@ testIndexToDiskName(const void *data ATTRIBUTE_UNUSED)
 static int
 testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED)
 {
-    int i, k;
+    size_t i;
+    int idx;
     char *diskName = NULL;
 
     for (i = 0; i < 100000; ++i) {
         VIR_FREE(diskName);
 
         diskName = virIndexToDiskName(i, "sd");
-        k = virDiskNameToIndex(diskName);
+        idx = virDiskNameToIndex(diskName);
 
-        if (k != i) {
+        if (idx < 0 || idx != i) {
             if (virTestGetDebug() > 0) {
-                fprintf(stderr, "\nExpect [%d]\n", i);
-                fprintf(stderr, "Actual [%d]\n", k);
+                fprintf(stderr, "\nExpect [%zu]\n", i);
+                fprintf(stderr, "Actual [%d]\n", idx);
             }
 
             VIR_FREE(diskName);
@@ -115,7 +116,8 @@ static struct testVersionString versions[] = {
 static int
 testParseVersionString(const void *data ATTRIBUTE_UNUSED)
 {
-    int i, result;
+    int result;
+    size_t i;
     unsigned long version;
 
     for (i = 0; i < ARRAY_CARDINALITY(versions); ++i) {
index 1ed1707c5db7c3533cde99b49fe153890a82e32e..40a05b84df65235631490b0cd8a8d343a859fba0 100644 (file)
@@ -115,7 +115,7 @@ static void
 thread_func(void *data)
 {
     int idx = (intptr_t)data;
-    int i;
+    size_t i;
     int d;
 
     for (i = 0; i < ROUNDS; i++) {
@@ -134,7 +134,7 @@ static int
 testThreads(const void *data ATTRIBUTE_UNUSED)
 {
     int sum;
-    int i;
+    size_t i;
     virThread threads[THREADS];
 
     atomic = 0;
index 2464c33bf37e4e753341ba1f815f9122d2d8803f..9c7329ea42116a4d1ac6ddc20cb079c3718c6f5c 100644 (file)
@@ -65,7 +65,7 @@ testBit(virBitmapPtr bitmap,
         unsigned int end,
         bool expected)
 {
-    int i;
+    size_t i;
     bool result;
 
     for (i = start; i <= end; i++) {
@@ -145,7 +145,7 @@ static int test3(const void *data ATTRIBUTE_UNUSED)
     virBitmapPtr bitmap = NULL;
     int ret = -1;
     int size = 5;
-    int i;
+    size_t i;
 
     if ((bitmap = virBitmapNew(size)) == NULL)
         goto error;
@@ -180,7 +180,7 @@ static int test4(const void *data ATTRIBUTE_UNUSED)
         28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
     };
     virBitmapPtr bitmap = NULL;
-    int i, j;
+    ssize_t i, j;
 
     if (ARRAY_CARDINALITY(bitsPos) + ARRAY_CARDINALITY(bitsPosInv) != size)
         goto error;
@@ -268,7 +268,8 @@ static int test5(const void *v ATTRIBUTE_UNUSED)
     int len2;
     int bits[] = {0, 9, 34};
     virBitmapPtr bitmap;
-    int i, j;
+    size_t i;
+    ssize_t j;
     int ret = -1;
 
     bitmap = virBitmapNewData(data, sizeof(data));
index 262eb8ba6b1d04c23a0421f92d0cde6ad23bf0bc..22b40b49061b12e4d5439bd6eadd5c026a155a50 100644 (file)
@@ -41,7 +41,7 @@ static int validateCgroup(virCgroupPtr cgroup,
                           const char **expectLinkPoint,
                           const char **expectPlacement)
 {
-    int i;
+    size_t i;
 
     if (STRNEQ(cgroup->path, expectPath)) {
         fprintf(stderr, "Wrong path '%s', expected '%s'\n",
index b028ead874e833ecaf143638a45f42c0f1f4896a..2430432f920be3fc9612ebc86c29c7cfa4a749e1 100644 (file)
@@ -130,7 +130,7 @@ testHashUpdate(const void *data ATTRIBUTE_UNUSED)
 {
     int count = ARRAY_CARDINALITY(uuids) + ARRAY_CARDINALITY(uuids_new);
     virHashTablePtr hash;
-    int i;
+    size_t i;
     int ret = -1;
 
     if (!(hash = testHashInit(0)))
@@ -172,7 +172,7 @@ testHashRemove(const void *data ATTRIBUTE_UNUSED)
 {
     int count = ARRAY_CARDINALITY(uuids) - ARRAY_CARDINALITY(uuids_subset);
     virHashTablePtr hash;
-    int i;
+    size_t i;
     int ret = -1;
 
     if (!(hash = testHashInit(0)))
@@ -208,7 +208,7 @@ testHashRemoveForEachSome(void *payload ATTRIBUTE_UNUSED,
                           void *data)
 {
     virHashTablePtr hash = data;
-    int i;
+    size_t i;
 
     for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
         if (STREQ(uuids_subset[i], name)) {
@@ -243,7 +243,7 @@ testHashRemoveForEachForbidden(void *payload ATTRIBUTE_UNUSED,
                                void *data)
 {
     virHashTablePtr hash = data;
-    int i;
+    size_t i;
 
     for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
         if (STREQ(uuids_subset[i], name)) {
@@ -299,7 +299,7 @@ testHashSteal(const void *data ATTRIBUTE_UNUSED)
 {
     int count = ARRAY_CARDINALITY(uuids) - ARRAY_CARDINALITY(uuids_subset);
     virHashTablePtr hash;
-    int i;
+    size_t i;
     int ret = -1;
 
     if (!(hash = testHashInit(0)))
@@ -404,7 +404,7 @@ testHashRemoveSetIter(const void *payload ATTRIBUTE_UNUSED,
 {
     int *count = (int *) data;
     bool rem = false;
-    int i;
+    size_t i;
 
     for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
         if (STREQ(uuids_subset[i], name)) {
index 4c5a0eab238059a83fdaf864476b106d0b5a6ca4..5b434ba9e845c4e73a8381fc1b4602fb8a32d845 100644 (file)
@@ -52,7 +52,7 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6,
     struct sockaddr_in in4;
     struct sockaddr_in6 in6;
     int s4 = -1, s6 = -1;
-    int i;
+    size_t i;
     int ret = -1;
 
     memset(&hints, 0, sizeof(hints));
index 61d36f7c3494c7c3d85ade553b9b4f0101de145c..a3c59efaaeee9a4f07be07c35f7765ac22ea5857 100644 (file)
@@ -218,7 +218,7 @@ testStorageChain(const void *args)
     int ret = -1;
     virStorageFileMetadataPtr meta;
     virStorageFileMetadataPtr elt;
-    int i = 0;
+    size_t i = 0;
 
     meta = virStorageFileGetMetadata(data->start, data->format, -1, -1,
                                      (data->flags & ALLOW_PROBE) != 0);