Convert 'int i' to 'size_t i' in tests/ files

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>
This commit is contained in:
Daniel P. Berrange 2013-07-08 15:09:33 +01:00
parent f8b42f3224
commit 7a1e691711
18 changed files with 62 additions and 56 deletions

View 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");

View 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;

View 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) {

View 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';

View File

@ -123,7 +123,7 @@ static int
mymain(void)
{
int ret = 0;
int i;
size_t i;
const char *nodeData[] = {
"test1",
# if !(defined(__powerpc__) || \

View 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;

View 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);
}
}

View 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;

View 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);

View 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 */

View 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;

View 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) {

View 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;

View 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));

View 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",

View 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)) {

View 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));

View 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);