Index: generators/TableGenerator.m ================================================================== --- generators/TableGenerator.m +++ generators/TableGenerator.m @@ -173,23 +173,22 @@ - (void)writeTablesToFile: (OFString*)path { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"wb"]; - of_unichar_t i, j; [file writeString: COPYRIGHT @"#include \"config.h\"\n" @"\n" @"#import \"OFString.h\"\n\n" @"static const of_unichar_t emptyPage[0x100] = { 0 };\n\n"]; /* Write uppercasePage%u */ - for (i = 0; i < 0x110000; i += 0x100) { + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { bool isEmpty = true; - for (j = i; j < i + 0x100; j++) { + for (of_unichar_t j = i; j < i + 0x100; j++) { if (_uppercaseTable[j] != 0) { isEmpty = false; _uppercaseTableSize = i >> 8; _uppercaseTableUsed[_uppercaseTableSize] = 1; break; @@ -201,11 +200,11 @@ [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"uppercasePage%u[0x100] = {\n", i >> 8]]; - for (j = i; j < i + 0x100; j += 8) + for (of_unichar_t j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", _uppercaseTable[j], _uppercaseTable[j + 1], _uppercaseTable[j + 2], @@ -220,14 +219,14 @@ objc_autoreleasePoolPop(pool2); } } /* Write lowercasePage%u */ - for (i = 0; i < 0x110000; i += 0x100) { + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { bool isEmpty = true; - for (j = i; j < i + 0x100; j++) { + for (of_unichar_t j = i; j < i + 0x100; j++) { if (_lowercaseTable[j] != 0) { isEmpty = false; _lowercaseTableSize = i >> 8; _lowercaseTableUsed[_lowercaseTableSize] = 1; break; @@ -239,11 +238,11 @@ [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"lowercasePage%u[0x100] = {\n", i >> 8]]; - for (j = i; j < i + 0x100; j += 8) + for (of_unichar_t j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", _lowercaseTable[j], _lowercaseTable[j + 1], _lowercaseTable[j + 2], @@ -258,14 +257,14 @@ objc_autoreleasePoolPop(pool2); } } /* Write titlecasePage%u if it does NOT match uppercasePage%u */ - for (i = 0; i < 0x110000; i += 0x100) { + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { bool isEmpty = true; - for (j = i; j < i + 0x100; j++) { + for (of_unichar_t j = i; j < i + 0x100; j++) { if (_titlecaseTable[j] != 0) { isEmpty = !memcmp(_uppercaseTable + i, _titlecaseTable + i, 256 * sizeof(of_unichar_t)); _titlecaseTableSize = i >> 8; @@ -280,11 +279,11 @@ [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"titlecasePage%u[0x100] = {\n", i >> 8]]; - for (j = i; j < i + 0x100; j += 8) + for (of_unichar_t j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", _titlecaseTable[j], _titlecaseTable[j + 1], _titlecaseTable[j + 2], @@ -299,14 +298,14 @@ objc_autoreleasePoolPop(pool2); } } /* Write casefoldingPage%u if it does NOT match lowercasePage%u */ - for (i = 0; i < 0x110000; i += 0x100) { + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { bool isEmpty = true; - for (j = i; j < i + 0x100; j++) { + for (of_unichar_t j = i; j < i + 0x100; j++) { if (_casefoldingTable[j] != 0) { isEmpty = !memcmp(_lowercaseTable + i, _casefoldingTable + i, 256 * sizeof(of_unichar_t)); _casefoldingTableSize = i >> 8; @@ -321,11 +320,11 @@ [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"casefoldingPage%u[0x100] = {\n", i >> 8]]; - for (j = i; j < i + 0x100; j += 8) + for (of_unichar_t j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", _casefoldingTable[j], _casefoldingTable[j + 1], _casefoldingTable[j + 2], @@ -353,11 +352,11 @@ /* Write of_unicode_uppercase_table */ [file writeString: [OFString stringWithFormat: @"const of_unichar_t* const of_unicode_uppercase_table[0x%X] = " @"{\n\t", _uppercaseTableSize]]; - for (i = 0; i < _uppercaseTableSize; i++) { + for (of_unichar_t i = 0; i < _uppercaseTableSize; i++) { if (_uppercaseTableUsed[i]) { [file writeString: [OFString stringWithFormat: @"uppercasePage%u", i]]; } else [file writeString: @"emptyPage"]; @@ -375,11 +374,11 @@ /* Write of_unicode_lowercase_table */ [file writeString: [OFString stringWithFormat: @"const of_unichar_t* const of_unicode_lowercase_table[0x%X] = " @"{\n\t", _lowercaseTableSize]]; - for (i = 0; i < _lowercaseTableSize; i++) { + for (of_unichar_t i = 0; i < _lowercaseTableSize; i++) { if (_lowercaseTableUsed[i]) { [file writeString: [OFString stringWithFormat: @"lowercasePage%u", i]]; } else [file writeString: @"emptyPage"]; @@ -397,11 +396,11 @@ /* Write of_unicode_titlecase_table */ [file writeString: [OFString stringWithFormat: @"const of_unichar_t* const of_unicode_titlecase_table[0x%X] = {" @"\n\t", _titlecaseTableSize]]; - for (i = 0; i < _titlecaseTableSize; i++) { + for (of_unichar_t i = 0; i < _titlecaseTableSize; i++) { if (_titlecaseTableUsed[i] == 1) { [file writeString: [OFString stringWithFormat: @"titlecasePage%u", i]]; } else if (_titlecaseTableUsed[i] == 2) { [file writeString: [OFString stringWithFormat: @@ -422,11 +421,11 @@ /* Write of_unicode_casefolding_table */ [file writeString: [OFString stringWithFormat: @"const of_unichar_t* const of_unicode_casefolding_table[0x%X] = " @"{\n\t", _casefoldingTableSize]]; - for (i = 0; i < _casefoldingTableSize; i++) { + for (of_unichar_t i = 0; i < _casefoldingTableSize; i++) { if (_casefoldingTableUsed[i] == 1) { [file writeString: [OFString stringWithFormat: @"casefoldingPage%u", i]]; } else if (_casefoldingTableUsed[i] == 2) { [file writeString: [OFString stringWithFormat: Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -333,11 +333,10 @@ andArgumentValues: (char***)argv { #ifndef OF_WINDOWS void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; - int i; of_string_encoding_t encoding; _argc = argc; _argv = argv; @@ -352,11 +351,11 @@ _programName = [[OFString alloc] initWithCString: (*argv)[0] encoding: encoding]; arguments = [[OFMutableArray alloc] init]; _arguments = arguments; - for (i = 1; i < *argc; i++) + for (int i = 1; i < *argc; i++) [arguments addObject: [OFString stringWithCString: (*argv)[i] encoding: encoding]]; [arguments makeImmutable]; @@ -373,17 +372,16 @@ - (void)OF_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t**)argv { void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; - int i; if (argc > 0) { _programName = [[OFString alloc] initWithUTF16String: argv[0]]; arguments = [[OFMutableArray alloc] init]; - for (i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) [arguments addObject: [OFString stringWithUTF16String: argv[i]]]; [arguments makeImmutable]; _arguments = arguments; Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -232,13 +232,11 @@ } - (void)getObjects: (id*)buffer inRange: (of_range_t)range { - size_t i; - - for (i = 0; i < range.length; i++) + for (size_t i = 0; i < range.length; i++) buffer[i] = [self objectAtIndex: range.location + i]; } - (id const*)objects { @@ -445,11 +443,11 @@ - (bool)isEqual: (id)object { /* FIXME: Optimize (for example, buffer of 16 for each) */ OFArray *otherArray; - size_t i, count; + size_t count; if (![object isKindOfClass: [OFArray class]]) return false; otherArray = object; @@ -457,11 +455,11 @@ count = [self count]; if (count != [otherArray count]) return false; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) if (![[self objectAtIndex: i] isEqual: [otherArray objectAtIndex: i]]) return false; return true; Index: src/OFArray_adjacent.m ================================================================== --- src/OFArray_adjacent.m +++ src/OFArray_adjacent.m @@ -86,11 +86,11 @@ } - initWithArray: (OFArray*)array { id const *objects; - size_t i, count; + size_t count; self = [super init]; if (array == nil) return self; @@ -105,17 +105,17 @@ [self release]; @throw e; } @try { - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [objects[i] retain]; [_array addItems: objects count: count]; } @catch (id e) { - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [objects[i] release]; /* Prevent double-release of objects */ [_array release]; _array = nil; @@ -131,14 +131,13 @@ count: (size_t)count { self = [self init]; @try { - size_t i; bool ok = true; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if (objects[i] == nil) ok = false; [objects[i] retain]; } @@ -147,13 +146,11 @@ @throw [OFInvalidArgumentException exception]; [_array addItems: objects count: count]; } @catch (id e) { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [objects[i] release]; [self release]; @throw e; } @@ -216,50 +213,50 @@ - (void)getObjects: (id*)buffer inRange: (of_range_t)range { id *objects = [_array items]; - size_t i, count = [_array count]; + size_t count = [_array count]; if (range.length > SIZE_MAX - range.location || range.location + range.length > count) @throw [OFOutOfRangeException exception]; - for (i = 0; i < range.length; i++) + for (size_t i = 0; i < range.length; i++) buffer[i] = objects[range.location + i]; } - (size_t)indexOfObject: (id)object { id *objects; - size_t i, count; + size_t count; if (object == nil) return OF_NOT_FOUND; objects = [_array items]; count = [_array count]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) if ([objects[i] isEqual: object]) return i; return OF_NOT_FOUND; } - (size_t)indexOfObjectIdenticalTo: (id)object { id *objects; - size_t i, count; + size_t count; if (object == nil) return OF_NOT_FOUND; objects = [_array items]; count = [_array count]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) if (objects[i] == object) return i; return OF_NOT_FOUND; } @@ -282,11 +279,11 @@ - (bool)isEqual: (id)object { OFArray *otherArray; id const *objects, *otherObjects; - size_t i, count; + size_t count; if (![object isKindOfClass: [OFArray_adjacent class]] && ![object isKindOfClass: [OFMutableArray_adjacent class]]) return [super isEqual: object]; @@ -298,26 +295,26 @@ return false; objects = [_array items]; otherObjects = [otherArray objects]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) if (![objects[i] isEqual: otherObjects[i]]) return false; return true; } - (uint32_t)hash { id *objects = [_array items]; - size_t i, count = [_array count]; + size_t count = [_array count]; uint32_t hash; OF_HASH_INIT(hash); - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) OF_HASH_ADD_HASH(hash, [objects[i] hash]); OF_HASH_FINALIZE(hash); return hash; @@ -350,26 +347,26 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { id *objects = [_array items]; - size_t i, count = [_array count]; + size_t count = [_array count]; bool stop = false; - for (i = 0; i < count && !stop; i++) + for (size_t i = 0; i < count && !stop; i++) block(objects[i], i, &stop); } #endif - (void)dealloc { id *objects = [_array items]; - size_t i, count = [_array count]; + size_t count = [_array count]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [objects[i] release]; [_array release]; [super dealloc]; } @end Index: src/OFArray_adjacentSubarray.m ================================================================== --- src/OFArray_adjacentSubarray.m +++ src/OFArray_adjacentSubarray.m @@ -28,11 +28,10 @@ - (bool)isEqual: (id)object { OFArray *otherArray; id const *objects, *otherObjects; - size_t i; if (![object isKindOfClass: [OFArray_adjacent class]] && ![object isKindOfClass: [OFMutableArray_adjacent class]]) return [super isEqual: object]; @@ -42,11 +41,11 @@ return false; objects = [self objects]; otherObjects = [otherArray objects]; - for (i = 0; i < _range.length; i++) + for (size_t i = 0; i < _range.length; i++) if (![objects[i] isEqual: otherObjects[i]]) return false; return true; } @@ -53,13 +52,12 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { id const *objects = [self objects]; - size_t i; bool stop = false; - for (i = 0; i < _range.length && !stop; i++) + for (size_t i = 0; i < _range.length && !stop; i++) block(objects[i], i, &stop); } #endif @end Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -53,13 +53,11 @@ #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OFAutoreleasePool **cache = of_tlskey_get(cacheKey); #endif if (cache != NULL) { - unsigned i; - - for (i = 0; i < MAX_CACHE_SIZE; i++) { + for (size_t i = 0; i < MAX_CACHE_SIZE; i++) { if (cache[i] != NULL) { OFAutoreleasePool *pool = cache[i]; cache[i] = NULL; return pool; } @@ -77,14 +75,13 @@ + (void)OF_handleThreadTermination { #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OFAutoreleasePool **cache = of_tlskey_get(cacheKey); #endif - size_t i; if (cache != NULL) { - for (i = 0; i < MAX_CACHE_SIZE; i++) + for (size_t i = 0; i < MAX_CACHE_SIZE; i++) [cache[i] OF_super_dealloc]; free(cache); cache = NULL; } @@ -156,13 +153,11 @@ } #endif } if (cache != NULL) { - unsigned i; - - for (i = 0; i < MAX_CACHE_SIZE; i++) { + for (size_t i = 0; i < MAX_CACHE_SIZE; i++) { if (cache[i] == NULL) { _pool = NULL; _ignoreRelease = false; cache[i] = self; Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -308,13 +308,11 @@ @implementation OFBlock + (void)load { #ifndef OF_HAVE_ATOMIC_OPS - size_t i; - - for (i = 0; i < NUM_SPINLOCKS; i++) + for (size_t i = 0; i < NUM_SPINLOCKS; i++) if (!of_spinlock_new(&spinlocks[i])) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif Index: src/OFCountedSet.m ================================================================== --- src/OFCountedSet.m +++ src/OFCountedSet.m @@ -237,13 +237,13 @@ if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; for (id object in countedSet) { - size_t i, count = [countedSet countForObject: object]; + size_t count = [countedSet countForObject: object]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [self removeObject: object]; } } else for (id object in set) [self removeObject: object]; @@ -257,17 +257,17 @@ if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; for (id object in countedSet) { - size_t i, count = [countedSet countForObject: object]; + size_t count = [countedSet countForObject: object]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [self addObject: object]; } } else for (id object in set) [self addObject: object]; objc_autoreleasePoolPop(pool); } @end Index: src/OFCountedSet_hashtable.m ================================================================== --- src/OFCountedSet_hashtable.m +++ src/OFCountedSet_hashtable.m @@ -45,15 +45,14 @@ if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)countedSet; for (id object in countedSet) { - size_t i, count; + size_t count = + [countedSet countForObject: object]; - count = [countedSet countForObject: object]; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [self addObject: object]; } } else for (id object in set) [self addObject: object]; @@ -71,13 +70,13 @@ { self = [self init]; @try { id const *objects = [array objects]; - size_t i, count = [array count]; + size_t count = [array count]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [self addObject: objects[i]]; } @catch (id e) { [self release]; @throw e; } @@ -89,13 +88,11 @@ count: (size_t)count { self = [self init]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [self addObject: objects[i]]; } @catch (id e) { [self release]; @throw e; } Index: src/OFDataArray+Hashing.m ================================================================== --- src/OFDataArray+Hashing.m +++ src/OFDataArray+Hashing.m @@ -35,17 +35,16 @@ void *pool = objc_autoreleasePoolPush(); id hash = [hashClass hash]; size_t digestSize = [hashClass digestSize]; const uint8_t *digest; char cString[digestSize * 2]; - size_t i; [hash updateWithBuffer: _items length: _count * _itemSize]; digest = [hash digest]; - for (i = 0; i < digestSize; i++) { + for (size_t i = 0; i < digestSize; i++) { uint8_t high, low; high = digest[i] >> 4; low = digest[i] & 0x0F; Index: src/OFDataArray+MessagePackValue.m ================================================================== --- src/OFDataArray+MessagePackValue.m +++ src/OFDataArray+MessagePackValue.m @@ -55,21 +55,20 @@ static size_t parseArray(const uint8_t *buffer, size_t length, id *object, size_t count) { void *pool; - size_t i, pos; + size_t pos = 0; /* * Don't use capacity! For data and strings, this is safe, as we can * check if we still have enough bytes left. For an array however, we * can't know this, as every child can be more than one byte. */ *object = [OFMutableArray array]; - pos = 0; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { id child; size_t childLength; pool = objc_autoreleasePoolPush(); @@ -92,21 +91,20 @@ static size_t parseTable(const uint8_t *buffer, size_t length, id *object, size_t count) { void *pool; - size_t i, pos; + size_t pos = 0; /* * Don't use capacity! For data and strings, this is safe, as we can * check if we still have enough bytes left. For a dictionary however, * we can't know this, as every key / value can be more than one byte. */ *object = [OFMutableDictionary dictionary]; - pos = 0; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { id key, value; size_t keyLength, valueLength; pool = objc_autoreleasePoolPush(); @@ -138,11 +136,11 @@ } static size_t parseObject(const uint8_t *buffer, size_t length, id *object) { - size_t i, count; + size_t count; int8_t type; OFDataArray *data; if (length < 1) goto error; @@ -242,11 +240,11 @@ } f; if (length < 5) goto error; - for (i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) f.u8[i] = buffer[i + 1]; *object = [OFNumber numberWithFloat: OF_BSWAP_FLOAT_IF_LE(f.f)]; return 5; case 0xCB:; /* float 64 */ @@ -256,11 +254,11 @@ } d; if (length < 9) goto error; - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) d.u8[i] = buffer[i + 1]; *object = [OFNumber numberWithDouble: OF_BSWAP_DOUBLE_IF_LE(d.d)]; return 9; Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -267,11 +267,11 @@ - initWithStringRepresentation: (OFString*)string { @try { const char *cString; - size_t i, count; + size_t count; count = [string cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII]; if (count % 2 != 0) @@ -282,11 +282,11 @@ self = [self initWithCapacity: count]; cString = [string cStringWithEncoding: OF_STRING_ENCODING_ASCII]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { uint8_t c1 = cString[2 * i]; uint8_t c2 = cString[2 * i + 1]; uint8_t byte; if (c1 >= '0' && c1 <= '9') @@ -569,15 +569,14 @@ } - (uint32_t)hash { uint32_t hash; - size_t i; OF_HASH_INIT(hash); - for (i = 0; i < _count * _itemSize; i++) + for (size_t i = 0; i < _count * _itemSize; i++) OF_HASH_ADD(hash, ((uint8_t*)_items)[i]); OF_HASH_FINALIZE(hash); return hash; @@ -584,19 +583,16 @@ } - (OFString*)description { OFMutableString *ret = [OFMutableString stringWithString: @"<"]; - size_t i; - for (i = 0; i < _count; i++) { - size_t j; - + for (size_t i = 0; i < _count; i++) { if (i > 0) [ret appendString: @" "]; - for (j = 0; j < _itemSize; j++) + for (size_t j = 0; j < _itemSize; j++) [ret appendFormat: @"%02x", _items[i * _itemSize + j]]; } [ret appendString: @">"]; @@ -605,14 +601,13 @@ } - (OFString*)stringRepresentation { OFMutableString *ret = [OFMutableString string]; - size_t i, j; - for (i = 0; i < _count; i++) - for (j = 0; j < _itemSize; j++) + for (size_t i = 0; i < _count; i++) + for (size_t j = 0; j < _itemSize; j++) [ret appendFormat: @"%02x", _items[i * _itemSize + j]]; [ret makeImmutable]; return ret; } Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -355,17 +355,16 @@ uint32_t hash; union { double d; uint8_t b[sizeof(double)]; } d; - uint8_t i; d.d = OF_BSWAP_DOUBLE_IF_BE(_seconds); OF_HASH_INIT(hash); - for (i = 0; i < sizeof(double); i++) + for (size_t i = 0; i < sizeof(double); i++) OF_HASH_ADD(hash, d.b[i]); OF_HASH_FINALIZE(hash); return hash; Index: src/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -396,11 +396,11 @@ forKey: (OFString*)key { void *pool; OFMutableArray *pairs; id const *lines; - size_t i, count; + size_t count; bool replaced; if ([array count] == 0) { [self removeValueForKey: key]; return; @@ -425,11 +425,11 @@ lines = [_lines objects]; count = [_lines count]; replaced = false; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { OFINICategory_Pair *pair; if (![lines[i] isKindOfClass: [OFINICategory_Pair class]]) continue; @@ -463,13 +463,13 @@ - (void)removeValueForKey: (OFString*)key { void *pool = objc_autoreleasePoolPush(); id const *lines = [_lines objects]; - size_t i, count = [_lines count]; + size_t count = [_lines count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { OFINICategory_Pair *pair; if (![lines[i] isKindOfClass: [OFINICategory_Pair class]]) continue; Index: src/OFINIFile.m ================================================================== --- src/OFINIFile.m +++ src/OFINIFile.m @@ -35,13 +35,13 @@ static bool isWhitespaceLine(OFString *line) { const char *cString = [line UTF8String]; - size_t i, length = [line UTF8StringLength]; + size_t length = [line UTF8StringLength]; - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { switch (cString[i]) { case ' ': case '\t': case '\n': case '\r': Index: src/OFInflateStream.m ================================================================== --- src/OFInflateStream.m +++ src/OFInflateStream.m @@ -106,15 +106,14 @@ static bool tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; - uint8_t i; assert(stream->_savedBitsLength < count); - for (i = stream->_savedBitsLength; i < count; i++) { + for (uint8_t i = stream->_savedBitsLength; i < count; i++) { if OF_UNLIKELY (stream->_bitIndex == 8) { if (stream->_bufferIndex < stream->_bufferLength) stream->_byte = stream->_buffer[stream->_bufferIndex++]; else { @@ -184,13 +183,12 @@ constructTree(uint8_t lengths[], uint16_t count) { struct huffman_tree *tree; uint16_t lengthCount[MAX_BITS + 1] = { 0 }; uint16_t code, maxCode = 0, nextCode[MAX_BITS + 1]; - uint16_t i; - for (i = 0; i < count; i++) { + for (uint16_t i = 0; i < count; i++) { uint8_t length = lengths[i]; if OF_UNLIKELY (length > MAX_BITS) @throw [OFInvalidFormatException exception]; @@ -199,18 +197,18 @@ maxCode = i; } } code = 0; - for (i = 1; i <= MAX_BITS; i++) { + for (size_t i = 1; i <= MAX_BITS; i++) { code = (code + lengthCount[i - 1]) << 1; nextCode[i] = code; } tree = newTree(); - for (i = 0; i <= maxCode; i++) { + for (uint16_t i = 0; i <= maxCode; i++) { uint8_t length = lengths[i]; if (length > 0) treeInsert(tree, nextCode[length]++, length, i); } @@ -241,40 +239,37 @@ } static void releaseTree(struct huffman_tree *tree) { - uint8_t i; - - for (i = 0; i < 2; i++) + for (uint8_t i = 0; i < 2; i++) if OF_LIKELY (tree->leafs[i] != NULL) releaseTree(tree->leafs[i]); free(tree); } @implementation OFInflateStream + (void)initialize { - uint16_t i; uint8_t lengths[288]; if (self != [OFInflateStream class]) return; - for (i = 0; i <= 143; i++) + for (uint16_t i = 0; i <= 143; i++) lengths[i] = 8; - for (i = 144; i <= 255; i++) + for (uint16_t i = 144; i <= 255; i++) lengths[i] = 9; - for (i = 256; i <= 279; i++) + for (uint16_t i = 256; i <= 279; i++) lengths[i] = 7; - for (i = 280; i <= 287; i++) + for (uint16_t i = 280; i <= 287; i++) lengths[i] = 8; fixedLitLenTree = constructTree(lengths, 288); - for (i = 0; i <= 31; i++) + for (uint16_t i = 0; i <= 31; i++) lengths[i] = 5; fixedDistTree = constructTree(lengths, 32); } @@ -310,11 +305,11 @@ - (size_t)lowlevelReadIntoBuffer: (void*)buffer_ length: (size_t)length { uint8_t *buffer = buffer_; - uint16_t bits, i, tmp; + uint16_t bits, tmp; uint16_t value; size_t bytesWritten = 0; uint8_t *slidingWindow; uint16_t slidingWindowIndex; @@ -415,11 +410,11 @@ memset(_slidingWindow, 0, _slidingWindowMask + 1); } slidingWindow = _slidingWindow; slidingWindowIndex = _slidingWindowIndex; - for (i = 0; i < tmp; i++) { + for (uint16_t i = 0; i < tmp; i++) { slidingWindow[slidingWindowIndex] = buffer[bytesWritten + i]; slidingWindowIndex = (slidingWindowIndex + 1) & _slidingWindowMask; } @@ -465,11 +460,11 @@ if OF_LIKELY (CTX.lengths == NULL) { CTX.lengths = [self allocMemoryWithSize: 19]; memset(CTX.lengths, 0, 19); } - for (i = CTX.receivedCount; + for (uint16_t i = CTX.receivedCount; i < CTX.codeLenCodesCount + 4; i++) { if OF_UNLIKELY (!tryReadBits(self, &bits, 3)) { CTX.receivedCount = i; return bytesWritten; } @@ -488,11 +483,11 @@ if OF_LIKELY (CTX.lengths == NULL) CTX.lengths = [self allocMemoryWithSize: CTX.litLenCodesCount + CTX.distCodesCount + 258]; - for (i = CTX.receivedCount; + for (uint16_t i = CTX.receivedCount; i < CTX.litLenCodesCount + CTX.distCodesCount + 258;) { uint8_t j, count; if OF_LIKELY (CTX.value == 0xFF) { if OF_UNLIKELY (!walkTree(self, &CTX.treeIter, Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -117,14 +117,13 @@ OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, [_name hash]); if (_typeEncoding != NULL) { - size_t i, length; + size_t length = strlen(_typeEncoding); - length = strlen(_typeEncoding); - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) OF_HASH_ADD(hash, _typeEncoding[i]); } OF_HASH_FINALIZE(hash); @@ -438,11 +437,10 @@ Method *methodList; objc_property_t *propertyList; Ivar *ivarList; unsigned count; #endif - unsigned i; void *pool; _classMethods = [[OFMutableArray alloc] init]; _instanceMethods = [[OFMutableArray alloc] init]; _properties = [[OFMutableArray alloc] init]; @@ -451,11 +449,11 @@ #if defined(OF_OBJFW_RUNTIME) for (methodList = object_getClass(class)->methodlist; methodList != NULL; methodList = methodList->next) { pool = objc_autoreleasePoolPush(); - for (i = 0; i < methodList->count; i++) + for (unsigned int i = 0; i < methodList->count; i++) [_classMethods addObject: [[[OFMethod alloc] OF_initWithMethod: &methodList->methods[i]] autorelease]]; objc_autoreleasePoolPop(pool); @@ -463,11 +461,11 @@ for (methodList = class->methodlist; methodList != NULL; methodList = methodList->next) { pool = objc_autoreleasePoolPush(); - for (i = 0; i < methodList->count; i++) + for (unsigned int i = 0; i < methodList->count; i++) [_instanceMethods addObject: [[[OFMethod alloc] OF_initWithMethod: &methodList->methods[i]] autorelease]]; objc_autoreleasePoolPop(pool); @@ -475,11 +473,11 @@ for (propertyList = class->properties; propertyList != NULL; propertyList = propertyList->next) { pool = objc_autoreleasePoolPush(); - for (i = 0; i < propertyList->count; i++) + for (unsigned int i = 0; i < propertyList->count; i++) [_properties addObject: [[[OFProperty alloc] OF_initWithProperty: &propertyList->properties[i]] autorelease]]; objc_autoreleasePoolPop(pool); @@ -486,11 +484,11 @@ } if (class->ivars != NULL) { pool = objc_autoreleasePoolPush(); - for (i = 0; i < class->ivars->count; i++) + for (unsigned int i = 0; i < class->ivars->count; i++) [_instanceVariables addObject: [[[OFInstanceVariable alloc] OF_initWithIvar: &class->ivars->ivars[i]] autorelease]]; @@ -500,11 +498,11 @@ methodList = class_copyMethodList(object_getClass(class), &count); @try { pool = objc_autoreleasePoolPush(); - for (i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) [_classMethods addObject: [[[OFMethod alloc] OF_initWithMethod: methodList[i]] autorelease]]; objc_autoreleasePoolPop(pool); @@ -514,11 +512,11 @@ methodList = class_copyMethodList(class, &count); @try { pool = objc_autoreleasePoolPush(); - for (i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) [_instanceMethods addObject: [[[OFMethod alloc] OF_initWithMethod: methodList[i]] autorelease]]; objc_autoreleasePoolPop(pool); @@ -528,11 +526,11 @@ propertyList = class_copyPropertyList(class, &count); @try { pool = objc_autoreleasePoolPush(); - for (i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) [_properties addObject: [[[OFProperty alloc] OF_initWithProperty: propertyList[i]] autorelease]]; objc_autoreleasePoolPop(pool); @@ -542,11 +540,11 @@ ivarList = class_copyIvarList(class, &count); @try { pool = objc_autoreleasePoolPush(); - for (i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) [_instanceVariables addObject: [[[OFInstanceVariable alloc] OF_initWithIvar: ivarList[i]] autorelease]]; objc_autoreleasePoolPop(pool); Index: src/OFKernelEventObserver_LockedQueue.m ================================================================== --- src/OFKernelEventObserver_LockedQueue.m +++ src/OFKernelEventObserver_LockedQueue.m @@ -175,16 +175,16 @@ @try { #endif int *queueActions = [_queueActions items]; int *queueFDs = [_queueFDs items]; id const *queueObjects = [_queueObjects objects]; - size_t i, count = [_queueActions count]; + size_t count = [_queueActions count]; OF_ENSURE([_queueFDs count] == count); OF_ENSURE([_queueObjects count] == count); - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { int action = queueActions[i]; int fd = queueFDs[i]; id object = queueObjects[i]; switch (action) { Index: src/OFKernelEventObserver_epoll.m ================================================================== --- src/OFKernelEventObserver_epoll.m +++ src/OFKernelEventObserver_epoll.m @@ -209,11 +209,11 @@ - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { OFNull *nullObject = [OFNull null]; void *pool = objc_autoreleasePoolPush(); struct epoll_event eventList[EVENTLIST_SIZE]; - int i, events; + int events; [self OF_processReadBuffers]; objc_autoreleasePoolPop(pool); @@ -222,11 +222,11 @@ if (events < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; - for (i = 0; i < events; i++) { + for (int i = 0; i < events; i++) { if (eventList[i].data.ptr == nullObject) { char buffer; assert(eventList[i].events == EPOLLIN); OF_ENSURE(read(_cancelFD[0], &buffer, 1) == 1); Index: src/OFKernelEventObserver_kqueue.m ================================================================== --- src/OFKernelEventObserver_kqueue.m +++ src/OFKernelEventObserver_kqueue.m @@ -206,11 +206,11 @@ - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { void *pool = objc_autoreleasePoolPush(); struct timespec timeout; struct kevent eventList[EVENTLIST_SIZE]; - int i, events; + int events; timeout.tv_sec = (time_t)timeInterval; timeout.tv_nsec = lrint((timeInterval - timeout.tv_sec) * 1000000000); [self OF_processReadBuffers]; @@ -222,11 +222,11 @@ if (events < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; - for (i = 0; i < events; i++) { + for (int i = 0; i < events; i++) { if (eventList[i].flags & EV_ERROR) @throw [OFObserveFailedException exceptionWithObserver: self errNo: (int)eventList[i].data]; Index: src/OFKernelEventObserver_poll.m ================================================================== --- src/OFKernelEventObserver_poll.m +++ src/OFKernelEventObserver_poll.m @@ -73,14 +73,14 @@ - (void)OF_addObject: (id)object fileDescriptor: (int)fd events: (short)events { struct pollfd *FDs = [_FDs items]; - size_t i, count = [_FDs count]; + size_t count = [_FDs count]; bool found = false; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if (FDs[i].fd == fd) { FDs[i].events |= events; found = true; break; } @@ -104,13 +104,13 @@ - (void)OF_removeObject: (id)object fileDescriptor: (int)fd events: (short)events { struct pollfd *FDs = [_FDs items]; - size_t i, nFDs = [_FDs count]; + size_t nFDs = [_FDs count]; - for (i = 0; i < nFDs; i++) { + for (size_t i = 0; i < nFDs; i++) { if (FDs[i].fd == fd) { FDs[i].events &= ~events; if (FDs[i].events == 0) { /* @@ -160,11 +160,11 @@ - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { void *pool = objc_autoreleasePoolPush(); struct pollfd *FDs; int events; - size_t i, nFDs; + size_t nFDs; [self OF_processQueue]; [self OF_processReadBuffers]; objc_autoreleasePoolPop(pool); @@ -182,11 +182,11 @@ if (events < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; - for (i = 0; i < nFDs; i++) { + for (size_t i = 0; i < nFDs; i++) { assert(FDs[i].fd <= _maxFD); if (FDs[i].revents & POLLIN) { if (FDs[i].fd == _cancelFD[0]) { char buffer; Index: src/OFKernelEventObserver_select.m ================================================================== --- src/OFKernelEventObserver_select.m +++ src/OFKernelEventObserver_select.m @@ -136,11 +136,11 @@ id const *objects; fd_set readFDs; fd_set writeFDs; struct timeval timeout; int events; - size_t i, count; + size_t count; [self OF_processQueue]; [self OF_processReadBuffers]; objc_autoreleasePoolPop(pool); @@ -185,11 +185,11 @@ } objects = [_readObjects objects]; count = [_readObjects count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { int fd; pool = objc_autoreleasePoolPush(); fd = [objects[i] fileDescriptorForReading]; @@ -201,11 +201,11 @@ } objects = [_writeObjects objects]; count = [_writeObjects count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { int fd; pool = objc_autoreleasePoolPush(); fd = [objects[i] fileDescriptorForWriting]; Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -65,13 +65,12 @@ return self; } - (void)dealloc { - of_list_object_t *iter; - - for (iter = _firstListObject; iter != NULL; iter = iter->next) + for (of_list_object_t *iter = _firstListObject; + iter != NULL; iter = iter->next) [iter->object release]; [super dealloc]; } @@ -227,30 +226,28 @@ return true; } - (bool)containsObject: (id)object { - of_list_object_t *iter; - if (_count == 0) return false; - for (iter = _firstListObject; iter != NULL; iter = iter->next) + for (of_list_object_t *iter = _firstListObject; + iter != NULL; iter = iter->next) if ([iter->object isEqual: object]) return true; return false; } - (bool)containsObjectIdenticalTo: (id)object { - of_list_object_t *iter; - if (_count == 0) return false; - for (iter = _firstListObject; iter != NULL; iter = iter->next) + for (of_list_object_t *iter = _firstListObject; + iter != NULL; iter = iter->next) if (iter->object == object) return true; return false; } @@ -272,17 +269,18 @@ } - copy { OFList *copy = [[[self class] alloc] init]; - of_list_object_t *iter, *listObject, *previous; + of_list_object_t *listObject, *previous; listObject = NULL; previous = NULL; @try { - for (iter = _firstListObject; iter != NULL; iter = iter->next) { + for (of_list_object_t *iter = _firstListObject; + iter != NULL; iter = iter->next) { listObject = [copy allocMemoryWithSize: sizeof(of_list_object_t)]; listObject->object = [iter->object retain]; listObject->next = NULL; listObject->previous = previous; @@ -306,16 +304,16 @@ return copy; } - (uint32_t)hash { - of_list_object_t *iter; uint32_t hash; OF_HASH_INIT(hash); - for (iter = _firstListObject; iter != NULL; iter = iter->next) + for (of_list_object_t *iter = _firstListObject; + iter != NULL; iter = iter->next) OF_HASH_ADD_HASH(hash, [iter->object hash]); OF_HASH_FINALIZE(hash); return hash; @@ -322,18 +320,18 @@ } - (OFString*)description { OFMutableString *ret; - of_list_object_t *iter; if (_count == 0) return @"[]"; ret = [OFMutableString stringWithString: @"[\n"]; - for (iter = _firstListObject; iter != NULL; iter = iter->next) { + for (of_list_object_t *iter = _firstListObject; + iter != NULL; iter = iter->next) { void *pool = objc_autoreleasePoolPush(); [ret appendString: [iter->object description]]; if (iter->next != NULL) @@ -350,17 +348,16 @@ return ret; } - (OFXMLElement*)XMLElementBySerializing { - OFXMLElement *element; - of_list_object_t *iter; + OFXMLElement *element = + [OFXMLElement elementWithName: [self className] + namespace: OF_SERIALIZATION_NS]; - element = [OFXMLElement elementWithName: [self className] - namespace: OF_SERIALIZATION_NS]; - - for (iter = _firstListObject; iter != NULL; iter = iter->next) { + for (of_list_object_t *iter = _firstListObject; + iter != NULL; iter = iter->next) { void *pool = objc_autoreleasePoolPush(); [element addChild: [iter->object XMLElementBySerializing]]; objc_autoreleasePoolPop(pool); @@ -372,11 +369,10 @@ - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count { of_list_object_t *listObject; - int i; memcpy(&listObject, state->extra, sizeof(listObject)); state->itemsPtr = objects; state->mutationsPtr = &_mutations; @@ -384,11 +380,11 @@ if (state->state == 0) { listObject = _firstListObject; state->state = 1; } - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { if (listObject == NULL) return i; objects[i] = listObject->object; listObject = listObject->next; Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -63,13 +63,11 @@ static OF_INLINE void byteSwapVectorIfBE(uint32_t *vector, uint8_t length) { #ifdef OF_BIG_ENDIAN - uint8_t i; - - for (i = 0; i < length; i++) + for (uint8_t i = 0; i < length; i++) vector[i] = OF_BSWAP32(vector[i]); #endif } static void Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -180,13 +180,11 @@ return self; } - (void)dealloc { - uint32_t i; - - for (i = 0; i < _capacity; i++) { + for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { _keyFunctions.release(_buckets[i]->key); _valueFunctions.release(_buckets[i]->value); } } @@ -195,11 +193,10 @@ } - (bool)isEqual: (id)object { OFMapTable *mapTable; - uint32_t i; if (![object isKindOfClass: [OFMapTable class]]) return false; mapTable = object; @@ -207,11 +204,11 @@ if (mapTable->_count != _count || mapTable->_keyFunctions.equal != _keyFunctions.equal || mapTable->_valueFunctions.equal != _valueFunctions.equal) return false; - for (i = 0; i < _capacity; i++) { + for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { void *value = [mapTable valueForKey: _buckets[i]->key]; if (!_valueFunctions.equal(value, _buckets[i]->value)) return false; @@ -221,13 +218,13 @@ return true; } - (uint32_t)hash { - uint32_t i, hash = 0; + uint32_t hash = 0; - for (i = 0; i < _capacity; i++) { + for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { hash += OF_ROR(_buckets[i]->hash, _rotate); hash += _valueFunctions.hash(_buckets[i]->value); } } @@ -241,13 +238,11 @@ initWithKeyFunctions: _keyFunctions valueFunctions: _valueFunctions capacity: _capacity]; @try { - uint32_t i; - - for (i = 0; i < _capacity; i++) + for (uint32_t i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) [copy OF_setValue: _buckets[i]->value forKey: _buckets[i]->key hash: OF_ROR(_buckets[i]->hash, _rotate)]; @@ -299,11 +294,11 @@ return NULL; } - (void)OF_resizeForCount: (uint32_t)count { - uint32_t i, fullness, capacity; + uint32_t fullness, capacity; struct of_map_table_bucket **buckets; if (count > UINT32_MAX / sizeof(*_buckets) || count > UINT32_MAX / 8) @throw [OFOutOfRangeException exception]; @@ -329,11 +324,11 @@ buckets = [self allocMemoryWithSize: sizeof(*buckets) count: capacity]; memset(buckets, 0, capacity * sizeof(*buckets)); - for (i = 0; i < _capacity; i++) { + for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { uint32_t j, last; last = capacity; @@ -512,13 +507,11 @@ } } - (void)removeAllValues { - uint32_t i; - - for (i = 0; i < _capacity; i++) { + for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL) { if (_buckets[i] == &deleted) { _buckets[i] = NULL; continue; } @@ -551,31 +544,27 @@ #endif } - (bool)containsValue: (void*)value { - uint32_t i; - if (value == NULL || _count == 0) return false; - for (i = 0; i < _capacity; i++) + for (uint32_t i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) if (_valueFunctions.equal(_buckets[i]->value, value)) return true; return false; } - (bool)containsValueIdenticalTo: (void*)value { - uint32_t i; - if (value == NULL || _count == 0) return false; - for (i = 0; i < _capacity; i++) + for (uint32_t i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) if (_buckets[i]->value == value) return true; return false; @@ -626,15 +615,14 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndValuesUsingBlock: (of_map_table_enumeration_block_t)block { - size_t i; bool stop = false; unsigned long mutations = _mutations; - for (i = 0; i < _capacity && !stop; i++) { + for (size_t i = 0; i < _capacity && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; if (_buckets[i] != NULL && _buckets[i] != &deleted) @@ -642,14 +630,13 @@ } } - (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block { - size_t i; unsigned long mutations = _mutations; - for (i = 0; i < _capacity; i++) { + for (size_t i = 0; i < _capacity; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; if (_buckets[i] != NULL && _buckets[i] != &deleted) { Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -242,18 +242,18 @@ } - (void)replaceObject: (id)oldObject withObject: (id)newObject { - size_t i, count; + size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; count = [self count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: oldObject]) { [self replaceObjectAtIndex: i withObject: newObject]; return; } @@ -261,18 +261,18 @@ } - (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { - size_t i, count; + size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; count = [self count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if ([self objectAtIndex: i] == oldObject) { [self replaceObjectAtIndex: i withObject: newObject]; return; @@ -285,18 +285,18 @@ OF_UNRECOGNIZED_SELECTOR } - (void)removeObject: (id)object { - size_t i, count; + size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; count = [self count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: object]) { [self removeObjectAtIndex: i]; return; } @@ -303,18 +303,18 @@ } } - (void)removeObjectIdenticalTo: (id)object { - size_t i, count; + size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; count = [self count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if ([self objectAtIndex: i] == object) { [self removeObjectAtIndex: i]; return; } @@ -321,13 +321,11 @@ } } - (void)removeObjectsInRange: (of_range_t)range { - size_t i; - - for (i = 0; i < range.length; i++) + for (size_t i = 0; i < range.length; i++) [self removeObjectAtIndex: range.location]; } - (void)removeLastObject { Index: src/OFMutableArray_adjacent.m ================================================================== --- src/OFMutableArray_adjacent.m +++ src/OFMutableArray_adjacent.m @@ -78,39 +78,39 @@ - (void)insertObjectsFromArray: (OFArray*)array atIndex: (size_t)index { id const *objects = [array objects]; - size_t i, count = [array count]; + size_t count = [array count]; @try { [_array insertItems: objects atIndex: index count: count]; } @catch (OFOutOfRangeException *e) { @throw [OFOutOfRangeException exception]; } - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [objects[i] retain]; _mutations++; } - (void)replaceObject: (id)oldObject withObject: (id)newObject { id *objects; - size_t i, count; + size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if ([objects[i] isEqual: oldObject]) { [newObject retain]; [objects[i] release]; objects[i] = newObject; @@ -140,19 +140,19 @@ - (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { id *objects; - size_t i, count; + size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if (objects[i] == oldObject) { [newObject retain]; [objects[i] release]; objects[i] = newObject; @@ -162,19 +162,19 @@ } - (void)removeObject: (id)object { id *objects; - size_t i, count; + size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if ([objects[i] isEqual: object]) { object = objects[i]; [_array removeItemAtIndex: i]; _mutations++; @@ -187,19 +187,19 @@ } - (void)removeObjectIdenticalTo: (id)object { id *objects; - size_t i, count; + size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if (objects[i] == object) { [_array removeItemAtIndex: i]; _mutations++; [object release]; @@ -219,22 +219,22 @@ } - (void)removeAllObjects { id *objects = [_array items]; - size_t i, count = [_array count]; + size_t count = [_array count]; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [objects[i] release]; [_array removeAllItems]; } - (void)removeObjectsInRange: (of_range_t)range { id *objects = [_array items], *copy; - size_t i, count = [_array count]; + size_t count = [_array count]; if (range.length > SIZE_MAX - range.location || range.length > count - range.location) @throw [OFOutOfRangeException exception]; @@ -244,11 +244,11 @@ @try { [_array removeItemsInRange: range]; _mutations++; - for (i = 0; i < range.length; i++) + for (size_t i = 0; i < range.length; i++) [copy[i] release]; } @finally { [self freeMemory: copy]; } } @@ -336,15 +336,15 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { id *objects = [_array items]; - size_t i, count = [_array count]; + size_t count = [_array count]; bool stop = false; unsigned long mutations = _mutations; - for (i = 0; i < count && !stop; i++) { + for (size_t i = 0; i < count && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; block(objects[i], i, &stop); @@ -352,14 +352,14 @@ } - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block { id *objects = [_array items]; - size_t i, count = [_array count]; + size_t count = [_array count]; unsigned long mutations = _mutations; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { id new; if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -245,14 +245,14 @@ wordStartTableSize: (size_t)startTableSize wordMiddleTableSize: (size_t)middleTableSize { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; - size_t i, length = [self length]; + size_t length = [self length]; bool isStart = true; - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { const of_unichar_t *const *table; size_t tableSize; of_unichar_t c = characters[i]; if (isStart) { @@ -469,11 +469,10 @@ void *pool = objc_autoreleasePoolPush(), *pool2; const of_unichar_t *characters; const of_unichar_t *searchCharacters = [string characters]; size_t searchLength = [string length]; size_t replacementLength = [replacement length]; - size_t i; if (range.length > SIZE_MAX - range.location || range.location + range.length > [self length]) @throw [OFOutOfRangeException exception]; @@ -483,11 +482,11 @@ } pool2 = objc_autoreleasePoolPush(); characters = [self characters]; - for (i = range.location; i <= range.length - searchLength; i++) { + for (size_t i = range.location; i <= range.length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t)) != 0) continue; [self replaceCharactersInRange: of_range(i, searchLength) Index: src/OFMutableString_UTF8.m ================================================================== --- src/OFMutableString_UTF8.m +++ src/OFMutableString_UTF8.m @@ -387,14 +387,14 @@ { char *tmp; tmp = [self allocMemoryWithSize: (length * 4) + 1]; @try { - size_t i, j = 0; + size_t j = 0; bool isUTF8 = false; - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { size_t len = of_string_utf8_encode(characters[i], tmp + j); if (len == 0) @throw [OFInvalidEncodingException exception]; @@ -647,11 +647,11 @@ { const char *searchString = [string UTF8String]; const char *replacementString = [replacement UTF8String]; size_t searchLength = [string UTF8StringLength]; size_t replacementLength = [replacement UTF8StringLength]; - size_t i, last, newCStringLength, newLength; + size_t last, newCStringLength, newLength; char *newCString; if (range.length > SIZE_MAX - range.location || range.location + range.length > [self length]) @throw [OFOutOfRangeException exception]; @@ -668,13 +668,13 @@ return; newCString = NULL; newCStringLength = 0; newLength = _s->length; - last = 0; - for (i = range.location; i <= range.length - searchLength; i++) { + + for (size_t i = range.location; i <= range.length - searchLength; i++) { if (memcmp(_s->cString + i, searchString, searchLength) != 0) continue; @try { newCString = [self Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -830,18 +830,17 @@ if (type & OF_NUMBER_TYPE_FLOAT) { union { double d; uint8_t b[sizeof(double)]; } d; - uint8_t i; if (isnan([self doubleValue])) return 0; d.d = OF_BSWAP_DOUBLE_IF_BE([self doubleValue]); - for (i = 0; i < sizeof(double); i++) + for (uint8_t i = 0; i < sizeof(double); i++) OF_HASH_ADD(hash, d.b[i]); } else if (type & OF_NUMBER_TYPE_SIGNED) { intmax_t v = [self intMaxValue] * -1; while (v != 0) { Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -278,13 +278,11 @@ encoding: OF_STRING_ENCODING_ASCII]; } + (bool)isSubclassOfClass: (Class)class { - Class iter; - - for (iter = self; iter != Nil; iter = class_getSuperclass(iter)) + for (Class iter = self; iter != Nil; iter = class_getSuperclass(iter)) if (iter == class) return true; return false; } @@ -384,17 +382,14 @@ if ([self isSubclassOfClass: class]) return; #if defined(OF_OBJFW_RUNTIME) - struct objc_method_list *methodlist; - - for (methodlist = object_getClass(class)->methodlist; + for (struct objc_method_list *methodlist = + object_getClass(class)->methodlist; methodlist != NULL; methodlist = methodlist->next) { - int i; - - for (i = 0; i < methodlist->count; i++) { + for (int i = 0; i < methodlist->count; i++) { SEL selector = (SEL)&methodlist->methods[i].sel; /* * Don't replace methods implemented in the receiving * class. @@ -406,15 +401,13 @@ [self replaceClassMethod: selector withMethodFromClass: class]; } } - for (methodlist = class->methodlist; methodlist != NULL; - methodlist = methodlist->next) { - int i; - - for (i = 0; i < methodlist->count; i++) { + for (struct objc_method_list *methodlist = class->methodlist; + methodlist != NULL; methodlist = methodlist->next) { + for (int i = 0; i < methodlist->count; i++) { SEL selector = (SEL)&methodlist->methods[i].sel; /* * Don't replace methods implemented in the receiving * class. @@ -427,15 +420,15 @@ withMethodFromClass: class]; } } #elif defined(OF_APPLE_RUNTIME) Method *methodList; - unsigned i, count; + unsigned int count; methodList = class_copyMethodList(object_getClass(class), &count); @try { - for (i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { SEL selector = method_getName(methodList[i]); /* * Don't replace methods implemented in the receiving * class. @@ -451,11 +444,11 @@ free(methodList); } methodList = class_copyMethodList(class, &count); @try { - for (i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { SEL selector = method_getName(methodList[i]); /* * Don't replace methods implemented in the receiving * class. @@ -506,13 +499,11 @@ encoding: OF_STRING_ENCODING_ASCII]; } - (bool)isKindOfClass: (Class)class { - Class iter; - - for (iter = object_getClass(self); iter != Nil; + for (Class iter = object_getClass(self); iter != Nil; iter = class_getSuperclass(iter)) if (iter == class) return true; return false; Index: src/OFRIPEMD160Hash.m ================================================================== --- src/OFRIPEMD160Hash.m +++ src/OFRIPEMD160Hash.m @@ -59,13 +59,11 @@ static OF_INLINE void byteSwapVectorIfBE(uint32_t *vector, uint8_t length) { #ifdef OF_BIG_ENDIAN - uint8_t i; - - for (i = 0; i < length; i++) + for (uint8_t i = 0; i < length; i++) vector[i] = OF_BSWAP32(vector[i]); #endif } static void Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -29,13 +29,11 @@ static OF_INLINE void byteSwapVectorIfLE(uint32_t *vector, uint8_t length) { #ifndef OF_BIG_ENDIAN - uint8_t i; - - for (i = 0; i < length; i++) + for (uint8_t i = 0; i < length; i++) vector[i] = OF_BSWAP32(vector[i]); #endif } static void Index: src/OFSHA224Or256Hash.m ================================================================== --- src/OFSHA224Or256Hash.m +++ src/OFSHA224Or256Hash.m @@ -43,13 +43,11 @@ static OF_INLINE void byteSwapVectorIfLE(uint32_t *vector, uint8_t length) { #ifndef OF_BIG_ENDIAN - uint8_t i; - - for (i = 0; i < length; i++) + for (uint8_t i = 0; i < length; i++) vector[i] = OF_BSWAP32(vector[i]); #endif } static void Index: src/OFSHA384Or512Hash.m ================================================================== --- src/OFSHA384Or512Hash.m +++ src/OFSHA384Or512Hash.m @@ -54,13 +54,11 @@ static OF_INLINE void byteSwapVectorIfLE(uint64_t *vector, uint8_t length) { #ifndef OF_BIG_ENDIAN - uint8_t i; - - for (i = 0; i < length; i++) + for (uint8_t i = 0; i < length; i++) vector[i] = OF_BSWAP64(vector[i]); #endif } static void Index: src/OFSet_hashtable.m ================================================================== --- src/OFSet_hashtable.m +++ src/OFSet_hashtable.m @@ -143,13 +143,11 @@ count: (size_t)count { self = [self initWithCapacity: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) [_mapTable setValue: (void*)1 forKey: objects[i]]; } @catch (id e) { [self release]; @throw e; Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -266,13 +266,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif return size; } @@ -284,13 +282,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif return size; } @@ -302,13 +298,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif return size; } @@ -320,13 +314,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif return size; } @@ -338,13 +330,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif return size; } @@ -406,13 +396,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif return size; } @@ -424,13 +412,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif return size; } @@ -442,13 +428,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif return size; } @@ -460,13 +444,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif return size; } @@ -478,13 +460,11 @@ [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif return size; } @@ -570,17 +550,17 @@ return ret; } - (OFString*)tryReadLineWithEncoding: (of_string_encoding_t)encoding { - size_t i, pageSize, bufferLength, retLength; + size_t pageSize, bufferLength, retLength; char *retCString, *buffer, *readBuffer; OFString *ret; /* Look if there's a line or \0 in our buffer */ if (!_waitingForDelimiter && _readBuffer != NULL) { - for (i = 0; i < _readBufferLength; i++) { + for (size_t i = 0; i < _readBufferLength; i++) { if OF_UNLIKELY (_readBuffer[i] == '\n' || _readBuffer[i] == '\0') { retLength = i; if (i > 0 && _readBuffer[i - 1] == '\r') @@ -636,11 +616,11 @@ bufferLength = [self lowlevelReadIntoBuffer: buffer length: pageSize]; /* Look if there's a newline or \0 */ - for (i = 0; i < bufferLength; i++) { + for (size_t i = 0; i < bufferLength; i++) { if OF_UNLIKELY (buffer[i] == '\n' || buffer[i] == '\0') { retLength = _readBufferLength + i; retCString = [self allocMemoryWithSize: retLength]; @@ -781,11 +761,11 @@ - (OFString*)tryReadTillDelimiter: (OFString*)delimiter encoding: (of_string_encoding_t)encoding { const char *delimiterCString; - size_t i, j, delimiterLength, pageSize, bufferLength, retLength; + size_t j, delimiterLength, pageSize, bufferLength, retLength; char *retCString, *buffer, *readBuffer; OFString *ret; delimiterCString = [delimiter cStringWithEncoding: encoding]; delimiterLength = [delimiter cStringLengthWithEncoding: encoding]; @@ -794,11 +774,11 @@ if (delimiterLength == 0) @throw [OFInvalidArgumentException exception]; /* Look if there's something in our buffer */ if (!_waitingForDelimiter && _readBuffer != NULL) { - for (i = 0; i < _readBufferLength; i++) { + for (size_t i = 0; i < _readBufferLength; i++) { if (_readBuffer[i] != delimiterCString[j++]) j = 0; if (j == delimiterLength || _readBuffer[i] == '\0') { if (_readBuffer[i] == '\0') @@ -850,11 +830,11 @@ bufferLength = [self lowlevelReadIntoBuffer: buffer length: pageSize]; /* Look if there's a delimiter or \0 */ - for (i = 0; i < bufferLength; i++) { + for (size_t i = 0; i < bufferLength; i++) { if (buffer[i] != delimiterCString[j++]) j = 0; if (j == delimiterLength || buffer[i] == '\0') { if (buffer[i] == '\0') @@ -1042,19 +1022,15 @@ #ifdef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint16_t *tmp; - - tmp = [self allocMemoryWithSize: sizeof(uint16_t) - count: count]; + uint16_t *tmp = [self allocMemoryWithSize: sizeof(uint16_t) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1072,19 +1048,15 @@ #ifdef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint32_t *tmp; - - tmp = [self allocMemoryWithSize: sizeof(uint32_t) - count: count]; + uint32_t *tmp = [self allocMemoryWithSize: sizeof(uint32_t) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1102,19 +1074,15 @@ #ifdef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint64_t *tmp; - - tmp = [self allocMemoryWithSize: sizeof(uint64_t) - count: count]; + uint64_t *tmp = [self allocMemoryWithSize: sizeof(uint64_t) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1132,19 +1100,15 @@ #ifdef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - float *tmp; - - tmp = [self allocMemoryWithSize: sizeof(float) - count: count]; + float *tmp = [self allocMemoryWithSize: sizeof(float) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1162,19 +1126,15 @@ #ifdef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - double *tmp; - - tmp = [self allocMemoryWithSize: sizeof(double) - count: count]; + double *tmp = [self allocMemoryWithSize: sizeof(double) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1232,19 +1192,15 @@ #ifndef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint16_t *tmp; - - tmp = [self allocMemoryWithSize: sizeof(uint16_t) - count: count]; + uint16_t *tmp = [self allocMemoryWithSize: sizeof(uint16_t) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1262,19 +1218,15 @@ #ifndef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint32_t *tmp; - - tmp = [self allocMemoryWithSize: sizeof(uint32_t) - count: count]; + uint32_t *tmp = [self allocMemoryWithSize: sizeof(uint32_t) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1292,19 +1244,15 @@ #ifndef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint64_t *tmp; - - tmp = [self allocMemoryWithSize: sizeof(uint64_t) - count: count]; + uint64_t *tmp = [self allocMemoryWithSize: sizeof(uint64_t) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1322,19 +1270,15 @@ #ifndef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - float *tmp; - - tmp = [self allocMemoryWithSize: sizeof(float) - count: count]; + float *tmp = [self allocMemoryWithSize: sizeof(float) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { @@ -1352,19 +1296,15 @@ #ifndef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - double *tmp; - - tmp = [self allocMemoryWithSize: sizeof(double) - count: count]; + double *tmp = [self allocMemoryWithSize: sizeof(double) + count: count]; @try { - size_t i; - - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { Index: src/OFString+Hashing.m ================================================================== --- src/OFString+Hashing.m +++ src/OFString+Hashing.m @@ -34,17 +34,16 @@ void *pool = objc_autoreleasePoolPush(); id hash = [hashClass hash]; size_t digestSize = [hashClass digestSize]; const uint8_t *digest; char cString[digestSize * 2]; - size_t i; [hash updateWithBuffer: [self UTF8String] length: [self UTF8StringLength]]; digest = [hash digest]; - for (i = 0; i < digestSize; i++) { + for (size_t i = 0; i < digestSize; i++) { uint8_t high, low; high = digest[i] >> 4; low = digest[i] & 0x0F; Index: src/OFString+JSONValue.m ================================================================== --- src/OFString+JSONValue.m +++ src/OFString+JSONValue.m @@ -111,19 +111,18 @@ static inline of_char16_t parseUnicodeEscape(const char *pointer, const char *stop) { of_char16_t ret = 0; - char i; if (pointer + 5 >= stop) return 0xFFFF; if (pointer[0] != '\\' || pointer[1] != 'u') return 0xFFFF; - for (i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; i++) { char c = pointer[i + 2]; ret <<= 4; if (c >= '0' && c <= '9') ret |= c - '0'; Index: src/OFString+XMLEscaping.m ================================================================== --- src/OFString+XMLEscaping.m +++ src/OFString+XMLEscaping.m @@ -31,11 +31,11 @@ { void *pool = objc_autoreleasePoolPush(); char *retCString; const char *string, *append; size_t length, retLength, appendLen; - size_t i, j; + size_t j; OFString *ret; string = [self UTF8String]; length = [self UTF8StringLength]; @@ -47,39 +47,39 @@ */ if ((retCString = malloc(retLength)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: retLength]; - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { switch (string[i]) { - case '<': - append = "<"; - appendLen = 4; - break; - case '>': - append = ">"; - appendLen = 4; - break; - case '"': - append = """; - appendLen = 6; - break; - case '\'': - append = "'"; - appendLen = 6; - break; - case '&': - append = "&"; - appendLen = 5; - break; - case '\r': - append = " "; - appendLen = 5; - break; - default: - append = NULL; - appendLen = 0; + case '<': + append = "<"; + appendLen = 4; + break; + case '>': + append = ">"; + appendLen = 4; + break; + case '"': + append = """; + appendLen = 6; + break; + case '\'': + append = "'"; + appendLen = 6; + break; + case '&': + append = "&"; + appendLen = 5; + break; + case '\r': + append = " "; + appendLen = 5; + break; + default: + append = NULL; + appendLen = 0; } if (append != NULL) { char *newRetCString; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -203,15 +203,15 @@ if ((startsWithEmpty = [[array firstObject] isEqual: @""])) [array removeObjectAtIndex: 0]; endsWithEmpty = [[array lastObject] isEqual: @""]; while (!done) { - size_t i, length = [array count]; + size_t length = [array count]; done = true; - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { id object = [array objectAtIndex: i]; id parent; if (i > 0) parent = [array objectAtIndex: i - 1]; @@ -1190,16 +1190,16 @@ - (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding { switch (encoding) { case OF_STRING_ENCODING_UTF_8:; const of_unichar_t *characters; - size_t i, length, UTF8StringLength = 0; + size_t length, UTF8StringLength = 0; characters = [self characters]; length = [self length]; - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { char buffer[4]; size_t len = of_string_utf8_encode(characters[i], buffer); if (len == 0) @@ -1231,13 +1231,11 @@ } - (void)getCharacters: (of_unichar_t*)buffer inRange: (of_range_t)range { - size_t i; - - for (i = 0; i < range.length; i++) + for (size_t i = 0; i < range.length; i++) buffer[i] = [self characterAtIndex: range.location + i]; } - (bool)isEqual: (id)object { @@ -1287,11 +1285,11 @@ - (of_comparison_result_t)compare: (id )object { void *pool; OFString *otherString; const of_unichar_t *characters, *otherCharacters; - size_t i, minimumLength; + size_t minimumLength; if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [OFString class]]) @@ -1304,11 +1302,11 @@ pool = objc_autoreleasePoolPush(); characters = [self characters]; otherCharacters = [otherString characters]; - for (i = 0; i < minimumLength; i++) { + for (size_t i = 0; i < minimumLength; i++) { if (characters[i] > otherCharacters[i]) { objc_autoreleasePoolPop(pool); return OF_ORDERED_DESCENDING; } @@ -1330,11 +1328,11 @@ - (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters, *otherCharacters; - size_t i, length, otherLength, minimumLength; + size_t length, otherLength, minimumLength; if (otherString == self) return OF_ORDERED_SAME; characters = [self characters]; @@ -1342,11 +1340,11 @@ length = [self length]; otherLength = [otherString length]; minimumLength = (length > otherLength ? otherLength : length); - for (i = 0; i < minimumLength; i++) { + for (size_t i = 0; i < minimumLength; i++) { of_unichar_t c = characters[i]; of_unichar_t oc = otherCharacters[i]; if (c >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) { of_unichar_t tc = @@ -1385,16 +1383,16 @@ } - (uint32_t)hash { const of_unichar_t *characters = [self characters]; - size_t i, length = [self length]; + size_t length = [self length]; uint32_t hash; OF_HASH_INIT(hash); - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { const of_unichar_t c = characters[i]; OF_HASH_ADD(hash, (c & 0xFF0000) >> 16); OF_HASH_ADD(hash, (c & 0x00FF00) >> 8); OF_HASH_ADD(hash, c & 0x0000FF); @@ -1565,11 +1563,11 @@ range: (of_range_t)range { void *pool; const of_unichar_t *searchCharacters; of_unichar_t *characters; - size_t i, searchLength; + size_t searchLength; if ((searchLength = [string length]) == 0) return of_range(0, 0); if (searchLength > range.length) @@ -1590,11 +1588,11 @@ @try { [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { - for (i = range.length - searchLength;; i--) { + for (size_t i = range.length - searchLength;; i--) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t)) == 0) { objc_autoreleasePoolPop(pool); return of_range(range.location + i, searchLength); @@ -1603,11 +1601,12 @@ /* No match and we're at the last character */ if (i == 0) break; } } else { - for (i = 0; i <= range.length - searchLength; i++) { + for (size_t i = 0; + i <= range.length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t)) == 0) { objc_autoreleasePoolPop(pool); return of_range(range.location + i, searchLength); @@ -1625,11 +1624,11 @@ - (bool)containsString: (OFString*)string { void *pool; const of_unichar_t *characters, *searchCharacters; - size_t i, length, searchLength; + size_t length, searchLength; if ((searchLength = [string length]) == 0) return true; if (searchLength > (length = [self length])) @@ -1638,11 +1637,11 @@ pool = objc_autoreleasePoolPush(); characters = [self characters]; searchCharacters = [string characters]; - for (i = 0; i <= length - searchLength; i++) { + for (size_t i = 0; i <= length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t)) == 0) { objc_autoreleasePoolPop(pool); return true; } @@ -1906,11 +1905,11 @@ OFMutableArray *array = [OFMutableArray array]; const of_unichar_t *characters, *delimiterCharacters; bool skipEmpty = (options & OF_STRING_SKIP_EMPTY); size_t length = [self length]; size_t delimiterLength = [delimiter length]; - size_t i, last; + size_t last; OFString *component; pool = objc_autoreleasePoolPush(); characters = [self characters]; @@ -1923,11 +1922,12 @@ objc_autoreleasePoolPop(pool); return array; } - for (i = 0, last = 0; i <= length - delimiterLength; i++) { + last = 0; + for (size_t i = 0; i <= length - delimiterLength; i++) { if (memcmp(characters + i, delimiterCharacters, delimiterLength * sizeof(of_unichar_t)) != 0) continue; component = [self substringWithRange: of_range(last, i - last)]; @@ -2052,11 +2052,11 @@ - (OFString*)stringByDeletingLastPathComponent { void *pool; const of_unichar_t *characters; - size_t i, length = [self length]; + size_t length = [self length]; if (length == 0) return @""; pool = objc_autoreleasePoolPush(); @@ -2069,11 +2069,11 @@ if (length == 0) { objc_autoreleasePoolPop(pool); return [self substringWithRange: of_range(0, 1)]; } - for (i = length - 1; i >= 1; i--) { + for (size_t i = length - 1; i >= 1; i--) { if (OF_IS_PATH_DELIMITER(characters[i])) { objc_autoreleasePoolPop(pool); return [self substringWithRange: of_range(0, i)]; } } @@ -2330,20 +2330,19 @@ OFObject *object = [[[OFObject alloc] init] autorelease]; void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t length = [self length]; of_char16_t *ret; - size_t i, j; + size_t j; bool swap = (byteOrder != OF_BYTE_ORDER_NATIVE); /* Allocate memory for the worst case */ ret = [object allocMemoryWithSize: sizeof(of_char16_t) count: (length + 1) * 2]; j = 0; - - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { of_unichar_t c = characters[i]; if (c > 0x10FFFF) @throw [OFInvalidEncodingException exception]; @@ -2379,15 +2378,15 @@ } - (size_t)UTF16StringLength { const of_unichar_t *characters = [self characters]; - size_t i, length, UTF16StringLength; + size_t length, UTF16StringLength; length = UTF16StringLength = [self length]; - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) if (characters[i] > 0xFFFF) UTF16StringLength++; return UTF16StringLength; } @@ -2407,16 +2406,13 @@ count: length + 1]; [self getCharacters: ret inRange: of_range(0, length)]; ret[length] = 0; - if (byteOrder != OF_BYTE_ORDER_NATIVE) { - size_t i; - - for (i = 0; i < length; i++) + if (byteOrder != OF_BYTE_ORDER_NATIVE) + for (size_t i = 0; i < length; i++) ret[i] = OF_BSWAP32(ret[i]); - } return ret; } #ifdef OF_HAVE_FILES Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -43,13 +43,11 @@ extern const of_char16_t of_codepage_437[128]; static inline int memcasecmp(const char *first, const char *second, size_t length) { - size_t i; - - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { if (tolower((int)first[i]) > tolower((int)second[i])) return OF_ORDERED_DESCENDING; if (tolower((int)first[i]) < tolower((int)second[i])) return OF_ORDERED_ASCENDING; } @@ -58,14 +56,14 @@ } int of_string_utf8_check(const char *UTF8String, size_t UTF8Length, size_t *length) { - size_t i, tmpLength = UTF8Length; + size_t tmpLength = UTF8Length; int isUTF8 = 0; - for (i = 0; i < UTF8Length; i++) { + for (size_t i = 0; i < UTF8Length; i++) { /* No sign of UTF-8 here */ if OF_LIKELY (!(UTF8String[i] & 0x80)) continue; isUTF8 = 1; @@ -125,25 +123,23 @@ } size_t of_string_utf8_get_index(const char *string, size_t position) { - size_t i, index = position; + size_t index = position; - for (i = 0; i < position; i++) + for (size_t i = 0; i < position; i++) if OF_UNLIKELY ((string[i] & 0xC0) == 0x80) index--; return index; } size_t of_string_utf8_get_position(const char *string, size_t index, size_t length) { - size_t i; - - for (i = 0; i <= index; i++) + for (size_t i = 0; i <= index; i++) if OF_UNLIKELY ((string[i] & 0xC0) == 0x80) if (++index > length) return OF_NOT_FOUND; return index; @@ -209,12 +205,12 @@ length: (size_t)cStringLength { self = [super init]; @try { - size_t i, j; const of_char16_t *table; + size_t j; if (encoding == OF_STRING_ENCODING_UTF_8 && cStringLength >= 3 && memcmp(cString, "\xEF\xBB\xBF", 3) == 0) { cString += 3; @@ -249,11 +245,12 @@ /* All other encodings we support are single byte encodings */ _s->length = cStringLength; if (encoding == OF_STRING_ENCODING_ISO_8859_1) { - for (i = j = 0; i < cStringLength; i++) { + j = 0; + for (size_t i = 0; i < cStringLength; i++) { char buffer[4]; size_t bytes; if (!(cString[i] & 0x80)) { _s->cString[j++] = cString[i]; @@ -294,11 +291,12 @@ break; default: @throw [OFInvalidEncodingException exception]; } - for (i = j = 0; i < cStringLength; i++) { + j = 0; + for (size_t i = 0; i < cStringLength; i++) { char buffer[4]; of_unichar_t character; size_t characterBytes; if (!(cString[i] & 0x80)) { @@ -405,18 +403,19 @@ length: (size_t)length { self = [super init]; @try { - size_t i, j = 0; + size_t j; _s = &_storage; _s->cString = [self allocMemoryWithSize: (length * 4) + 1]; _s->length = length; - for (i = 0; i < length; i++) { + j = 0; + for (size_t i = 0; i < length; i++) { size_t len = of_string_utf8_encode(characters[i], _s->cString + j); if (len == 0) @throw [OFInvalidEncodingException exception]; @@ -449,11 +448,11 @@ byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { - size_t i, j = 0; + size_t j; bool swap = false; if (length > 0 && *string == 0xFEFF) { string++; length--; @@ -467,11 +466,12 @@ _s = &_storage; _s->cString = [self allocMemoryWithSize: (length * 4) + 1]; _s->length = length; - for (i = 0; i < length; i++) { + j = 0; + for (size_t i = 0; i < length; i++) { of_unichar_t character = (swap ? OF_BSWAP16(string[i]) : string[i]); size_t len; /* Missing high surrogate */ @@ -533,11 +533,11 @@ byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { - size_t i, j = 0; + size_t j; bool swap = false; if (length > 0 && *characters == 0xFEFF) { characters++; length--; @@ -551,11 +551,12 @@ _s = &_storage; _s->cString = [self allocMemoryWithSize: (length * 4) + 1]; _s->length = length; - for (i = 0; i < length; i++) { + j = 0; + for (size_t i = 0; i < length; i++) { char buffer[4]; size_t len = of_string_utf8_encode( (swap ? OF_BSWAP32(characters[i]) : characters[i]), buffer); @@ -850,19 +851,18 @@ return OF_ORDERED_SAME; } - (uint32_t)hash { - size_t i; uint32_t hash; if (_s->hashed) return _s->hash; OF_HASH_INIT(hash); - for (i = 0; i < _s->cStringLength; i++) { + for (size_t i = 0; i < _s->cStringLength; i++) { of_unichar_t c; size_t length; if ((length = of_string_utf8_decode(_s->cString + i, _s->cStringLength - i, &c)) == 0) @@ -923,11 +923,11 @@ - (of_range_t)rangeOfString: (OFString*)string options: (int)options range: (of_range_t)range { const char *cString = [string UTF8String]; - size_t i, cStringLength = [string UTF8StringLength]; + size_t cStringLength = [string UTF8StringLength]; size_t rangeLocation, rangeLength; if (range.length > SIZE_MAX - range.location || range.location + range.length > _s->length) @throw [OFOutOfRangeException exception]; @@ -948,11 +948,11 @@ if (cStringLength > rangeLength) return of_range(OF_NOT_FOUND, 0); if (options & OF_STRING_SEARCH_BACKWARDS) { - for (i = rangeLength - cStringLength;; i--) { + for (size_t i = rangeLength - cStringLength;; i--) { if (memcmp(_s->cString + rangeLocation + i, cString, cStringLength) == 0) { range.location += of_string_utf8_get_index( _s->cString + rangeLocation, i); range.length = [string length]; @@ -963,11 +963,11 @@ /* Did not match and we're at the last char */ if (i == 0) return of_range(OF_NOT_FOUND, 0); } } else { - for (i = 0; i <= rangeLength - cStringLength; i++) { + for (size_t i = 0; i <= rangeLength - cStringLength; i++) { if (memcmp(_s->cString + rangeLocation + i, cString, cStringLength) == 0) { range.location += of_string_utf8_get_index( _s->cString + rangeLocation, i); range.length = [string length]; @@ -981,19 +981,19 @@ } - (bool)containsString: (OFString*)string { const char *cString = [string UTF8String]; - size_t i, cStringLength = [string UTF8StringLength]; + size_t cStringLength = [string UTF8StringLength]; if (cStringLength == 0) return true; if (cStringLength > _s->cStringLength) return false; - for (i = 0; i <= _s->cStringLength - cStringLength; i++) + for (size_t i = 0; i <= _s->cStringLength - cStringLength; i++) if (memcmp(_s->cString + i, cString, cStringLength) == 0) return true; return false; } @@ -1044,11 +1044,11 @@ void *pool; OFMutableArray *array; const char *cString = [delimiter UTF8String]; size_t cStringLength = [delimiter UTF8StringLength]; bool skipEmpty = (options & OF_STRING_SKIP_EMPTY); - size_t i, last; + size_t last; OFString *component; array = [OFMutableArray array]; pool = objc_autoreleasePoolPush(); @@ -1057,11 +1057,12 @@ objc_autoreleasePoolPop(pool); return array; } - for (i = 0, last = 0; i <= _s->cStringLength - cStringLength; i++) { + last = 0; + for (size_t i = 0; i <= _s->cStringLength - cStringLength; i++) { if (memcmp(_s->cString + i, cString, cStringLength) != 0) continue; component = [OFString stringWithUTF8String: _s->cString + last length: i - last]; @@ -1152,11 +1153,11 @@ length: pathCStringLength - i]; } - (OFString*)stringByDeletingLastPathComponent { - size_t i, pathCStringLength = _s->cStringLength; + size_t pathCStringLength = _s->cStringLength; if (pathCStringLength == 0) return @""; if (OF_IS_PATH_DELIMITER(_s->cString[pathCStringLength - 1])) @@ -1164,11 +1165,11 @@ if (pathCStringLength == 0) return [OFString stringWithUTF8String: _s->cString length: 1]; - for (i = pathCStringLength - 1; i >= 1; i--) + for (size_t i = pathCStringLength - 1; i >= 1; i--) if (OF_IS_PATH_DELIMITER(_s->cString[i])) return [OFString stringWithUTF8String: _s->cString length: i]; if (OF_IS_PATH_DELIMITER(_s->cString[0])) Index: src/OFThreadPool.m ================================================================== --- src/OFThreadPool.m +++ src/OFThreadPool.m @@ -258,19 +258,17 @@ - initWithSize: (size_t)size { self = [super init]; @try { - size_t i; - _size = size; _threads = [[OFMutableArray alloc] init]; _queue = [[OFList alloc] init]; _queueCondition = [[OFCondition alloc] init]; _countCondition = [[OFCondition alloc] init]; - for (i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { void *pool = objc_autoreleasePoolPush(); OFThreadPoolThread *thread = [OFThreadPoolThread threadWithThreadPool: self]; @@ -279,13 +277,13 @@ objc_autoreleasePoolPop(pool); } /* * We need to start the threads in a separate loop to make sure - * threads is not modified anymore to prevent a race condition. + * _threads is not modified anymore to prevent a race condition. */ - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) [[_threads objectAtIndex: i] start]; } @catch (id e) { [self release]; @throw e; } Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -234,11 +234,10 @@ uint32_t hash = of_hash_seed; struct sockaddr_in *sin; #ifdef AF_INET6 struct sockaddr_in6 *sin6; uint32_t subhash; - size_t i; #endif hash += address->address.ss_family; switch (address->address.ss_family) { @@ -266,11 +265,11 @@ hash += (sin6->sin6_port << 1); OF_HASH_INIT(subhash); - for (i = 0; i < sizeof(sin6->sin6_addr.s6_addr); i++) + for (size_t i = 0; i < sizeof(sin6->sin6_addr.s6_addr); i++) OF_HASH_ADD(subhash, sin6->sin6_addr.s6_addr[i]); OF_HASH_FINALIZE(subhash); hash ^= subhash; Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -425,11 +425,11 @@ indentation: (unsigned int)indentation level: (unsigned int)level { void *pool; char *cString; - size_t length, i, j, attributesCount; + size_t length, i, attributesCount; OFString *prefix, *parentPrefix; OFXMLAttribute *const *attributesObjects; OFString *ret; OFString *defaultNS; @@ -519,11 +519,11 @@ /* Attributes */ attributesObjects = [_attributes objects]; attributesCount = [_attributes count]; - for (j = 0; j < attributesCount; j++) { + for (size_t j = 0; j < attributesCount; j++) { void *pool2 = objc_autoreleasePoolPush(); OFString *attributeName = [attributesObjects[j] name]; OFString *attributePrefix = nil; OFString *tmp = [[attributesObjects[j] stringValue] stringByXMLEscaping]; @@ -576,11 +576,11 @@ bool indent; if (indentation > 0) { indent = true; - for (j = 0; j < childrenCount; j++) { + for (size_t j = 0; j < childrenCount; j++) { if ([childrenObjects[j] isKindOfClass: charactersClass] || [childrenObjects[j] isKindOfClass: CDATAClass]) { indent = false; break; @@ -587,11 +587,11 @@ } } } else indent = false; - for (j = 0; j < childrenCount; j++) { + for (size_t j = 0; j < childrenCount; j++) { OFString *child; unsigned int ind = (indent ? indentation : 0); if (ind) [tmp addItem: "\n"]; @@ -821,13 +821,13 @@ } - (void)removeAttributeForName: (OFString*)attributeName { OFXMLAttribute *const *objects = [_attributes objects]; - size_t i, count = [_attributes count]; + size_t count = [_attributes count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if (objects[i]->_namespace == nil && [objects[i]->_name isEqual: attributeName]) { [_attributes removeObjectAtIndex: i]; return; @@ -837,21 +837,21 @@ - (void)removeAttributeForName: (OFString*)attributeName namespace: (OFString*)attributeNS { OFXMLAttribute *const *objects; - size_t i, count; + size_t count; if (attributeNS == nil) { [self removeAttributeForName: attributeName]; return; } objects = [_attributes objects]; count = [_attributes count]; - for (i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { if ([objects[i]->_namespace isEqual: attributeNS] && [objects[i]->_name isEqual: attributeName]) { [_attributes removeObjectAtIndex: i]; return; } Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -62,19 +62,16 @@ static OFString* transformString(OFXMLParser *parser, OFDataArray *buffer, size_t cut, bool unescape) { - char *items; - size_t i, length; + char *items = [buffer items]; + size_t length = [buffer count] - cut; bool hasEntities = false; OFString *ret; - items = [buffer items]; - length = [buffer count] - cut; - - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { if (items[i] == '\r') { if (i + 1 < length && items[i + 1] == '\n') { [buffer removeItemAtIndex: i]; items = [buffer items]; @@ -104,19 +101,18 @@ static OFString* namespaceForPrefix(OFString *prefix, OFArray *namespaces) { OFDictionary *const *objects = [namespaces objects]; size_t count = [namespaces count]; - ssize_t i; if (prefix == nil) prefix = @""; if (count - 1 > SSIZE_MAX) @throw [OFOutOfRangeException exception]; - for (i = count - 1; i >= 0; i--) { + for (ssize_t i = count - 1; i >= 0; i--) { OFString *tmp; if ((tmp = [objects[i] objectForKey: prefix]) != nil) return tmp; } @@ -148,12 +144,10 @@ @implementation OFXMLParser @synthesize delegate = _delegate, depthLimit = _depthLimit; + (void)initialize { - size_t i; - const SEL selectors_[OF_XMLPARSER_NUM_STATES] = { @selector(OF_inByteOrderMarkState), @selector(OF_outsideTagState), @selector(OF_tagOpenedState), @selector(OF_inProcessingInstructionsState), @@ -174,11 +168,11 @@ @selector(OF_inCommentState2), @selector(OF_inDOCTYPEState) }; memcpy(selectors, selectors_, sizeof(selectors_)); - for (i = 0; i < OF_XMLPARSER_NUM_STATES; i++) { + for (size_t i = 0; i < OF_XMLPARSER_NUM_STATES; i++) { if (![self instancesRespondToSelector: selectors[i]]) @throw [OFInitializationFailedException exceptionWithClass: self]; lookupTable[i] = (state_function_t) @@ -397,11 +391,11 @@ /* */ - (bool)OF_parseXMLProcessingInstructions: (OFString*)pi { const char *cString; - size_t i, last, length; + size_t length, last; int PIState = 0; OFString *attribute = nil; OFMutableString *value = nil; char piDelimiter = 0; bool hasVersion = false; @@ -415,11 +409,12 @@ pi = [pi stringByDeletingEnclosingWhitespaces]; cString = [pi UTF8String]; length = [pi UTF8StringLength]; - for (i = last = 0; i < length; i++) { + last = 0; + for (size_t i = 0; i < length; i++) { switch (PIState) { case 0: if (cString[i] == ' ' || cString[i] == '\t' || cString[i] == '\r' || cString[i] == '\n') continue; @@ -690,11 +685,11 @@ - (void)OF_inTagState { void *pool; OFString *namespace; OFXMLAttribute *const *attributesObjects; - size_t j, attributesCount; + size_t attributesCount; if (_data[_i] != '>' && _data[_i] != '/') { if (_data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r') { _last = _i; @@ -712,11 +707,11 @@ if (_prefix != nil && namespace == nil) @throw [OFUnboundPrefixException exceptionWithPrefix: _prefix parser: self]; - for (j = 0; j < attributesCount; j++) + for (size_t j = 0; j < attributesCount; j++) resolveAttributeNamespace(attributesObjects[j], _namespaces, self); pool = objc_autoreleasePoolPush(); Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -84,16 +84,15 @@ uint32_t of_zip_archive_read_field32(uint8_t **data, uint16_t *size) { uint32_t field = 0; - uint8_t i; if (*size < 4) @throw [OFInvalidFormatException exception]; - for (i = 0; i < 4; i++) + for (uint8_t i = 0; i < 4; i++) field |= (uint32_t)(*data)[i] << (i * 8); *data += 4; *size -= 4; @@ -102,16 +101,15 @@ uint64_t of_zip_archive_read_field64(uint8_t **data, uint16_t *size) { uint64_t field = 0; - uint8_t i; if (*size < 8) @throw [OFInvalidFormatException exception]; - for (i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) field |= (uint64_t)(*data)[i] << (i * 8); *data += 8; *size -= 8; @@ -119,18 +117,14 @@ } static uint32_t calculateCRC32(uint32_t crc, uint8_t *bytes, size_t length) { - size_t i; - - for (i = 0; i < length; i++) { - uint8_t j; - + for (size_t i = 0; i < length; i++) { crc ^= bytes[i]; - for (j = 0; j < 8; j++) + for (uint8_t j = 0; j < 8; j++) crc = (crc >> 1) ^ (CRC32_MAGIC & (~(crc & 1) + 1)); } return crc; } @@ -302,11 +296,10 @@ } - (void)OF_readEntries { void *pool = objc_autoreleasePoolPush(); - size_t i; if ((of_offset_t)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat(_stream, @@ -313,11 +306,11 @@ (of_offset_t)_centralDirectoryOffset, SEEK_SET); _entries = [[OFMutableArray alloc] init]; _pathToEntryMap = [[OFMutableDictionary alloc] init]; - for (i = 0; i < _centralDirectoryEntries; i++) { + for (size_t i = 0; i < _centralDirectoryEntries; i++) { OFZIPArchiveEntry *entry = [[[OFZIPArchiveEntry alloc] OF_initWithStream: _stream] autorelease]; if ([_pathToEntryMap objectForKey: [entry fileName]] != nil) @throw [OFInvalidFormatException exception]; Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -109,17 +109,14 @@ void of_zip_archive_entry_extra_field_find(OFDataArray *extraField, uint16_t tag, uint8_t **data, uint16_t *size) { - uint8_t *bytes; - size_t i, count; + uint8_t *bytes = [extraField items]; + size_t count = [extraField count]; - bytes = [extraField items]; - count = [extraField count]; - - for (i = 0; i < count;) { + for (size_t i = 0; i < count;) { uint16_t currentTag, currentSize; if (i + 3 >= count) @throw [OFInvalidFormatException exception]; Index: src/codepage_437.m ================================================================== --- src/codepage_437.m +++ src/codepage_437.m @@ -39,13 +39,11 @@ bool of_unicode_to_codepage_437(const of_unichar_t *input, uint8_t *output, size_t length, bool lossy) { - size_t i; - - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { of_unichar_t c = input[i]; if OF_UNLIKELY (c > 0x7F) { if OF_UNLIKELY (c > 0xFFFF) { if (lossy) { Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -260,13 +260,13 @@ - (OFArray*)backtrace { #ifdef HAVE_DWARF_EXCEPTIONS OFMutableArray *backtrace = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); - uint8_t i; - for (i = 0; i < OF_BACKTRACE_SIZE && _backtrace[i] != NULL; i++) { + for (uint8_t i = 0; + i < OF_BACKTRACE_SIZE && _backtrace[i] != NULL; i++) { # ifdef HAVE_DLADDR Dl_info info; if (dladdr(_backtrace[i], &info)) { OFString *frame; Index: src/iso_8859_15.m ================================================================== --- src/iso_8859_15.m +++ src/iso_8859_15.m @@ -39,13 +39,11 @@ bool of_unicode_to_iso_8859_15(const of_unichar_t *input, uint8_t *output, size_t length, bool lossy) { - size_t i; - - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { of_unichar_t c = input[i]; if OF_UNLIKELY (c > 0xFF) { if OF_UNLIKELY (c > 0xFFFF) { if (lossy) { Index: src/of_asprintf.m ================================================================== --- src/of_asprintf.m +++ src/of_asprintf.m @@ -379,20 +379,21 @@ ctx->subformat[ctx->subformatLen - 1] = 's'; { const of_unichar_t *arg = va_arg(ctx->arguments, const of_unichar_t*); - size_t i, j, len = of_string_utf32_length(arg); + size_t j, len = of_string_utf32_length(arg); char *buffer; if (SIZE_MAX / 4 < len || (SIZE_MAX / 4) - len < 1) return false; if ((buffer = malloc((len * 4) + 1)) == NULL) return false; - for (i = j = 0; i < len; i++) { + j = 0; + for (size_t i = 0; i < len; i++) { size_t clen = of_string_utf8_encode(arg[i], buffer + j); if (clen == 0) { free(buffer); Index: src/of_strptime.m ================================================================== --- src/of_strptime.m +++ src/of_strptime.m @@ -27,16 +27,17 @@ { enum { SEARCH_CONVERSION_SPECIFIER, IN_CONVERSION_SPECIFIER } state = SEARCH_CONVERSION_SPECIFIER; - size_t i, j, buffer_len, format_len; + size_t j, buffer_len, format_len; buffer_len = strlen(buffer); format_len = strlen(format); - for (i = j = 0; i < format_len; i++) { + j = 0; + for (size_t i = 0; i < format_len; i++) { if (j >= buffer_len) return NULL; switch (state) { case SEARCH_CONVERSION_SPECIFIER: Index: src/runtime/category.m ================================================================== --- src/runtime/category.m +++ src/runtime/category.m @@ -26,20 +26,19 @@ static struct objc_hashtable *categories = NULL; static void register_selectors(struct objc_abi_category *cat) { - struct objc_abi_method_list *ml; - unsigned int i; - - for (ml = cat->instance_methods; ml != NULL; ml = ml->next) - for (i = 0; i < ml->count; i++) + for (struct objc_abi_method_list *ml = cat->instance_methods; + ml != NULL; ml = ml->next) + for (unsigned int i = 0; i < ml->count; i++) objc_register_selector( (struct objc_abi_selector*)&ml->methods[i]); - for (ml = cat->class_methods; ml != NULL; ml = ml->next) - for (i = 0; i < ml->count; i++) + for (struct objc_abi_method_list *ml = cat->class_methods; + ml != NULL; ml = ml->next) + for (unsigned int i = 0; i < ml->count; i++) objc_register_selector( (struct objc_abi_selector*)&ml->methods[i]); } static void @@ -93,16 +92,14 @@ } void objc_register_all_categories(struct objc_abi_symtab *symtab) { - struct objc_abi_category **cats; - size_t i; + struct objc_abi_category **cats = + (struct objc_abi_category**)symtab->defs + symtab->cls_def_cnt; - cats = (struct objc_abi_category**)symtab->defs + symtab->cls_def_cnt; - - for (i = 0; i < symtab->cat_def_cnt; i++) { + for (size_t i = 0; i < symtab->cat_def_cnt; i++) { register_selectors(cats[i]); register_category(cats[i]); } } @@ -117,17 +114,15 @@ } void objc_unregister_all_categories(void) { - uint32_t i; - if (categories == NULL) return; - for (i = 0; i < categories->size; i++) + for (uint32_t i = 0; i < categories->size; i++) if (categories->data[i] != NULL) free((void*)categories->data[i]->obj); objc_hashtable_free(categories); categories = NULL; } Index: src/runtime/class.m ================================================================== --- src/runtime/class.m +++ src/runtime/class.m @@ -66,14 +66,13 @@ static void register_selectors(struct objc_abi_class *cls) { struct objc_abi_method_list *ml; - unsigned int i; for (ml = cls->methodlist; ml != NULL; ml = ml->next) - for (i = 0; i < ml->count; i++) + for (unsigned int i = 0; i < ml->count; i++) objc_register_selector( (struct objc_abi_selector*)&ml->methods[i]); } Class @@ -128,34 +127,28 @@ } static void call_method(Class cls, const char *method) { - struct objc_method_list *ml; - SEL selector; - unsigned int i; - - selector = sel_registerName(method); - - for (ml = cls->isa->methodlist; ml != NULL; ml = ml->next) - for (i = 0; i < ml->count; i++) + SEL selector = sel_registerName(method); + + for (struct objc_method_list *ml = cls->isa->methodlist; + ml != NULL; ml = ml->next) + for (unsigned int i = 0; i < ml->count; i++) if (sel_isEqual((SEL)&ml->methods[i].sel, selector)) ((void(*)(id, SEL))ml->methods[i].imp)(cls, selector); } static bool has_load(Class cls) { - struct objc_method_list *ml; - SEL selector; - unsigned int i; - - selector = sel_registerName("load"); - - for (ml = cls->isa->methodlist; ml != NULL; ml = ml->next) - for (i = 0; i < ml->count; i++) + SEL selector = sel_registerName("load"); + + for (struct objc_method_list *ml = cls->isa->methodlist; + ml != NULL; ml = ml->next) + for (size_t i = 0; i < ml->count; i++) if (sel_isEqual((SEL)&ml->methods[i].sel, selector)) return true; return false; } @@ -177,11 +170,10 @@ void objc_update_dtable(Class cls) { struct objc_method_list *ml; struct objc_category **cats; - unsigned int i; if (!(cls->info & OBJC_CLASS_INFO_DTABLE)) return; if (cls->dtable == empty_dtable) @@ -189,36 +181,31 @@ if (cls->superclass != Nil) objc_dtable_copy(cls->dtable, cls->superclass->dtable); for (ml = cls->methodlist; ml != NULL; ml = ml->next) - for (i = 0; i < ml->count; i++) + for (unsigned int i = 0; i < ml->count; i++) objc_dtable_set(cls->dtable, (uint32_t)ml->methods[i].sel.uid, ml->methods[i].imp); if ((cats = objc_categories_for_class(cls)) != NULL) { - for (i = 0; cats[i] != NULL; i++) { - unsigned int j; - + for (unsigned int i = 0; cats[i] != NULL; i++) { ml = (cls->info & OBJC_CLASS_INFO_CLASS ? cats[i]->instance_methods : cats[i]->class_methods); for (; ml != NULL; ml = ml->next) - for (j = 0; j < ml->count; j++) + for (unsigned int j = 0; j < ml->count; j++) objc_dtable_set(cls->dtable, (uint32_t)ml->methods[j].sel.uid, ml->methods[j].imp); } } - if (cls->subclass_list != NULL) { - Class *iter; - - for (iter = cls->subclass_list; *iter != NULL; iter++) + if (cls->subclass_list != NULL) + for (Class *iter = cls->subclass_list; *iter != NULL; iter++) objc_update_dtable(*iter); - } } static void add_subclass(Class cls) { @@ -251,12 +238,10 @@ static void update_ivar_offsets(Class cls) { - unsigned i; - if (!(cls->info & OBJC_CLASS_INFO_NEW_ABI)) return; if (cls->instance_size > 0) return; @@ -265,19 +250,19 @@ if (cls->superclass != Nil) { cls->instance_size += cls->superclass->instance_size; if (cls->ivars != NULL) { - for (i = 0; i < cls->ivars->count; i++) { + for (unsigned int i = 0; i < cls->ivars->count; i++) { cls->ivars->ivars[i].offset += cls->superclass->instance_size; *cls->ivar_offsets[i] = cls->ivars->ivars[i].offset; } } } else - for (i = 0; i < cls->ivars->count; i++) + for (unsigned int i = 0; i < cls->ivars->count; i++) *cls->ivar_offsets[i] = cls->ivars->ivars[i].offset; } static void setup_class(Class cls) @@ -368,22 +353,20 @@ } void objc_register_all_classes(struct objc_abi_symtab *symtab) { - uint32_t i; - - for (i = 0; i < symtab->cls_def_cnt; i++) { + for (uint16_t i = 0; i < symtab->cls_def_cnt; i++) { struct objc_abi_class *cls = (struct objc_abi_class*)symtab->defs[i]; register_class(cls); register_selectors(cls); register_selectors(cls->metaclass); } - for (i = 0; i < symtab->cls_def_cnt; i++) { + for (uint16_t i = 0; i < symtab->cls_def_cnt; i++) { Class cls = (Class)symtab->defs[i]; if (has_load(cls)) { setup_class(cls); @@ -402,11 +385,11 @@ } else cls->info |= OBJC_CLASS_INFO_LOADED; } /* Process load queue */ - for (i = 0; i < load_queue_cnt; i++) { + for (size_t i = 0; i < load_queue_cnt; i++) { setup_class(load_queue[i]); if (load_queue[i]->info & OBJC_CLASS_INFO_SETUP) { call_load(load_queue[i]); @@ -482,21 +465,21 @@ } unsigned int objc_getClassList(Class *buf, unsigned int count) { - uint32_t i; unsigned int j; objc_global_mutex_lock(); if (buf == NULL) return classes_cnt; if (classes_cnt < count) count = classes_cnt; - for (i = j = 0; i < classes->size; i++) { + j = 0; + for (uint32_t i = 0; i < classes->size; i++) { void *cls; if (j >= count) { objc_global_mutex_unlock(); return j; @@ -626,19 +609,18 @@ const char* class_getMethodTypeEncoding(Class cls, SEL sel) { struct objc_method_list *ml; struct objc_category **cats; - unsigned int i; if (cls == Nil) return NULL; objc_global_mutex_lock(); for (ml = cls->methodlist; ml != NULL; ml = ml->next) { - for (i = 0; i < ml->count; i++) { + for (unsigned int i = 0; i < ml->count; i++) { if (sel_isEqual((SEL)&ml->methods[i].sel, sel)) { const char *ret = ml->methods[i].sel.types; objc_global_mutex_unlock(); return ret; } @@ -647,11 +629,11 @@ if ((cats = objc_categories_for_class(cls)) != NULL) { for (; *cats != NULL; cats++) { for (ml = (*cats)->instance_methods; ml != NULL; ml = ml->next) { - for (i = 0; i < ml->count; i++) { + for (unsigned int i = 0; i < ml->count; i++) { if (ml->methods[i].sel.uid == sel->uid) { const char *ret = ml->methods[i].sel.types; objc_global_mutex_unlock(); @@ -673,17 +655,16 @@ IMP class_replaceMethod(Class cls, SEL sel, IMP newimp, const char *types) { struct objc_method_list *ml; struct objc_category **cats; - unsigned int i; IMP oldimp; objc_global_mutex_lock(); for (ml = cls->methodlist; ml != NULL; ml = ml->next) { - for (i = 0; i < ml->count; i++) { + for (unsigned int i = 0; i < ml->count; i++) { if (ml->methods[i].sel.uid == sel->uid) { oldimp = ml->methods[i].imp; ml->methods[i].imp = newimp; objc_update_dtable(cls); @@ -701,11 +682,11 @@ ml = (*cats)->class_methods; else ml = (*cats)->instance_methods; for (; ml != NULL; ml = ml->next) { - for (i = 0; i < ml->count; i++) { + for (unsigned int i = 0; i < ml->count; i++) { if (ml->methods[i].sel.uid == sel->uid) { oldimp = ml->methods[i].imp; ml->methods[i].imp = newimp; @@ -840,16 +821,14 @@ } void objc_unregister_all_classes(void) { - uint32_t i; - if (classes == NULL) return; - for (i = 0; i < classes->size; i++) { + for (uint32_t i = 0; i < classes->size; i++) { if (classes->data[i] != NULL && classes->data[i] != &objc_deleted_bucket) { void *cls = (Class)classes->data[i]->obj; if (cls == Nil || (uintptr_t)cls & 1) Index: src/runtime/dtable.m ================================================================== --- src/runtime/dtable.m +++ src/runtime/dtable.m @@ -28,12 +28,10 @@ #endif static void init(void) { - uint16_t i; - empty_level2 = malloc(sizeof(struct objc_dtable_level2)); if (empty_level2 == NULL) OBJC_ERROR("Not enough memory to allocate dtable!"); #ifdef OF_SELUID24 @@ -41,25 +39,24 @@ if (empty_level3 == NULL) OBJC_ERROR("Not enough memory to allocate dtable!"); #endif #ifdef OF_SELUID24 - for (i = 0; i < 256; i++) { + for (uint_fast16_t i = 0; i < 256; i++) { empty_level2->buckets[i] = empty_level3; empty_level3->buckets[i] = (IMP)0; } #else - for (i = 0; i < 256; i++) + for (uint_fast16_t i = 0; i < 256; i++) empty_level2->buckets[i] = (IMP)0; #endif } struct objc_dtable* objc_dtable_new(void) { struct objc_dtable *dtable; - uint16_t i; #ifdef OF_SELUID24 if (empty_level2 == NULL || empty_level3 == NULL) init(); #else @@ -68,36 +65,31 @@ #endif if ((dtable = malloc(sizeof(struct objc_dtable))) == NULL) OBJC_ERROR("Not enough memory to allocate dtable!"); - for (i = 0; i < 256; i++) + for (uint_fast16_t i = 0; i < 256; i++) dtable->buckets[i] = empty_level2; return dtable; } void objc_dtable_copy(struct objc_dtable *dst, struct objc_dtable *src) { - uint16_t i, j; -#ifdef OF_SELUID24 - uint16_t k; -#endif - uint32_t idx; - - for (i = 0; i < 256; i++) { + for (uint_fast16_t i = 0; i < 256; i++) { if (src->buckets[i] == empty_level2) continue; #ifdef OF_SELUID24 - for (j = 0; j < 256; j++) { + for (uint_fast16_t j = 0; j < 256; j++) { if (src->buckets[i]->buckets[j] == empty_level3) continue; - for (k = 0; k < 256; k++) { + for (uint_fast16_t k = 0; k < 256; k++) { IMP obj; + uint32_t idx; obj = src->buckets[i]->buckets[j]->buckets[k]; if (obj == (IMP)0) continue; @@ -106,14 +98,13 @@ (((uint32_t)i << 16) | (j << 8) | k); objc_dtable_set(dst, idx, obj); } } #else - for (j = 0; j < 256; j++) { - IMP obj; - - obj = src->buckets[i]->buckets[j]; + for (uint_fast16_t j = 0; j < 256; j++) { + IMP obj = src->buckets[i]->buckets[j]; + uint32_t idx; if (obj == (IMP)0) continue; idx = (uint32_t)((i << 8) | j); @@ -134,19 +125,17 @@ uint8_t i = idx >> 8; uint8_t j = idx; #endif if (dtable->buckets[i] == empty_level2) { - struct objc_dtable_level2 *level2; - uint16_t l; - - level2 = malloc(sizeof(struct objc_dtable_level2)); + struct objc_dtable_level2 *level2 = + malloc(sizeof(struct objc_dtable_level2)); if (level2 == NULL) OBJC_ERROR("Not enough memory to insert into dtable!"); - for (l = 0; l < 256; l++) + for (uint_fast16_t l = 0; l < 256; l++) #ifdef OF_SELUID24 level2->buckets[l] = empty_level3; #else level2->buckets[l] = (IMP)0; #endif @@ -154,19 +143,17 @@ dtable->buckets[i] = level2; } #ifdef OF_SELUID24 if (dtable->buckets[i]->buckets[j] == empty_level3) { - struct objc_dtable_level3 *level3; - uint16_t l; - - level3 = malloc(sizeof(struct objc_dtable_level3)); + struct objc_dtable_level3 *level3 = + malloc(sizeof(struct objc_dtable_level3)); if (level3 == NULL) OBJC_ERROR("Not enough memory to insert into dtable!"); - for (l = 0; l < 256; l++) + for (uint_fast16_t l = 0; l < 256; l++) level3->buckets[l] = (IMP)0; dtable->buckets[i]->buckets[j] = level3; } @@ -177,21 +164,16 @@ } void objc_dtable_free(struct objc_dtable *dtable) { - uint16_t i; -#ifdef OF_SELUID24 - uint16_t j; -#endif - - for (i = 0; i < 256; i++) { + for (uint_fast16_t i = 0; i < 256; i++) { if (dtable->buckets[i] == empty_level2) continue; #ifdef OF_SELUID24 - for (j = 0; j < 256; j++) + for (uint_fast16_t j = 0; j < 256; j++) if (dtable->buckets[i]->buckets[j] != empty_level3) free(dtable->buckets[i]->buckets[j]); #endif free(dtable->buckets[i]); Index: src/runtime/hashtable.m ================================================================== --- src/runtime/hashtable.m +++ src/runtime/hashtable.m @@ -75,11 +75,11 @@ } static void resize(struct objc_hashtable *table, uint32_t count) { - uint32_t i, fullness, nsize; + uint32_t fullness, nsize; struct objc_hashtable_bucket **ndata; if (count > UINT32_MAX / sizeof(*table->data) || count > UINT32_MAX / 8) OBJC_ERROR("Integer overflow!"); @@ -99,11 +99,11 @@ return; if ((ndata = calloc(nsize, sizeof(sizeof(*ndata)))) == NULL) OBJC_ERROR("Not enough memory to resize hash table!"); - for (i = 0; i < table->size; i++) { + for (uint32_t i = 0; i < table->size; i++) { if (table->data[i] != NULL && table->data[i] != &objc_deleted_bucket) { uint32_t j, last; last = nsize; @@ -230,15 +230,13 @@ } void objc_hashtable_free(struct objc_hashtable *table) { - uint32_t i; - - for (i = 0; i < table->size; i++) + for (uint32_t i = 0; i < table->size; i++) if (table->data[i] != NULL && table->data[i] != &objc_deleted_bucket) free(table->data[i]); free(table->data); free(table); } Index: src/runtime/property.m ================================================================== --- src/runtime/property.m +++ src/runtime/property.m @@ -32,13 +32,11 @@ #ifdef OF_HAVE_THREADS static void __attribute__((__constructor__)) init(void) { - size_t i; - - for (i = 0; i < NUM_SPINLOCKS; i++) + for (size_t i = 0; i < NUM_SPINLOCKS; i++) if (!of_spinlock_new(&spinlocks[i])) OBJC_ERROR("Failed to initialize spinlocks!") } #endif Index: src/runtime/protocol.m ================================================================== --- src/runtime/protocol.m +++ src/runtime/protocol.m @@ -37,33 +37,30 @@ } bool protocol_conformsToProtocol(Protocol *a, Protocol *b) { - struct objc_protocol_list *pl; - size_t i; - if (protocol_isEqual(a, b)) return true; - for (pl = a->protocol_list; pl != NULL; pl = pl->next) - for (i = 0; i < pl->count; i++) + for (struct objc_protocol_list *pl = a->protocol_list; + pl != NULL; pl = pl->next) + for (size_t i = 0; i < pl->count; i++) if (protocol_conformsToProtocol(pl->list[i], b)) return true; return false; } bool class_conformsToProtocol(Class cls, Protocol *p) { - struct objc_protocol_list *pl; struct objc_category **cats; - long i, j; - for (pl = cls->protocols; pl != NULL; pl = pl->next) - for (i = 0; i < pl->count; i++) + for (struct objc_protocol_list *pl = cls->protocols; + pl != NULL; pl = pl->next) + for (long i = 0; i < pl->count; i++) if (protocol_conformsToProtocol(pl->list[i], p)) return true; objc_global_mutex_lock(); @@ -70,13 +67,14 @@ if ((cats = objc_categories_for_class(cls)) == NULL) { objc_global_mutex_unlock(); return false; } - for (i = 0; cats[i] != NULL; i++) { - for (pl = cats[i]->protocols; pl != NULL; pl = pl->next) { - for (j = 0; j < pl->count; j++) { + for (long i = 0; cats[i] != NULL; i++) { + for (struct objc_protocol_list *pl = cats[i]->protocols; + pl != NULL; pl = pl->next) { + for (long j = 0; j < pl->count; j++) { if (protocol_conformsToProtocol( pl->list[j], p)) { objc_global_mutex_unlock(); return true; } Index: src/runtime/selector.m ================================================================== --- src/runtime/selector.m +++ src/runtime/selector.m @@ -137,13 +137,11 @@ { objc_hashtable_free(selectors); objc_sparsearray_free(selector_names); if (free_list != NULL) { - size_t i; - - for (i = 0; i < free_list_cnt; i++) + for (size_t i = 0; i < free_list_cnt; i++) free(free_list[i]); free(free_list); } Index: src/runtime/sparsearray.m ================================================================== --- src/runtime/sparsearray.m +++ src/runtime/sparsearray.m @@ -40,13 +40,12 @@ void* objc_sparsearray_get(struct objc_sparsearray *sparsearray, uintptr_t idx) { struct objc_sparsearray_data *iter = sparsearray->data; - uint8_t i; - for (i = 0; i < sparsearray->index_size - 1; i++) { + for (uint8_t i = 0; i < sparsearray->index_size - 1; i++) { uintptr_t j = (idx >> ((sparsearray->index_size - i - 1) * 8)) & 0xFF; if ((iter = iter->next[j]) == NULL) return NULL; @@ -58,13 +57,12 @@ void objc_sparsearray_set(struct objc_sparsearray *sparsearray, uintptr_t idx, void *value) { struct objc_sparsearray_data *iter = sparsearray->data; - uint8_t i; - for (i = 0; i < sparsearray->index_size - 1; i++) { + for (uint8_t i = 0; i < sparsearray->index_size - 1; i++) { uintptr_t j = (idx >> ((sparsearray->index_size - i - 1) * 8)) & 0xFF; if (iter->next[j] == NULL) if ((iter->next[j] = calloc(1, @@ -79,16 +77,14 @@ } static void free_sparsearray_data(struct objc_sparsearray_data *data, uint8_t depth) { - uint16_t i; - if (data == NULL || depth == 0) return; - for (i = 0; i < 256; i++) + for (uint_fast16_t i = 0; i < 256; i++) free_sparsearray_data(data->next[i], depth - 1); free(data); } Index: src/runtime/static-instances.m ================================================================== --- src/runtime/static-instances.m +++ src/runtime/static-instances.m @@ -27,20 +27,17 @@ void objc_init_static_instances(struct objc_abi_symtab *symtab) { struct objc_abi_static_instances **si; - size_t i; /* Check if the class for a static instance became available */ - for (i = 0; i < static_instances_cnt; i++) { + for (size_t i = 0; i < static_instances_cnt; i++) { Class cls = objc_lookUpClass(static_instances[i]->class_name); if (cls != Nil) { - id *instances; - - for (instances = static_instances[i]->instances; + for (id *instances = static_instances[i]->instances; *instances != nil; instances++) object_setClass(*instances, cls); static_instances_cnt--; @@ -71,14 +68,12 @@ for (; *si != NULL; si++) { Class cls = objc_lookUpClass((*si)->class_name); if (cls != Nil) { - id *instances; - - for (instances = (*si)->instances; *instances != nil; - instances++) + for (id *instances = (*si)->instances; + *instances != nil; instances++) object_setClass(*instances, cls); } else { static_instances = realloc(static_instances, sizeof(struct objc_abi_static_instances*) * (static_instances_cnt + 1)); Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -202,13 +202,11 @@ static OF_INLINE bool of_spinlock_lock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) # if defined(OF_HAVE_SCHED_YIELD) || defined(OF_WINDOWS) - int i; - - for (i = 0; i < OF_SPINCOUNT; i++) + for (size_t i = 0; i < OF_SPINCOUNT; i++) if (of_spinlock_trylock(spinlock)) return true; while (!of_spinlock_trylock(spinlock)) # ifndef OF_WINDOWS Index: src/threading_winapi.m ================================================================== --- src/threading_winapi.m +++ src/threading_winapi.m @@ -159,13 +159,11 @@ } bool of_condition_broadcast(of_condition_t *condition) { - int i; - - for (i = 0; i < condition->count; i++) + for (int i = 0; i < condition->count; i++) if (!SetEvent(condition->event)) return false; return true; } Index: src/windows_1252.m ================================================================== --- src/windows_1252.m +++ src/windows_1252.m @@ -39,13 +39,11 @@ bool of_unicode_to_windows_1252(const of_unichar_t *input, uint8_t *output, size_t length, bool lossy) { - size_t i; - - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { of_unichar_t c = input[i]; if OF_UNLIKELY (c > 0xFF) { if OF_UNLIKELY (c > 0xFFFF) { if (lossy) { Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -180,15 +180,15 @@ @implementation TestsAppDelegate - (void)outputString: (OFString*)str inColor: (int)color { #if defined(OF_PSP) - char i, space = ' '; + char space = ' '; int y = pspDebugScreenGetY(); pspDebugScreenSetXY(0, y); - for (i = 0; i < 68; i++) + for (uint8_t i = 0; i < 68; i++) pspDebugScreenPrintData(&space, 1); switch (color) { case NO_COLOR: pspDebugScreenSetTextColor(0xFFFFFF); Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -84,11 +84,11 @@ for (OFString *path in arguments) { void *pool; OFStream *file; const uint8_t *digest; - size_t i, digestSize; + size_t digestSize; if (first) { first = false; continue; } @@ -136,11 +136,11 @@ [file close]; digest = [hash digest]; digestSize = [[hash class] digestSize]; - for (i = 0; i < digestSize; i++) + for (size_t i = 0; i < digestSize; i++) [of_stdout writeFormat: @"%02x", digest[i]]; [of_stdout writeFormat: @" %@\n", path]; outer_loop_end: Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -416,11 +416,11 @@ DISPOSITION_PARAM_NAME, DISPOSITION_PARAM_VALUE, DISPOSITION_PARAM_QUOTED, DISPOSITION_EXPECT_SEMICOLON } state; - size_t i, last; + size_t last; OFString *type = nil, *paramName = nil, *paramValue; OFMutableDictionary *params; OFString *fileName; if (contentDisposition == nil) @@ -432,11 +432,11 @@ UTF8StringLength = [contentDisposition UTF8StringLength]; state = DISPOSITION_TYPE; params = [OFMutableDictionary dictionary]; last = 0; - for (i = 0; i < UTF8StringLength; i++) { + for (size_t i = 0; i < UTF8StringLength; i++) { switch (state) { case DISPOSITION_TYPE: if (UTF8String[i] == ';' || UTF8String[i] == ' ') { type = [OFString stringWithUTF8String: UTF8String Index: utils/ofhttp/ProgressBar.m ================================================================== --- utils/ofhttp/ProgressBar.m +++ utils/ofhttp/ProgressBar.m @@ -90,11 +90,10 @@ _received = received; } - (void)_drawProgress { - size_t i; float bars, percent; unsigned short barWidth; #ifdef HAVE_SYS_IOCTL_H struct winsize ws; @@ -111,11 +110,11 @@ percent = (float)(_resumedFrom + _received) / (float)(_resumedFrom + _length) * 100; [of_stdout writeString: @"\r ▕"]; - for (i = 0; i < (size_t)bars; i++) + for (size_t i = 0; i < (size_t)bars; i++) [of_stdout writeString: @"█"]; if (bars < barWidth) { float remainder = bars - floorf(bars); if (remainder >= 0.875) @@ -133,11 +132,11 @@ else if (remainder >= 0.125) [of_stdout writeString: @"▏"]; else [of_stdout writeString: @" "]; - for (i = 0; i < barWidth - (size_t)bars - 1; i++) + for (size_t i = 0; i < barWidth - (size_t)bars - 1; i++) [of_stdout writeString: @" "]; } [of_stdout writeFormat: @"▏ %6.2f%% ", percent];