Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -3801,10 +3801,11 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 2; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_PEDANTIC = YES; + GCC_WARN_SHADOW = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; @@ -3854,10 +3855,11 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 2; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_PEDANTIC = YES; + GCC_WARN_SHADOW = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; OTHER_CFLAGS = ( Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -174,10 +174,12 @@ OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings" AC_SUBST(NO_CONST_CFSTRINGS, "-fno-constant-cfstrings") ]) AX_CHECK_COMPILER_FLAGS(-Wsign-compare -Werror, [OBJCFLAGS="$OBJCFLAGS -Wsign-compare"]) +AX_CHECK_COMPILER_FLAGS(-Wshadow -Werror, + [OBJCFLAGS="$OBJCFLAGS -Wshadow"]) AX_CHECK_COMPILER_FLAGS(-Wshorten-64-to-32 -Werror, [OBJCFLAGS="$OBJCFLAGS -Wshorten-64-to-32"]) AX_CHECK_COMPILER_FLAGS(-Wsemicolon-before-method-body -Werror, [OBJCFLAGS="$OBJCFLAGS -Wsemicolon-before-method-body"]) AX_CHECK_COMPILER_FLAGS(-Wobjc-missing-property-synthesis -Werror, Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -273,15 +273,14 @@ return [self objectAtIndex: index]; } - (id)valueForKey: (OFString *)key { - OFMutableArray *ret; + id ret; if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - id ret; key = [key substringWithRange: of_range(1, [key length] - 1)]; ret = [[super valueForKey: key] retain]; objc_autoreleasePoolPop(pool); @@ -730,13 +729,13 @@ } - (void)makeObjectsPerformSelector: (SEL)selector withObject: (id)object { - for (id object in self) - [object performSelector: selector - withObject: object]; + for (id objectIter in self) + [objectIter performSelector: selector + withObject: object]; } - (OFArray *)sortedArray { OFMutableArray *new = [[self mutableCopy] autorelease]; Index: src/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -508,17 +508,17 @@ [stream writeFormat: @"%@\r\n", comment->_comment]; } else if ([line isKindOfClass: [OFINICategory_Pair class]]) { OFINICategory_Pair *pair = line; OFString *key = escapeString(pair->_key); OFString *value = escapeString(pair->_value); - OFString *line = [OFString + OFString *tmp = [OFString stringWithFormat: @"%@=%@\r\n", key, value]; - [stream writeString: line + [stream writeString: tmp encoding: encoding]; } else @throw [OFInvalidArgumentException exception]; } return true; } @end Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -207,14 +207,14 @@ mapTable->_objectFunctions.equal != _objectFunctions.equal) return false; for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { - void *object = + void *objectIter = [mapTable objectForKey: _buckets[i]->key]; - if (!_objectFunctions.equal(object, + if (!_objectFunctions.equal(objectIter, _buckets[i]->object)) return false; } } Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -211,15 +211,14 @@ OF_UNRECOGNIZED_SELECTOR } - (id)valueForKey: (OFString *)key { - OFMutableSet *ret; + id ret; if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - id ret; key = [key substringWithRange: of_range(1, [key length] - 1)]; ret = [[super valueForKey: key] retain]; objc_autoreleasePoolPop(pool); Index: src/OFString+XMLUnescaping.m ================================================================== --- src/OFString+XMLUnescaping.m +++ src/OFString+XMLUnescaping.m @@ -127,28 +127,29 @@ memcmp(entity, "amp", 3) == 0) [ret appendCString: "&" encoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entity[0] == '#') { - void *pool; + void *pool2; OFString *tmp; - pool = objc_autoreleasePoolPush(); + pool2 = objc_autoreleasePoolPush(); tmp = parseNumericEntity(entity, entityLength); if (tmp == nil) @throw [OFInvalidFormatException exception]; [ret appendString: tmp]; - objc_autoreleasePoolPop(pool); + + objc_autoreleasePoolPop(pool2); } else { - void *pool; + void *pool2; OFString *name, *tmp; - pool = objc_autoreleasePoolPush(); + pool2 = objc_autoreleasePoolPush(); name = [OFString stringWithUTF8String: entity length: entityLength]; tmp = lookup(context, self, name); @@ -156,11 +157,12 @@ if (tmp == nil) @throw [OFUnknownXMLEntityException exceptionWithEntityName: name]; [ret appendString: tmp]; - objc_autoreleasePoolPop(pool); + + objc_autoreleasePoolPop(pool2); } last = i + 1; inEntity = false; } Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -134,28 +134,28 @@ UTF8String = tmp2; } if ((tmp2 = strchr(UTF8String, ':')) != NULL) { - void *pool; + void *pool2; OFString *portString; *tmp2 = '\0'; tmp2++; _host = [[OFString alloc] initWithUTF8String: UTF8String]; - pool = objc_autoreleasePoolPush(); + pool2 = objc_autoreleasePoolPush(); portString = [OFString stringWithUTF8String: tmp2]; if ([portString decimalValue] > 65535) @throw [OFInvalidFormatException exception]; _port = [portString decimalValue]; - objc_autoreleasePoolPop(pool); + objc_autoreleasePoolPop(pool2); } else { _host = [[OFString alloc] initWithUTF8String: UTF8String]; if ([_scheme isEqual: @"http"]) Index: tests/OFArrayTests.m ================================================================== --- tests/OFArrayTests.m +++ tests/OFArrayTests.m @@ -351,50 +351,50 @@ [m[0] removeLastObject]; #ifdef OF_HAVE_BLOCKS { - __block bool ok = true; + __block bool blockOk = true; __block size_t count = 0; OFArray *cmp = a[0]; OFMutableArray *a2; m[0] = [[a[0] mutableCopy] autorelease]; [m[0] enumerateObjectsUsingBlock: - ^ (id obj, size_t idx, bool *stop) { + ^ (id object, size_t idx, bool *stop) { count++; - if (![obj isEqual: [cmp objectAtIndex: idx]]) - ok = false; + if (![object isEqual: [cmp objectAtIndex: idx]]) + blockOk = false; }]; if (count != [cmp count]) - ok = false; + blockOk = false; - TEST(@"Enumeration using blocks", ok) + TEST(@"Enumeration using blocks", blockOk) - ok = false; + blockOk = false; a2 = m[0]; @try { [a2 enumerateObjectsUsingBlock: - ^ (id obj, size_t idx, bool *stop) { + ^ (id object, size_t idx, bool *stop) { [a2 removeObjectAtIndex: idx]; }]; } @catch (OFEnumerationMutationException *e) { - ok = true; + blockOk = true; } @catch (OFOutOfRangeException *e) { /* * Out of bounds access due to enumeration not being * detected. */ } TEST(@"Detection of mutation during enumeration using blocks", - ok) + blockOk) } TEST(@"-[replaceObjectsUsingBlock:]", - R([m[0] replaceObjectsUsingBlock: ^ id (id obj, size_t idx) { + R([m[0] replaceObjectsUsingBlock: ^ id (id object, size_t idx) { switch (idx) { case 0: return @"foo"; case 1: return @"bar"; @@ -402,11 +402,11 @@ return nil; }]) && [[m[0] description] isEqual: @"(\n\tfoo,\n\tbar\n)"]) TEST(@"-[mappedArrayUsingBlock:]", - [[[m[0] mappedArrayUsingBlock: ^ id (id obj, size_t idx) { + [[[m[0] mappedArrayUsingBlock: ^ id (id object, size_t idx) { switch (idx) { case 0: return @"foobar"; case 1: return @"qux"; @@ -414,12 +414,12 @@ return nil; }] description] isEqual: @"(\n\tfoobar,\n\tqux\n)"]) TEST(@"-[filteredArrayUsingBlock:]", - [[[m[0] filteredArrayUsingBlock: ^ bool (id obj, size_t idx) { - return [obj isEqual: @"foo"]; + [[[m[0] filteredArrayUsingBlock: ^ bool (id object, size_t idx) { + return [object isEqual: @"foo"]; }] description] isEqual: @"(\n\tfoo\n)"]) TEST(@"-[foldUsingBlock:]", [[arrayClass arrayWithObjects: [OFMutableString string], @"foo", @"bar", @"baz", nil] foldUsingBlock: ^ id (id left, id right) { Index: tests/OFDictionaryTests.m ================================================================== --- tests/OFDictionaryTests.m +++ tests/OFDictionaryTests.m @@ -266,47 +266,47 @@ @"q&x", @"q=x", nil] stringByURLEncoding] isEqual: @"q%26x=q%3Dx&foo=bar"]) #ifdef OF_HAVE_BLOCKS { - __block size_t i = 0; - __block bool ok = true; + __block size_t j = 0; + __block bool blockOk = true; [mutDict enumerateKeysAndObjectsUsingBlock: - ^ (id key, id obj, bool *stop) { - if (i > 1 || ![key isEqual: keys[i]]) { - ok = false; + ^ (id key, id object, bool *stop) { + if (j > 1 || ![key isEqual: keys[j]]) { + blockOk = false; *stop = true; return; } [mutDict setObject: [mutDict objectForKey: key] forKey: key]; - i++; + j++; }]; - TEST(@"Enumeration using blocks", ok) + TEST(@"Enumeration using blocks", blockOk) - ok = false; + blockOk = false; @try { [mutDict enumerateKeysAndObjectsUsingBlock: - ^ (id key, id obj, bool *stop) { + ^ (id key, id object, bool *stop) { [mutDict setObject: @"" forKey: @""]; }]; } @catch (OFEnumerationMutationException *e) { - ok = true; + blockOk = true; } TEST(@"Detection of mutation during enumeration using blocks", - ok) + blockOk) [mutDict removeObjectForKey: @""]; } TEST(@"-[replaceObjectsUsingBlock:]", - R([mutDict replaceObjectsUsingBlock: ^ id (id key, id obj) { + R([mutDict replaceObjectsUsingBlock: ^ id (id key, id object) { if ([key isEqual: keys[0]]) return @"value_1"; if ([key isEqual: keys[1]]) return @"value_2"; @@ -313,21 +313,22 @@ return nil; }]) && [[mutDict objectForKey: keys[0]] isEqual: @"value_1"] && [[mutDict objectForKey: keys[1]] isEqual: @"value_2"]) TEST(@"-[mappedDictionaryUsingBlock:]", - [[[mutDict mappedDictionaryUsingBlock: ^ id (id key, id obj) { + [[[mutDict mappedDictionaryUsingBlock: ^ id (id key, id object) { if ([key isEqual: keys[0]]) return @"val1"; if ([key isEqual: keys[1]]) return @"val2"; return nil; }] description] isEqual: @"{\n\tkey1 = val1;\n\tkey2 = val2;\n}"]) TEST(@"-[filteredDictionaryUsingBlock:]", - [[[mutDict filteredDictionaryUsingBlock: ^ bool (id key, id obj) { + [[[mutDict filteredDictionaryUsingBlock: + ^ bool (id key, id object) { return [key isEqual: keys[0]]; }] description] isEqual: @"{\n\tkey1 = value_1;\n}"]) #endif TEST(@"-[count]", [mutDict count] == 2) Index: tests/OFListTests.m ================================================================== --- tests/OFListTests.m +++ tests/OFListTests.m @@ -125,12 +125,12 @@ loe = [list firstListObject]; i = 0; ok = true; - for (OFString *obj in list) { - if (![obj isEqual: loe->object]) + for (OFString *object in list) { + if (![object isEqual: loe->object]) ok = false; loe = loe->next; i++; } @@ -140,12 +140,12 @@ TEST(@"Fast Enumeration", ok) ok = false; @try { - for (OFString *obj in list) { - (void)obj; + for (OFString *object in list) { + (void)object; [list removeListObject: [list lastListObject]]; } } @catch (OFEnumerationMutationException *e) { ok = true; Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -832,14 +832,15 @@ OF_LOCALIZED(@"size_unknown", @"unknown"); if (_verbose) { void *pool = objc_autoreleasePoolPush(); OFDictionary OF_GENERIC(OFString *, OFString *) - *headers = [response headers]; - OFEnumerator *keyEnumerator = [headers keyEnumerator]; + *responseHeaders = [response headers]; + OFEnumerator *keyEnumerator = + [responseHeaders keyEnumerator]; OFEnumerator *objectEnumerator = - [headers objectEnumerator]; + [responseHeaders objectEnumerator]; OFString *key, *object; [of_stdout writeString: @" "]; [of_stdout writeLine: OF_LOCALIZED( @"info_name_unaligned",