Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -187,12 +187,10 @@ [OBJCFLAGS="$OBJCFLAGS -Wobjc-missing-property-synthesis"]) AX_CHECK_COMPILER_FLAGS([-Watomic-properties -Werror], [ OBJCFLAGS="$OBJCFLAGS -Watomic-properties" TESTS_OBJCFLAGS="$TESTS_OBJCFLAGS -Wno-atomic-properties" ]) -AX_CHECK_COMPILER_FLAGS([-Wnullable-to-nonnull-conversion -Werror], - [OBJCFLAGS="$OBJCFLAGS -Wnullable-to-nonnull-conversion"]) AC_MSG_CHECKING(whether Objective C compiler supports properties) AC_TRY_COMPILE([ #ifdef __has_attribute # if __has_attribute(objc_root_class) Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -97,12 +97,11 @@ #define SIGNAL_HANDLER(sig) \ static void \ handle##sig(int signal) \ { \ - app->_##sig##Handler( \ - (id )app->_delegate, \ + app->_##sig##Handler(app->_delegate, \ @selector(applicationDidReceive##sig)); \ } SIGNAL_HANDLER(SIGINT) #ifdef SIGHUP SIGNAL_HANDLER(SIGHUP) Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -642,23 +642,23 @@ - (OFDate *)earlierDate: (OFDate *)otherDate { if (otherDate == nil) return self; - if ([self compare: (OFDate *)otherDate] == OF_ORDERED_DESCENDING) - return (OFDate *)otherDate; + if ([self compare: otherDate] == OF_ORDERED_DESCENDING) + return otherDate; return self; } - (OFDate *)laterDate: (OFDate *)otherDate { if (otherDate == nil) return self; - if ([self compare: (OFDate *)otherDate] == OF_ORDERED_ASCENDING) - return (OFDate *)otherDate; + if ([self compare: otherDate] == OF_ORDERED_ASCENDING) + return otherDate; return self; } - (of_time_interval_t)timeIntervalSince1970 Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -468,11 +468,11 @@ (of_dictionary_enumeration_block_t)block { bool stop = false; for (id key in self) { - block(key, (id)[self objectForKey: key], &stop); + block(key, [self objectForKey: key], &stop); if (stop) break; } } Index: src/OFHMAC.m ================================================================== --- src/OFHMAC.m +++ src/OFHMAC.m @@ -125,17 +125,17 @@ { if (_outerHash == nil || _innerHash == nil) @throw [OFInvalidArgumentException exception]; if (_calculated) - return (const unsigned char *)[_outerHash digest]; + return [_outerHash digest]; - [_outerHash updateWithBuffer: (const unsigned char *)[_innerHash digest] + [_outerHash updateWithBuffer: [_innerHash digest] length: [_hashClass digestSize]]; _calculated = true; - return (const unsigned char *)[_outerHash digest]; + return [_outerHash digest]; } - (size_t)digestSize { return [_hashClass digestSize]; Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -95,11 +95,11 @@ requestString = [OFMutableString stringWithFormat: @"%s %@", of_http_request_method_to_string(method), path]; if ([URL query] != nil) { [requestString appendString: @"?"]; - [requestString appendString: (OFString *)[URL query]]; + [requestString appendString: [URL query]]; } [requestString appendString: @" HTTP/"]; [requestString appendString: [request protocolVersionString]]; [requestString appendString: @"\r\n"]; Index: src/OFHTTPCookie.m ================================================================== --- src/OFHTTPCookie.m +++ src/OFHTTPCookie.m @@ -403,13 +403,13 @@ void *pool = objc_autoreleasePoolPush(); [ret appendFormat: @"; Domain=%@; Path=%@", _domain, _path]; if (_expires != nil) - [ret appendString: [(OFDate *)_expires - dateStringWithFormat: @"; Expires=%a, %d %b %Y " - @"%H:%M:%S +0000"]]; + [ret appendString: + [_expires dateStringWithFormat: @"; Expires=%a, %d %b %Y " + @"%H:%M:%S +0000"]]; if (_secure) [ret appendString: @"; Secure"]; if (_HTTPOnly) Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -723,11 +723,11 @@ if (_listeningSocket != nil) @throw [OFAlreadyConnectedException exception]; _listeningSocket = [[OFTCPSocket alloc] init]; - _port = [_listeningSocket bindToHost: (OFString *)_host + _port = [_listeningSocket bindToHost: _host port: _port]; [_listeningSocket listen]; [_listeningSocket asyncAcceptWithTarget: self selector: @selector(of_socket: Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -148,15 +148,15 @@ _name = [[OFString alloc] initWithUTF8String: property->name]; _attributes = property->attributes | (property->extended_attributes << 8); if (property->getter.name != NULL) - _getter = [[OFString alloc] initWithUTF8String: - (const char *)property->getter.name]; + _getter = [[OFString alloc] + initWithUTF8String: property->getter.name]; if (property->setter.name != NULL) - _setter = [[OFString alloc] initWithUTF8String: - (const char *)property->setter.name]; + _setter = [[OFString alloc] + initWithUTF8String: property->setter.name]; } @catch (id e) { [self release]; @throw e; } @@ -389,11 +389,11 @@ @try { const char *name = ivar_getName(ivar); if (name != NULL) _name = [[OFString alloc] initWithUTF8String: - (const char *)ivar_getName(ivar)]; + ivar_getName(ivar)]; _typeEncoding = ivar_getTypeEncoding(ivar); _offset = ivar_getOffset(ivar); } @catch (id e) { [self release]; @throw e; Index: src/OFMutableString_UTF8.m ================================================================== --- src/OFMutableString_UTF8.m +++ src/OFMutableString_UTF8.m @@ -211,13 +211,13 @@ _s->hashed = false; if (lenNew == (size_t)lenOld) memcpy(_s->cString + index, buffer, lenNew); else if (lenNew > (size_t)lenOld) { - _s->cString = (void *)[self resizeMemory: _s->cString - size: _s->cStringLength - - lenOld + lenNew + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength - + lenOld + lenNew + 1]; memmove(_s->cString + index + lenNew, _s->cString + index + lenOld, _s->cStringLength - index - lenOld); memcpy(_s->cString + index, buffer, lenNew); @@ -240,11 +240,11 @@ if (character >= 0x80) _s->isUTF8 = true; @try { - _s->cString = (void *)[self + _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } @@ -269,13 +269,13 @@ case -1: @throw [OFInvalidEncodingException exception]; } _s->hashed = false; - _s->cString = (void *)[self resizeMemory: _s->cString - size: _s->cStringLength + - UTF8StringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + + UTF8StringLength + 1]; memcpy(_s->cString + _s->cStringLength, UTF8String, UTF8StringLength + 1); _s->cStringLength += UTF8StringLength; _s->length += length; @@ -299,13 +299,13 @@ case -1: @throw [OFInvalidEncodingException exception]; } _s->hashed = false; - _s->cString = (void *)[self resizeMemory: _s->cString - size: _s->cStringLength + - UTF8StringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + + UTF8StringLength + 1]; memcpy(_s->cString + _s->cStringLength, UTF8String, UTF8StringLength); _s->cStringLength += UTF8StringLength; _s->length += length; @@ -347,13 +347,13 @@ @throw [OFInvalidArgumentException exception]; UTF8StringLength = [string UTF8StringLength]; _s->hashed = false; - _s->cString = (void *)[self resizeMemory: _s->cString - size: _s->cStringLength + - UTF8StringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + + UTF8StringLength + 1]; memcpy(_s->cString + _s->cStringLength, [string UTF8String], UTF8StringLength); _s->cStringLength += UTF8StringLength; _s->length += [string length]; @@ -392,13 +392,12 @@ } tmp[j] = '\0'; _s->hashed = false; - _s->cString = (void *)[self - resizeMemory: _s->cString - size: _s->cStringLength + j + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + j + 1]; memcpy(_s->cString + _s->cStringLength, tmp, j + 1); _s->cStringLength += j; _s->length += length; @@ -522,12 +521,12 @@ index = of_string_utf8_get_position(_s->cString, index, _s->cStringLength); newCStringLength = _s->cStringLength + [string UTF8StringLength]; _s->hashed = false; - _s->cString = (void *)[self resizeMemory: _s->cString - size: newCStringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: newCStringLength + 1]; memmove(_s->cString + index + [string UTF8StringLength], _s->cString + index, _s->cStringLength - index); memcpy(_s->cString + index, [string UTF8String], [string UTF8StringLength]); @@ -565,13 +564,12 @@ _s->length -= range.length; _s->cStringLength -= end - start; _s->cString[_s->cStringLength] = 0; @try { - _s->cString = (void *)[self - resizeMemory: _s->cString - size: _s->cStringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -608,12 +606,12 @@ * We must not resize the string if the new string is smaller, because * then we can't memmove() the rest of the string forward as the rest is * lost due to the resize! */ if (newCStringLength > _s->cStringLength) - _s->cString = (void *)[self resizeMemory: _s->cString - size: newCStringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: newCStringLength + 1]; memmove(_s->cString + start + [replacement UTF8StringLength], _s->cString + end, _s->cStringLength - end); memcpy(_s->cString + start, [replacement UTF8String], [replacement UTF8StringLength]); @@ -622,12 +620,12 @@ /* * If the new string is smaller, we can safely resize it now as we're * done with memmove(). */ if (newCStringLength < _s->cStringLength) - _s->cString = (void *)[self resizeMemory: _s->cString - size: newCStringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: newCStringLength + 1]; _s->cStringLength = newCStringLength; _s->length = newLength; if ([replacement isKindOfClass: [OFString_UTF8 class]] || @@ -739,13 +737,12 @@ memmove(_s->cString, _s->cString + i, _s->cStringLength); _s->cString[_s->cStringLength] = '\0'; @try { - _s->cString = (void *)[self - resizeMemory: _s->cString - size: _s->cStringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -767,13 +764,12 @@ _s->cStringLength -= d; _s->length -= d; @try { - _s->cString = (void *)[self - resizeMemory: _s->cString - size: _s->cStringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -805,13 +801,12 @@ memmove(_s->cString, _s->cString + i, _s->cStringLength); _s->cString[_s->cStringLength] = '\0'; @try { - _s->cString = (void *)[self - resizeMemory: _s->cString - size: _s->cStringLength + 1]; + _s->cString = [self resizeMemory: _s->cString + size: _s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -295,13 +295,12 @@ return self; } + (OFString *)className { - return [OFString - stringWithCString: (const char *)class_getName(self) - encoding: OF_STRING_ENCODING_ASCII]; + return [OFString stringWithCString: class_getName(self) + encoding: OF_STRING_ENCODING_ASCII]; } + (bool)isSubclassOfClass: (Class)class { for (Class iter = self; iter != Nil; iter = class_getSuperclass(iter)) @@ -358,13 +357,12 @@ IMP method = [class methodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; - return class_replaceMethod((Class)object_getClass(self), selector, - (IMP)method, typeEncodingForSelector(object_getClass(class), - selector)); + return class_replaceMethod(object_getClass(self), selector, method, + typeEncodingForSelector(object_getClass(class), selector)); } + (IMP)replaceInstanceMethod: (SEL)selector withMethodFromClass: (Class)class { @@ -371,11 +369,11 @@ IMP method = [class instanceMethodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; - return class_replaceMethod(self, selector, (IMP)method, + return class_replaceMethod(self, selector, method, typeEncodingForSelector(class, selector)); } + (void)inheritMethodsFromClass: (Class)class { @@ -484,23 +482,22 @@ return self; } - (Class)class { - return (Class)object_getClass(self); + return object_getClass(self); } - (Class)superclass { return class_getSuperclass(object_getClass(self)); } - (OFString *)className { - return [OFString - stringWithCString: (const char *)object_getClassName(self) - encoding: OF_STRING_ENCODING_ASCII]; + return [OFString stringWithCString: object_getClassName(self) + encoding: OF_STRING_ENCODING_ASCII]; } - (bool)isKindOfClass: (Class)class { for (Class iter = object_getClass(self); iter != Nil; Index: src/OFOptionsParser.m ================================================================== --- src/OFOptionsParser.m +++ src/OFOptionsParser.m @@ -105,20 +105,18 @@ @try { iter2->longOption = [iter->longOption copy]; if ([_longOptions objectForKey: - (OFString *)iter2->longOption] != - NULL) + iter2->longOption] != NULL) @throw [OFInvalidArgumentException exception]; [_longOptions setObject: iter2 - forKey: (OFString *) - iter2->longOption]; + forKey: iter2->longOption]; } @catch (id e) { /* * Make sure we are in a consistent * state where dealloc works. */ @@ -209,12 +207,11 @@ _lastLongOption = [[argument substringWithRange: of_range(2, pos - 2)] copy]; objc_autoreleasePoolPop(pool); - option = [_longOptions objectForKey: - (OFString *)_lastLongOption]; + option = [_longOptions objectForKey: _lastLongOption]; if (option == NULL) return '?'; if (option->hasArgument == 1 && _argument == nil) return ':'; Index: src/OFSet.h ================================================================== --- src/OFSet.h +++ src/OFSet.h @@ -204,11 +204,11 @@ /*! * @brief Returns an arbitrary object in the set. * * @return An arbitrary object in the set */ -- (ObjectType)anyObject; +- (nullable ObjectType)anyObject; /*! * @brief Checks whether the set contains an object equal to the specified * object. * Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -659,14 +659,13 @@ retLength = i; if (i > 0 && _readBuffer[i - 1] == '\r') retLength--; - ret = [OFString - stringWithCString: (char *)_readBuffer - encoding: encoding - length: retLength]; + ret = [OFString stringWithCString: _readBuffer + encoding: encoding + length: retLength]; _readBuffer += i + 1; _readBufferLength -= i + 1; _waitingForDelimiter = false; @@ -689,11 +688,11 @@ retLength = _readBufferLength; if (retLength > 0 && _readBuffer[retLength - 1] == '\r') retLength--; - ret = [OFString stringWithCString: (char *)_readBuffer + ret = [OFString stringWithCString: _readBuffer encoding: encoding length: retLength]; [self freeMemory: _readBufferMemory]; _readBuffer = _readBufferMemory = NULL; @@ -884,11 +883,11 @@ if (j == delimiterLength || _readBuffer[i] == '\0') { if (_readBuffer[i] == '\0') delimiterLength = 1; ret = [OFString - stringWithCString: (char *)_readBuffer + stringWithCString: _readBuffer encoding: encoding length: i + 1 - delimiterLength]; _readBuffer += i + 1; _readBufferLength -= i + 1; @@ -908,11 +907,11 @@ if (_readBuffer == NULL) { _waitingForDelimiter = false; return nil; } - ret = [OFString stringWithCString: (char *)_readBuffer + ret = [OFString stringWithCString: _readBuffer encoding: encoding length: _readBufferLength]; [self freeMemory: _readBufferMemory]; _readBuffer = _readBufferMemory = NULL; @@ -1038,11 +1037,11 @@ - (void)flushWriteBuffer { if (_writeBuffer == NULL) return; - [self lowlevelWriteBuffer: (char *)_writeBuffer + [self lowlevelWriteBuffer: _writeBuffer length: _writeBufferLength]; [self freeMemory: _writeBuffer]; _writeBuffer = NULL; _writeBufferLength = 0; Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -177,11 +177,11 @@ self = [super init]; @try { _s = &_storage; - _s->cString = (void *)[self allocMemoryWithSize: 1]; + _s->cString = [self allocMemoryWithSize: 1]; _s->cString[0] = '\0'; } @catch (id e) { [self release]; @throw e; } @@ -243,12 +243,11 @@ cStringLength -= 3; } _s = &_storage; - _s->cString = (void *)[self - allocMemoryWithSize: cStringLength + 1]; + _s->cString = [self allocMemoryWithSize: cStringLength + 1]; _s->cStringLength = cStringLength; if (encoding == OF_STRING_ENCODING_UTF_8 || encoding == OF_STRING_ENCODING_ASCII) { switch (of_string_utf8_check(cString, cStringLength, @@ -291,11 +290,11 @@ if (bytes == 0) @throw [OFInvalidEncodingException exception]; _s->cStringLength += bytes - 1; - _s->cString = (void *)[self + _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + 1]; memcpy(_s->cString + j, buffer, bytes); j += bytes; @@ -372,11 +371,11 @@ if (byteLength == 0) @throw [OFInvalidEncodingException exception]; _s->cStringLength += byteLength - 1; - _s->cString = (void *)[self + _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + 1]; memcpy(_s->cString + j, buffer, byteLength); j += byteLength; @@ -444,12 +443,11 @@ else _s->isUTF8 = true; _s->length = [string length]; - _s->cString = (void *)[self - allocMemoryWithSize: _s->cStringLength + 1]; + _s->cString = [self allocMemoryWithSize: _s->cStringLength + 1]; memcpy(_s->cString, [string UTF8String], _s->cStringLength + 1); } @catch (id e) { [self release]; @throw e; } @@ -465,12 +463,11 @@ @try { size_t j; _s = &_storage; - _s->cString = (void *)[self - allocMemoryWithSize: (length * 4) + 1]; + _s->cString = [self allocMemoryWithSize: (length * 4) + 1]; _s->length = length; j = 0; for (size_t i = 0; i < length; i++) { size_t len = of_string_utf8_encode(characters[i], @@ -487,12 +484,12 @@ _s->cString[j] = '\0'; _s->cStringLength = j; @try { - _s->cString = (void *)[self resizeMemory: _s->cString - size: j + 1]; + _s->cString = [self resizeMemory: _s->cString + size: j + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } } @catch (id e) { [self release]; @@ -522,12 +519,11 @@ } else if (byteOrder != OF_BYTE_ORDER_NATIVE) swap = true; _s = &_storage; - _s->cString = (void *)[self - allocMemoryWithSize: (length * 4) + 1]; + _s->cString = [self allocMemoryWithSize: (length * 4) + 1]; _s->length = length; j = 0; for (size_t i = 0; i < length; i++) { of_unichar_t character = @@ -573,12 +569,12 @@ _s->cString[j] = '\0'; _s->cStringLength = j; @try { - _s->cString = (void *)[self resizeMemory: _s->cString - size: j + 1]; + _s->cString = [self resizeMemory: _s->cString + size: j + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } } @catch (id e) { [self release]; @@ -608,12 +604,11 @@ } else if (byteOrder != OF_BYTE_ORDER_NATIVE) swap = true; _s = &_storage; - _s->cString = (void *)[self - allocMemoryWithSize: (length * 4) + 1]; + _s->cString = [self allocMemoryWithSize: (length * 4) + 1]; _s->length = length; j = 0; for (size_t i = 0; i < length; i++) { char buffer[4]; @@ -641,12 +636,12 @@ _s->cString[j] = '\0'; _s->cStringLength = j; @try { - _s->cString = (void *)[self resizeMemory: _s->cString - size: j + 1]; + _s->cString = [self resizeMemory: _s->cString + size: j + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } } @catch (id e) { [self release]; @@ -684,11 +679,11 @@ break; case -1: @throw [OFInvalidEncodingException exception]; } - _s->cString = (void *)[self + _s->cString = [self allocMemoryWithSize: cStringLength + 1]; memcpy(_s->cString, tmp, cStringLength + 1); } @finally { free(tmp); } Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -263,11 +263,11 @@ if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) { /* Connect to the SOCKS5 proxy instead */ - host = (OFString *)_SOCKS5Host; + host = _SOCKS5Host; port = _SOCKS5Port; } results = of_resolve_host(host, port, SOCK_STREAM); @@ -605,12 +605,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; if (_address == NULL) @throw [OFInvalidArgumentException exception]; - of_address_to_string_and_port((struct sockaddr *)_address, - _addressLength, &ret, NULL); + of_address_to_string_and_port(_address, _addressLength, &ret, NULL); return ret; } - (bool)isListening Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -209,11 +209,11 @@ @throw [OFInvalidArgumentException exception]; if (_lastReturnedStream == nil) @throw [OFInvalidArgumentException exception]; - return [[(OFStream *)_lastReturnedStream retain] autorelease]; + return [[_lastReturnedStream retain] autorelease]; } - (OFStream *)streamForWritingEntry: (OFTarArchiveEntry *)entry { void *pool; @@ -234,11 +234,11 @@ initWithStream: _stream entry: entry]; objc_autoreleasePoolPop(pool); - return [[(OFStream *)_lastReturnedStream retain] autorelease]; + return [[_lastReturnedStream retain] autorelease]; } - (void)close { if (_stream == nil) Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -385,11 +385,11 @@ if (_runLoop == nil) _runLoop = [[OFRunLoop alloc] init]; } # endif - return (OFRunLoop *)_runLoop; + return _runLoop; } - (OFString *)name { return [[_name copy] autorelease]; Index: src/OFXMLAttribute.m ================================================================== --- src/OFXMLAttribute.m +++ src/OFXMLAttribute.m @@ -163,11 +163,11 @@ [element addAttributeWithName: @"name" stringValue: _name]; if (_namespace != nil) [element addAttributeWithName: @"namespace" - stringValue: (OFString *)_namespace]; + stringValue: _namespace]; [element addAttributeWithName: @"stringValue" stringValue: _stringValue]; [element retain]; Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -174,11 +174,11 @@ initWithKeysAndObjects: @"http://www.w3.org/XML/1998/namespace", @"xml", @"http://www.w3.org/2000/xmlns/", @"xmlns", nil]; if (stringValue != nil) - [self setStringValue: (OFString *)stringValue]; + [self setStringValue: stringValue]; } @catch (id e) { [self release]; @throw e; } @@ -436,11 +436,11 @@ pool = objc_autoreleasePoolPush(); parentPrefix = [allNamespaces objectForKey: (parent != nil && parent->_namespace != nil - ? (OFString *)parent->_namespace : (OFString *)@"")]; + ? parent->_namespace : (OFString *)@"")]; /* Add the namespaces of the current element */ if (allNamespaces != nil) { OFEnumerator *keyEnumerator = [_namespaces keyEnumerator]; OFEnumerator *objectEnumerator = [_namespaces objectEnumerator]; @@ -457,11 +457,11 @@ allNamespaces = tmp; } else allNamespaces = _namespaces; prefix = [allNamespaces objectForKey: - (_namespace != nil ? (OFString *)_namespace : (OFString *)@"")]; + (_namespace != nil ? _namespace : (OFString *)@"")]; if (parent != nil && parent->_namespace != nil && parentPrefix == nil) defaultNS = parent->_namespace; else if (parent != nil && parent->_defaultNamespace != nil) defaultNS = parent->_defaultNamespace; @@ -525,14 +525,13 @@ OFString *attributePrefix = nil; OFString *tmp = [[attribute stringValue] stringByXMLEscaping]; if ([attribute namespace] != nil && (attributePrefix = [allNamespaces objectForKey: - (OFString *)[attribute namespace]]) == nil) + [attribute namespace]]) == nil) @throw [OFUnboundNamespaceException - exceptionWithNamespace: (OFString *) - [attribute namespace] + exceptionWithNamespace: [attribute namespace] element: self]; length += [attributeName UTF8StringLength] + (attributePrefix != nil ? [attributePrefix UTF8StringLength] + 1 : 0) + @@ -702,24 +701,24 @@ [element addAttributeWithName: @"name" stringValue: _name]; if (_namespace != nil) [element addAttributeWithName: @"namespace" - stringValue: (OFString *)_namespace]; + stringValue: _namespace]; if (_defaultNamespace != nil) [element addAttributeWithName: @"defaultNamespace" - stringValue: (OFString *)_defaultNamespace]; + stringValue: _defaultNamespace]; if (_attributes != nil) { OFXMLElement *attributesElement; attributesElement = [OFXMLElement elementWithName: @"attributes" namespace: OF_SERIALIZATION_NS]; [attributesElement addChild: - [(OFArray *)_attributes XMLElementBySerializing]]; + [_attributes XMLElementBySerializing]]; [element addChild: attributesElement]; } if (_namespaces != nil) { OFXMLElement *namespacesElement; @@ -745,12 +744,11 @@ OFXMLElement *childrenElement; childrenElement = [OFXMLElement elementWithName: @"children" namespace: OF_SERIALIZATION_NS]; - [childrenElement addChild: - [(OFArray *)_children XMLElementBySerializing]]; + [childrenElement addChild: [_children XMLElementBySerializing]]; [element addChild: childrenElement]; } [element retain]; Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -115,12 +115,11 @@ @throw [OFMalformedXMLException exception]; return; case 1: [_delegate elementBuilder: self - didBuildElement: (OFXMLElement *) - [_stack firstObject]]; + didBuildElement: [_stack firstObject]]; break; } [_stack removeLastObject]; } Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -545,26 +545,26 @@ namespace = namespaceForPrefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) @throw [OFUnboundPrefixException - exceptionWithPrefix: (OFString *)_prefix + exceptionWithPrefix: _prefix parser: self]; if ([_delegate respondsToSelector: @selector(parser: didStartElement:prefix:namespace:attributes:)]) [_delegate parser: self - didStartElement: (OFString *)_name + didStartElement: _name prefix: _prefix namespace: namespace attributes: nil]; if (_data[_i] == '/') { if ([_delegate respondsToSelector: @selector(parser:didEndElement:prefix:namespace:)]) [_delegate parser: self - didEndElement: (OFString *)_name + didEndElement: _name prefix: _prefix namespace: namespace]; if ([_previous count] == 0) _finishedParsing = true; @@ -632,18 +632,17 @@ [_buffer removeAllItems]; namespace = namespaceForPrefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) - @throw [OFUnboundPrefixException - exceptionWithPrefix: (OFString *)_prefix - parser: self]; + @throw [OFUnboundPrefixException exceptionWithPrefix: _prefix + parser: self]; if ([_delegate respondsToSelector: @selector(parser:didEndElement:prefix:namespace:)]) [_delegate parser: self - didEndElement: (OFString *)_name + didEndElement: _name prefix: _prefix namespace: namespace]; objc_autoreleasePoolPop(pool); @@ -684,13 +683,12 @@ attributesCount = [_attributes count]; namespace = namespaceForPrefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) - @throw [OFUnboundPrefixException - exceptionWithPrefix: (OFString *)_prefix - parser: self]; + @throw [OFUnboundPrefixException exceptionWithPrefix: _prefix + parser: self]; for (size_t j = 0; j < attributesCount; j++) resolveAttributeNamespace(attributesObjects[j], _namespaces, self); @@ -697,20 +695,20 @@ pool = objc_autoreleasePoolPush(); if ([_delegate respondsToSelector: @selector(parser:didStartElement:prefix:namespace:attributes:)]) [_delegate parser: self - didStartElement: (OFString *)_name + didStartElement: _name prefix: _prefix namespace: namespace attributes: _attributes]; if (_data[_i] == '/') { if ([_delegate respondsToSelector: @selector(parser:didEndElement:prefix:namespace:)]) [_delegate parser: self - didEndElement: (OFString *)_name + didEndElement: _name prefix: _prefix namespace: namespace]; if ([_previous count] == 0) _finishedParsing = true; @@ -719,11 +717,11 @@ } else if (_prefix != nil) { OFString *str = [OFString stringWithFormat: @"%@:%@", _prefix, _name]; [_previous addObject: str]; } else - [_previous addObject: (OFString *)_name]; + [_previous addObject: _name]; objc_autoreleasePoolPop(pool); [_name release]; [_prefix release]; @@ -830,16 +828,15 @@ if (_attributePrefix == nil && [_attributeName isEqual: @"xmlns"]) [[_namespaces lastObject] setObject: attributeValue forKey: @""]; if ([_attributePrefix isEqual: @"xmlns"]) - [[_namespaces lastObject] - setObject: attributeValue - forKey: (OFString *)_attributeName]; + [[_namespaces lastObject] setObject: attributeValue + forKey: _attributeName]; [_attributes addObject: - [OFXMLAttribute attributeWithName: (OFString *)_attributeName + [OFXMLAttribute attributeWithName: _attributeName namespace: _attributePrefix stringValue: attributeValue]]; objc_autoreleasePoolPop(pool); Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -465,11 +465,11 @@ initWithStream: _stream entry: entry]; objc_autoreleasePoolPop(pool); - return [[(OFStream *)_lastReturnedStream retain] autorelease]; + return [[_lastReturnedStream retain] autorelease]; } - (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry_ { /* TODO: Avoid data descriptor when _stream is an OFSeekableStream */ @@ -556,11 +556,11 @@ initWithStream: _stream entry: entry]; objc_autoreleasePoolPop(pool); - return [[(OFStream *)_lastReturnedStream retain] autorelease]; + return [[_lastReturnedStream retain] autorelease]; } - (void)of_writeCentralDirectory { void *pool = objc_autoreleasePoolPush(); @@ -603,11 +603,11 @@ [_stream writeLittleEndianInt16: 0xFFFF]; /* CD entries */ [_stream writeLittleEndianInt32: 0xFFFFFFFF]; /* CD size */ [_stream writeLittleEndianInt32: 0xFFFFFFFF]; /* CD offset */ [_stream writeLittleEndianInt16: [_archiveComment UTF8StringLength]]; if (_archiveComment != nil) - [_stream writeString: (OFString *)_archiveComment]; + [_stream writeString: _archiveComment]; objc_autoreleasePoolPop(pool); } - (void)close Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -463,15 +463,15 @@ [stream writeLittleEndianInt64: _localFileHeaderOffset]; [stream writeLittleEndianInt32: _startDiskNumber]; size += (2 * 2) + (3 * 8) + 4; if (_extraField != nil) - [stream writeData: (OFData *)_extraField]; + [stream writeData: _extraField]; size += (uint64_t)[_extraField count]; if (_fileComment != nil) - [stream writeString: (OFString *)_fileComment]; + [stream writeString: _fileComment]; size += (uint64_t)[_fileComment UTF8StringLength]; objc_autoreleasePoolPop(pool); return size; Index: src/bridge/NSString+OFObject.m ================================================================== --- src/bridge/NSString+OFObject.m +++ src/bridge/NSString+OFObject.m @@ -18,8 +18,8 @@ #import "OFString.h" @implementation NSString (OFObject) - (id)OFObject { - return [OFString stringWithUTF8String: (const char *)[self UTF8String]]; + return [OFString stringWithUTF8String: [self UTF8String]]; } @end Index: src/instance.m ================================================================== --- src/instance.m +++ src/instance.m @@ -55,11 +55,11 @@ id obj = (id)bytes; if (cls == Nil || bytes == NULL) return nil; - object_setClass(obj, (Class)cls); + object_setClass(obj, cls); if (!callConstructors(cls, obj)) return nil; return obj; Index: src/runtime/class.m ================================================================== --- src/runtime/class.m +++ src/runtime/class.m @@ -867,11 +867,11 @@ void objc_unregister_class(Class cls) { while (cls->subclass_list != NULL && cls->subclass_list[0] != Nil) - objc_unregister_class((Class)cls->subclass_list[0]); + objc_unregister_class(cls->subclass_list[0]); if (cls->info & OBJC_CLASS_INFO_LOADED) call_method(cls, "unload"); objc_hashtable_delete(classes, cls->name); Index: src/runtime/protocol.m ================================================================== --- src/runtime/protocol.m +++ src/runtime/protocol.m @@ -65,11 +65,11 @@ if (protocol_conformsToProtocol(pl->list[i], p)) return true; objc_global_mutex_lock(); - if ((cats = objc_categories_for_class((Class)cls)) == NULL) { + if ((cats = objc_categories_for_class(cls)) == NULL) { objc_global_mutex_unlock(); return false; } for (long i = 0; cats[i] != NULL; i++) { Index: src/runtime/selector.m ================================================================== --- src/runtime/selector.m +++ src/runtime/selector.m @@ -70,11 +70,10 @@ SEL sel_registerName(const char *name) { const struct objc_abi_selector *rsel; struct objc_abi_selector *sel; - char *name_copy; objc_global_mutex_lock(); if (selectors != NULL && (rsel = objc_hashtable_get(selectors, name)) != NULL) { @@ -83,14 +82,13 @@ } if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); - if ((name_copy = of_strdup(name)) == NULL) + if ((sel->name = of_strdup(name)) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); - sel->name = name_copy; sel->types = NULL; if ((free_list = realloc(free_list, sizeof(void *) * (free_list_cnt + 2))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); Index: tests/ForwardingTests.m ================================================================== --- tests/ForwardingTests.m +++ tests/ForwardingTests.m @@ -71,12 +71,12 @@ + (BOOL)resolveClassMethod: (SEL)selector { forwardings++; if (sel_isEqual(selector, @selector(test))) { - class_replaceMethod((Class)object_getClass(self), - @selector(test), (IMP)test, "v#:"); + class_replaceMethod(object_getClass(self), @selector(test), + (IMP)test, "v#:"); return YES; } return NO; } Index: tests/OFDictionaryTests.m ================================================================== --- tests/OFDictionaryTests.m +++ tests/OFDictionaryTests.m @@ -236,11 +236,11 @@ if (i > 1 || ![key isEqual: keys[i]]) { ok = false; break; } - [mutDict setObject: (OFString *)[mutDict objectForKey: key] + [mutDict setObject: [mutDict objectForKey: key] forKey: key]; i++; } TEST(@"Fast Enumeration", ok) @@ -277,13 +277,12 @@ ok = false; *stop = true; return; } - [mutDict - setObject: (OFString *)[mutDict objectForKey: key] - forKey: key]; + [mutDict setObject: [mutDict objectForKey: key] + forKey: key]; i++; }]; TEST(@"Enumeration using blocks", ok) Index: tests/OFInvocationTests.m ================================================================== --- tests/OFInvocationTests.m +++ tests/OFInvocationTests.m @@ -253,12 +253,11 @@ - (void)invocationTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; SEL selector = @selector(invocationTestMethod1::::); - OFMethodSignature *sig = - (OFMethodSignature *)[self methodSignatureForSelector: selector]; + OFMethodSignature *sig = [self methodSignatureForSelector: selector]; OFInvocation *invocation; struct test_struct st, st2, *stp = &st, *stp2; unsigned const char c = 0xAA; unsigned char c2; const unsigned int i = 0x55555555; @@ -312,11 +311,11 @@ #ifdef OF_INVOCATION_CAN_INVOKE /* -[invoke] #1 */ selector = @selector(invocationTestMethod2::::::::::::::::); invocation = [OFInvocation invocationWithMethodSignature: - (OFMethodSignature *)[self methodSignatureForSelector: selector]]; + [self methodSignatureForSelector: selector]]; [invocation setArgument: &self atIndex: 0]; [invocation setArgument: &selector atIndex: 1]; @@ -330,11 +329,11 @@ R([invocation getReturnValue: &intResult]) && intResult == 8) /* -[invoke] #2 */ selector = @selector(invocationTestMethod3::::::::::::::::); invocation = [OFInvocation invocationWithMethodSignature: - (OFMethodSignature *)[self methodSignatureForSelector: selector]]; + [self methodSignatureForSelector: selector]]; [invocation setArgument: &self atIndex: 0]; [invocation setArgument: &selector atIndex: 1]; @@ -351,11 +350,11 @@ doubleResult == 8.5) /* -[invoke] #3 */ selector = @selector(invocationTestMethod4::::::::::::::::); invocation = [OFInvocation invocationWithMethodSignature: - (OFMethodSignature *)[self methodSignatureForSelector: selector]]; + [self methodSignatureForSelector: selector]]; [invocation setArgument: &self atIndex: 0]; [invocation setArgument: &selector atIndex: 1]; @@ -379,11 +378,10 @@ /* Only when encoding long doubles is supported */ if (strcmp(@encode(double), @encode(long double)) != 0) { /* -[invoke] #4 */ selector = @selector(invocationTestMethod5::::::::::::::::); invocation = [OFInvocation invocationWithMethodSignature: - (OFMethodSignature *) [self methodSignatureForSelector: selector]]; [invocation setArgument: &self atIndex: 0]; [invocation setArgument: &selector @@ -403,11 +401,11 @@ # ifndef __STDC_NO_COMPLEX__ /* -[invoke] #5 */ selector = @selector(invocationTestMethod6::::::::::::::::); invocation = [OFInvocation invocationWithMethodSignature: - (OFMethodSignature *)[self methodSignatureForSelector: selector]]; + [self methodSignatureForSelector: selector]]; [invocation setArgument: &self atIndex: 0]; [invocation setArgument: &selector atIndex: 1]; @@ -433,11 +431,10 @@ if (strcmp(@encode(complex double), @encode(complex long double)) != 0) { /* -[invoke] #6 */ selector = @selector(invocationTestMethod7::::::::::::::::); invocation = [OFInvocation invocationWithMethodSignature: - (OFMethodSignature *) [self methodSignatureForSelector: selector]]; [invocation setArgument: &self atIndex: 0]; [invocation setArgument: &selector @@ -473,11 +470,11 @@ # ifdef __SIZEOF_INT128__ /* -[invoke] #7 */ selector = @selector(invocationTestMethod8::::::::::::::::); invocation = [OFInvocation invocationWithMethodSignature: - (OFMethodSignature *)[self methodSignatureForSelector: selector]]; + [self methodSignatureForSelector: selector]]; [invocation setArgument: &self atIndex: 0]; [invocation setArgument: &selector atIndex: 1]; Index: tests/OFListTests.m ================================================================== --- tests/OFListTests.m +++ tests/OFListTests.m @@ -58,27 +58,24 @@ TEST(@"-[lastListObject]->previous", [[list lastListObject]->previous->object isEqual: strings[1]]) TEST(@"-[removeListObject:]", - R([list removeListObject: - (of_list_object_t *)[list lastListObject]]) && + R([list removeListObject: [list lastListObject]]) && [[list lastListObject]->object isEqual: strings[1]] && - R([list removeListObject: - (of_list_object_t *)[list firstListObject]]) && + R([list removeListObject: [list firstListObject]]) && [[list firstListObject]->object isEqual: [list lastListObject]->object]) TEST(@"-[insertObject:beforeListObject:]", [list insertObject: strings[0] - beforeListObject: (of_list_object_t *)[list lastListObject]] && + beforeListObject: [list lastListObject]] && [[list lastListObject]->previous->object isEqual: strings[0]]) TEST(@"-[insertObject:afterListObject:]", [list insertObject: strings[2] - afterListObject: (of_list_object_t *) - [list firstListObject]->next] && + afterListObject: [list firstListObject]->next] && [[list lastListObject]->object isEqual: strings[2]]) TEST(@"-[count]", [list count] == 3) TEST(@"-[containsObject:]", @@ -117,11 +114,11 @@ ok = false; TEST(@"OFEnumerator's -[nextObject]", ok); [enumerator reset]; - [list removeListObject: (of_list_object_t *)[list firstListObject]]; + [list removeListObject: [list firstListObject]]; EXPECT_EXCEPTION(@"Detection of mutation during enumeration", OFEnumerationMutationException, [enumerator nextObject]) [list prependObject: strings[0]]; @@ -146,12 +143,11 @@ ok = false; @try { for (OFString *obj in list) { (void)obj; - [list removeListObject: - (of_list_object_t *)[list lastListObject]]; + [list removeListObject: [list lastListObject]]; } } @catch (OFEnumerationMutationException *e) { ok = true; }