Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -16,12 +16,10 @@ #include "config.h" #include #include -#include - #import "OFArray.h" #import "OFArray+Private.h" #import "OFAdjacentArray.h" #import "OFData.h" #import "OFNull.h" @@ -687,11 +685,11 @@ [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } - assert(i == count); + OFAssert(i == count); [data makeImmutable]; objc_autoreleasePoolPop(pool); Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -15,12 +15,10 @@ #include "config.h" #include -#include - #import "OFDictionary.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFData.h" #import "OFEnumerator.h" @@ -824,11 +822,11 @@ [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } - assert(i == count); + OFAssert(i == count); [data makeImmutable]; objc_autoreleasePoolPop(pool); Index: src/OFEpollKernelEventObserver.m ================================================================== --- src/OFEpollKernelEventObserver.m +++ src/OFEpollKernelEventObserver.m @@ -13,11 +13,10 @@ * file. */ #include "config.h" -#include #include #ifdef HAVE_FCNTL_H # include #endif Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -15,11 +15,10 @@ #include "config.h" #define _LARGEFILE64_SOURCE -#include #include #ifdef HAVE_FCNTL_H # include #endif Index: src/OFInflateStream.m ================================================================== --- src/OFInflateStream.m +++ src/OFInflateStream.m @@ -16,12 +16,10 @@ #include "config.h" #include #include -#include - #ifndef OF_INFLATE64_STREAM_M # import "OFInflateStream.h" #else # import "OFInflate64Stream.h" # define OFInflateStream OFInflate64Stream @@ -105,11 +103,11 @@ static OF_INLINE bool tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; - assert(stream->_savedBitsLength < count); + OFAssert(stream->_savedBitsLength < count); for (uint_fast8_t i = stream->_savedBitsLength; i < count; i++) { if OF_UNLIKELY (stream->_bitIndex == 8) { if OF_LIKELY (stream->_bufferIndex < stream->_bufferLength) Index: src/OFKqueueKernelEventObserver.m ================================================================== --- src/OFKqueueKernelEventObserver.m +++ src/OFKqueueKernelEventObserver.m @@ -13,11 +13,10 @@ * file. */ #include "config.h" -#include #include #ifdef HAVE_FCNTL_H # include #endif @@ -186,11 +185,11 @@ errNo: (int)eventList[i].data]; if (eventList[i].ident == (uintptr_t)_cancelFD[0]) { char buffer; - assert(eventList[i].filter == EVFILT_READ); + OFAssert(eventList[i].filter == EVFILT_READ); OFEnsure(read(_cancelFD[0], &buffer, 1) == 1); continue; } @@ -208,12 +207,12 @@ @selector(objectIsReadyForWriting:)]) [_delegate objectIsReadyForWriting: (id)eventList[i].udata]; break; default: - assert(0); + OFAssert(0); } objc_autoreleasePoolPop(pool); } } @end Index: src/OFLHADecompressingStream.m ================================================================== --- src/OFLHADecompressingStream.m +++ src/OFLHADecompressingStream.m @@ -13,12 +13,10 @@ * file. */ #include "config.h" -#include - #import "OFLHADecompressingStream.h" #import "OFKernelEventObserver.h" #import "OFHuffmanTree.h" @@ -48,11 +46,11 @@ static OF_INLINE bool tryReadBits(OFLHADecompressingStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; - assert(stream->_savedBitsLength < count); + OFAssert(stream->_savedBitsLength < count); for (uint_fast8_t i = stream->_savedBitsLength; i < count; i++) { if OF_UNLIKELY (stream->_bitIndex == 8) { if OF_LIKELY (stream->_bufferIndex < stream->_bufferLength) Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -14,11 +14,10 @@ */ #include "config.h" #include -#include #import "OFList.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFArray.h" @@ -254,11 +253,11 @@ iter = iter->next, iter2 = iter2->next) if (![iter->object isEqual: iter2->object]) return false; /* One is bigger than the other even though we checked the count */ - assert(iter == NULL && iter2 == NULL); + OFAssert(iter == NULL && iter2 == NULL); return true; } - (bool)containsObject: (id)object Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -18,12 +18,10 @@ #include "config.h" #include #include -#include - #import "OFMapTable.h" #import "OFMapTable+Private.h" #import "OFEnumerator.h" #import "OFEnumerationMutationException.h" Index: src/OFMapTableDictionary.m ================================================================== --- src/OFMapTableDictionary.m +++ src/OFMapTableDictionary.m @@ -13,12 +13,10 @@ * file. */ #include "config.h" -#include - #import "OFMapTableDictionary.h" #import "OFArray.h" #import "OFMapTable+Private.h" #import "OFMapTable.h" #import "OFMutableMapTableDictionary.h" @@ -344,11 +342,11 @@ size_t i; i = 0; enumerator = [_mapTable keyEnumerator]; while ((keyPtr = [enumerator nextObject]) != NULL) { - assert(i < count); + OFAssert(i < count); keys[i++] = (id)*keyPtr; } objc_autoreleasePoolPop(pool); @@ -377,11 +375,11 @@ size_t i; i = 0; enumerator = [_mapTable objectEnumerator]; while ((objectPtr = [enumerator nextObject]) != NULL) { - assert(i < count); + OFAssert(i < count); objects[i++] = (id)*objectPtr; } objc_autoreleasePoolPop(pool); Index: src/OFMethodSignature.m ================================================================== --- src/OFMethodSignature.m +++ src/OFMethodSignature.m @@ -13,15 +13,15 @@ * file. */ #include "config.h" -#include #include #import "OFMethodSignature.h" #import "OFData.h" +#import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" @@ -34,11 +34,11 @@ static size_t alignmentOfArray(const char **type, size_t *length) { size_t alignment; - assert(*length > 0); + OFAssert(*length > 0); (*type)++; (*length)--; while (*length > 0 && OFASCIIIsDigit(**type)) { @@ -63,11 +63,11 @@ size_t alignment = 0; #if defined(OF_POWERPC) && defined(OF_MACOS) bool first = true; #endif - assert(*length > 0); + OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ @@ -109,11 +109,11 @@ static size_t alignmentOfUnion(const char **type, size_t *length) { size_t alignment = 0; - assert(*length > 0); + OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ @@ -290,11 +290,11 @@ sizeOfArray(const char **type, size_t *length) { size_t count = 0; size_t size; - assert(*length > 0); + OFAssert(*length > 0); (*type)++; (*length)--; while (*length > 0 && OFASCIIIsDigit(**type)) { @@ -330,11 +330,11 @@ size_t alignment = alignmentOfStruct(&typeCopy, &lengthCopy); #if defined(OF_POWERPC) && defined(OF_MACOS) bool first = true; #endif - assert(*length > 0); + OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ @@ -403,11 +403,11 @@ static size_t sizeOfUnion(const char **type, size_t *length) { size_t size = 0; - assert(*length > 0); + OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -16,12 +16,10 @@ #include "config.h" #include #include -#include - #import "OFMutableArray.h" #import "OFMutableAdjacentArray.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" Index: src/OFMutableSet.m ================================================================== --- src/OFMutableSet.m +++ src/OFMutableSet.m @@ -15,14 +15,13 @@ #include "config.h" #include -#include - #import "OFMutableSet.h" #import "OFMutableMapTableSet.h" +#import "OFString.h" static struct { Class isa; } placeholder; @@ -172,11 +171,11 @@ @try { size_t i; i = 0; for (id object in self) { - assert(i < count); + OFAssert(i < count); cArray[i++] = object; } for (i = 0; i < count; i++) if (![set containsObject: cArray[i]]) Index: src/OFMutableUTF8String.m ================================================================== --- src/OFMutableUTF8String.m +++ src/OFMutableUTF8String.m @@ -16,11 +16,10 @@ #include "config.h" #include #include #include -#include #import "OFMutableUTF8String.h" #import "OFASPrintF.h" #import "OFString.h" #import "OFUTF8String.h" @@ -77,11 +76,11 @@ if (!_s->isUTF8) { uint8_t t; const OFUnichar *const *table; - assert(startTableSize >= 1 && middleTableSize >= 1); + OFAssert(startTableSize >= 1 && middleTableSize >= 1); _s->hasHash = false; for (i = 0; i < _s->cStringLength; i++) { if (isStart) @@ -171,11 +170,11 @@ @throw [OFInvalidEncodingException exception]; } j += d; } - assert(j == newCStringLength); + OFAssert(j == newCStringLength); newCString[j] = 0; OFFreeMemory(unicodeString); OFFreeMemory(_s->cString); _s->hasHash = false; Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -18,12 +18,10 @@ #include #include #include #include "unistd_wrapper.h" -#include - #ifdef OF_APPLE_RUNTIME # include #endif #ifdef HAVE_GETRANDOM @@ -1176,11 +1174,11 @@ return self; } - (unsigned int)retainCount { - assert(PRE_IVARS->retainCount >= 0); + OFAssert(PRE_IVARS->retainCount >= 0); return PRE_IVARS->retainCount; } - (void)release { Index: src/OFPollKernelEventObserver.m ================================================================== --- src/OFPollKernelEventObserver.m +++ src/OFPollKernelEventObserver.m @@ -15,11 +15,10 @@ #define __NO_EXT_QNX #include "config.h" -#include #include #ifdef HAVE_POLL_H # include #endif @@ -190,11 +189,11 @@ @throw [OFObserveKernelEventsFailedException exceptionWithObserver: self errNo: errno]; for (size_t i = 0; i < nFDs; i++) { - assert(FDs[i].fd <= _maxFD); + OFAssert(FDs[i].fd <= _maxFD); if (FDs[i].revents & POLLIN) { void *pool2; if (FDs[i].fd == _cancelFD[0]) { Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -13,11 +13,10 @@ * file. */ #include "config.h" -#include #include #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFArray.h" @@ -272,11 +271,11 @@ * handler called -[cancelAsyncRequests]. */ OFList OF_GENERIC(OF_KINDOF(OFRunLoopReadQueueItem *)) *queue = [[_readQueues objectForKey: object] retain]; - assert(queue != nil); + OFAssert(queue != nil); @try { if (![queue.firstObject handleObject: object]) { OFListItem listItem = queue.firstListItem; @@ -316,11 +315,11 @@ * Retain the queue so that it doesn't disappear from us because the * handler called -[cancelAsyncRequests]. */ OFList *queue = [[_writeQueues objectForKey: object] retain]; - assert(queue != nil); + OFAssert(queue != nil); @try { if (![queue.firstObject handleObject: object]) { OFListItem listItem = queue.firstListItem; @@ -1326,11 +1325,11 @@ if (state == nil) return; if ((queue = [state->_writeQueues objectForKey: object]) != nil) { - assert(queue.count > 0); + OFAssert(queue.count > 0); /* * Clear the queue now, in case this has been called from a * handler, as otherwise, we'd do the cleanups below twice. */ @@ -1339,11 +1338,11 @@ [state->_kernelEventObserver removeObjectForWriting: object]; [state->_writeQueues removeObjectForKey: object]; } if ((queue = [state->_readQueues objectForKey: object]) != nil) { - assert(queue.count > 0); + OFAssert(queue.count > 0); /* * Clear the queue now, in case this has been called from a * handler, as otherwise, we'd do the cleanups below twice. */ Index: src/OFSequencedPacketSocket.m ================================================================== --- src/OFSequencedPacketSocket.m +++ src/OFSequencedPacketSocket.m @@ -18,11 +18,10 @@ #ifndef _XOPEN_SOURCE_EXTENDED # define _XOPEN_SOURCE_EXTENDED #endif #define _HPUX_ALT_XOPEN_SOCKET_API -#include #include #ifdef HAVE_FCNTL_H # include #endif @@ -360,11 +359,11 @@ if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif #endif - assert(client->_remoteAddress.length <= + OFAssert(client->_remoteAddress.length <= (socklen_t)sizeof(client->_remoteAddress.sockaddr)); switch (((struct sockaddr *)&client->_remoteAddress.sockaddr) ->sa_family) { case AF_INET: Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -15,11 +15,10 @@ #define __NO_EXT_QNX #include "config.h" -#include #include #include #include #include #include Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -19,11 +19,10 @@ # define _XOPEN_SOURCE_EXTENDED #endif #define __NO_EXT_QNX #define _HPUX_ALT_XOPEN_SOCKET_API -#include #include #include #import "OFStreamSocket.h" #import "OFStreamSocket+Private.h" @@ -281,11 +280,11 @@ if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif #endif - assert(client->_remoteAddress.length <= + OFAssert(client->_remoteAddress.length <= (socklen_t)sizeof(client->_remoteAddress.sockaddr)); switch (((struct sockaddr *)&client->_remoteAddress.sockaddr) ->sa_family) { case AF_INET: Index: src/OFString+JSONParsing.m ================================================================== --- src/OFString+JSONParsing.m +++ src/OFString+JSONParsing.m @@ -18,12 +18,10 @@ #include #include #include -#include - #import "OFString+JSONParsing.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFNumber.h" #import "OFNull.h" @@ -651,14 +649,10 @@ const char *pointer = self.UTF8String; const char *stop = pointer + self.UTF8StringLength; id object; size_t line = 1; -#ifdef __clang_analyzer__ - assert(pointer != NULL); -#endif - object = nextObject(&pointer, stop, &line, depthLimit); skipWhitespacesAndComments(&pointer, stop, &line); if (pointer < stop || object == nil) @throw [OFInvalidJSONException exceptionWithString: self Index: src/OFString+XMLEscaping.m ================================================================== --- src/OFString+XMLEscaping.m +++ src/OFString+XMLEscaping.m @@ -13,11 +13,10 @@ * file. */ #include "config.h" -#include #include #include #import "OFString.h" @@ -86,11 +85,11 @@ memcpy(retCString + j, append, appendLen); j += appendLen; } else retCString[j++] = string[i]; } - assert(j == retLength); + OFAssert(j == retLength); objc_autoreleasePoolPop(pool); @try { ret = [OFString stringWithUTF8String: retCString Index: src/OFTCPSocketSOCKS5Connector.m ================================================================== --- src/OFTCPSocketSOCKS5Connector.m +++ src/OFTCPSocketSOCKS5Connector.m @@ -13,11 +13,10 @@ * file. */ #include "config.h" -#include #include #import "OFTCPSocketSOCKS5Connector.h" #import "OFData.h" #import "OFRunLoop.h" @@ -266,11 +265,11 @@ [_socket asyncReadIntoBuffer: _buffer exactLength: addressLength[0] + 2 runLoopMode: runLoopMode]; return false; default: - assert(0); + OFAssert(0); return false; } } - (OFData *)stream: (OFStream *)sock @@ -303,10 +302,10 @@ [_socket asyncReadIntoBuffer: _buffer exactLength: 4 runLoopMode: runLoopMode]; return nil; default: - assert(0); + OFAssert(0); return nil; } } @end Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -15,12 +15,10 @@ #include "config.h" #include -#include - #import "OFTimer.h" #import "OFTimer+Private.h" #import "OFDate.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" @@ -485,12 +483,12 @@ { /* * The run loop references the timer, so it should never be deallocated * if it is still in a run loop. */ - assert(_inRunLoop == nil); - assert(_inRunLoopMode == nil); + OFAssert(_inRunLoop == nil); + OFAssert(_inRunLoopMode == nil); [_fireDate release]; [_target release]; [_object1 release]; [_object2 release]; Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -18,12 +18,10 @@ #define OF_XML_ELEMENT_M #include #include -#include - #import "OFXMLElement.h" #import "OFArray.h" #import "OFData.h" #import "OFDictionary.h" #import "OFStream.h" @@ -631,11 +629,11 @@ i += _name.UTF8StringLength; } else cString[i++] = '/'; cString[i++] = '>'; - assert(i == length); + OFAssert(i == length); objc_autoreleasePoolPop(pool); ret = [OFString stringWithUTF8String: cString length: length]; Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -374,10 +374,16 @@ @__FILE__ ":%d: " @#cond, __LINE__); \ abort(); \ } \ } while (0) #endif + +#ifndef NDEBUG +# define OFAssert(...) OFEnsure(__VA_ARGS__) +#else +# define OFAssert(...) +#endif #define OF_UNRECOGNIZED_SELECTOR OFMethodNotFound(self, _cmd); #if __has_feature(objc_arc) # define OF_INVALID_INIT_METHOD OFMethodNotFound(self, _cmd); #else Index: src/platform/AmigaOS/OFPlainThread.m ================================================================== --- src/platform/AmigaOS/OFPlainThread.m +++ src/platform/AmigaOS/OFPlainThread.m @@ -13,11 +13,10 @@ * file. */ #include "config.h" -#include #include #import "OFPlainThread.h" #import "OFData.h" #import "OFString.h" @@ -192,11 +191,11 @@ } Wait(1ul << thread->joinSigBit); FreeSignal(thread->joinSigBit); - assert(thread->done); + OFAssert(thread->done); free(thread); return 0; } Index: src/platform/Windows/OFWin32ConsoleStdIOStream.m ================================================================== --- src/platform/Windows/OFWin32ConsoleStdIOStream.m +++ src/platform/Windows/OFWin32ConsoleStdIOStream.m @@ -37,11 +37,10 @@ * writing binary), it checks that the handle is indeed a console. */ #include "config.h" -#include #include #include #import "OFWin32ConsoleStdIOStream.h" #import "OFColor.h" @@ -293,11 +292,11 @@ UTF8Len = OFUTF8StringDecode( _incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c); if (UTF8Len <= 0 || c > 0x10FFFF) { - assert(UTF8Len == 0 || UTF8Len < -4); + OFAssert(UTF8Len == 0 || UTF8Len < -4); UTF16[0] = 0xFFFD; UTF16Len = 1; } else { if (c > 0xFFFF) { Index: tests/OFInvocationTests.m ================================================================== --- tests/OFInvocationTests.m +++ tests/OFInvocationTests.m @@ -13,11 +13,10 @@ * file. */ #include "config.h" -#include #include #if defined(HAVE_COMPLEX_H) && !defined(__STDC_NO_COMPLEX__) # include #endif @@ -57,14 +56,10 @@ st.i = 0xAAAAAAAA; TEST(@"+[invocationWithMethodSignature:]", (invocation = [OFInvocation invocationWithMethodSignature: sig])) -#ifdef __clang_analyzer__ - assert(invocation != nil); -#endif - TEST(@"-[setReturnValue]", R([invocation setReturnValue: &st])) TEST(@"-[getReturnValue]", R([invocation getReturnValue: &st2]) && memcmp(&st, &st2, sizeof(st)) == 0)