From 3486a008a1fd1348d0f2fe748a5e23933d94647a Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 17:48:42 +1100 Subject: [PATCH 01/12] Fixing warnings: implicit conversion changes signedness: 'NSInteger' (aka 'long') to 'unsigned long' [-Werror,-Wsign-conversion] --- AFNetworking/AFHTTPClient.m | 16 ++++++++-------- AFNetworking/AFURLConnectionOperation.m | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 98c574e..997b22e 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -653,7 +653,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {} return nil; } - self.stringEncoding = [aDecoder decodeIntegerForKey:@"stringEncoding"]; + self.stringEncoding = (NSStringEncoding)[aDecoder decodeIntegerForKey:@"stringEncoding"]; self.parameterEncoding = [aDecoder decodeIntegerForKey:@"parameterEncoding"]; self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"]; self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"]; @@ -663,7 +663,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {} - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.baseURL forKey:@"baseURL"]; - [aCoder encodeInteger:self.stringEncoding forKey:@"stringEncoding"]; + [aCoder encodeInteger:(NSInteger)self.stringEncoding forKey:@"stringEncoding"]; [aCoder encodeInteger:self.parameterEncoding forKey:@"parameterEncoding"]; [aCoder encodeObject:self.registeredHTTPOperationClassNames forKey:@"registeredHTTPOperationClassNames"]; [aCoder encodeObject:self.defaultHeaders forKey:@"defaultHeaders"]; @@ -945,7 +945,7 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; break; } } else { - bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:length - bytesRead]; + bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; if (self.delay > 0.0f) { [NSThread sleepForTimeInterval:self.delay]; } @@ -1113,17 +1113,17 @@ typedef enum { if (_phase == AFEncapsulationBoundaryPhase) { NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding]; - bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } if (_phase == AFHeaderPhase) { NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; - bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } if (_phase == AFBodyPhase) { if ([self.inputStream hasBytesAvailable]) { - bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } if (![self.inputStream hasBytesAvailable]) { @@ -1133,7 +1133,7 @@ typedef enum { if (_phase == AFFinalBoundaryPhase) { NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]); - bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } return bytesRead; @@ -1152,7 +1152,7 @@ typedef enum { [self transitionToNextPhase]; } - return range.length; + return (NSInteger)range.length; } - (BOOL)transitionToNextPhase { diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 74d0c0b..0d5eb14 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -526,7 +526,7 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite { if (self.uploadProgress) { dispatch_async(dispatch_get_main_queue(), ^{ - self.uploadProgress(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); }); } } From debd44290384238c83dd3ececd6093bf195697a5 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:03:34 +1100 Subject: [PATCH 02/12] Fixes warning: unused parameter 'x' [-Werror,-Wunused-parameter] --- AFNetworking/AFHTTPClient.m | 36 +++++++++++++-------------- AFNetworking/AFHTTPRequestOperation.m | 10 ++++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 997b22e..9a54f48 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -146,11 +146,11 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; if([value isKindOfClass:[NSDictionary class]]) { - [value enumerateKeysAndObjectsUsingBlock:^(id nestedKey, id nestedValue, BOOL *stop) { + [value enumerateKeysAndObjectsUsingBlock:^(id nestedKey, id nestedValue, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; }]; } else if([value isKindOfClass:[NSArray class]]) { - [value enumerateObjectsUsingBlock:^(id nestedValue, NSUInteger idx, BOOL *stop) { + [value enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; } else { @@ -302,7 +302,7 @@ static const void * AFNetworkReachabilityRetainCallback(const void *info) { return (__bridge_retained const void *)([(__bridge AFNetworkReachabilityStatusBlock)info copy]); } -static void AFNetworkReachabilityReleaseCallback(const void *info) {} +static void AFNetworkReachabilityReleaseCallback(__unused const void *info) {} - (void)startMonitoringNetworkReachability { [self stopMonitoringNetworkReachability]; @@ -569,7 +569,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {} } __block NSUInteger numberOfFinishedOperations = 0; - [operations enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [operations enumerateObjectsUsingBlock:^(id obj, __unused NSUInteger idx, __unused BOOL *stop) { if ([(NSOperation *)obj isFinished]) { numberOfFinishedOperations++; } @@ -955,7 +955,7 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; return bytesRead; } -- (BOOL)getBuffer:(uint8_t **)buffer length:(NSUInteger *)len { +- (BOOL)getBuffer:(__unused uint8_t **)buffer length:(__unused NSUInteger *)len { return NO; } @@ -980,20 +980,20 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; self.streamStatus = NSStreamStatusClosed; } -- (id)propertyForKey:(NSString *)key { +- (id)propertyForKey:(__unused NSString *)key { return nil; } -- (BOOL)setProperty:(id)property forKey:(NSString *)key { +- (BOOL)setProperty:(__unused id)property forKey:(__unused NSString *)key { return NO; } -- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop - forMode:(NSString *)mode +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode {} -- (void)removeFromRunLoop:(NSRunLoop *)aRunLoop - forMode:(NSString *)mode +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode {} - (unsigned long long)contentLength { @@ -1007,17 +1007,17 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; #pragma mark - Undocumented CFReadStream Bridged Methods -- (void)_scheduleInCFRunLoop:(CFRunLoopRef)aRunLoop - forMode:(CFStringRef)aMode +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode {} -- (void)_unscheduleFromCFRunLoop:(CFRunLoopRef)aRunLoop - forMode:(CFStringRef)aMode +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode {} -- (BOOL)_setCFClientFlags:(CFOptionFlags)inFlags - callback:(CFReadStreamClientCallBack)inCallback - context:(CFStreamClientContext *)inContext { +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { return NO; } diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 3e31962..2256d40 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -38,7 +38,7 @@ NSSet * AFContentTypesFromHTTPHeader(NSString *string) { NSArray *mediaRanges = [string componentsSeparatedByString:@","]; NSMutableSet *mutableContentTypes = [NSMutableSet setWithCapacity:mediaRanges.count]; - [mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, NSUInteger idx, BOOL *stop) { + [mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, __unused NSUInteger idx, __unused BOOL *stop) { NSRange parametersRange = [mediaRange rangeOfString:@";"]; if (parametersRange.location != NSNotFound) { mediaRange = [mediaRange substringToIndex:parametersRange.location]; @@ -271,7 +271,7 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes { NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]]; [mutableStatusCodes addIndexes:statusCodes]; - AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(id _self) { + AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(__unused id _self) { return mutableStatusCodes; }); } @@ -283,7 +283,7 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL + (void)addAcceptableContentTypes:(NSSet *)contentTypes { NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES]; [mutableContentTypes unionSet:contentTypes]; - AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(id _self) { + AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(__unused id _self) { return mutableContentTypes; }); } @@ -298,8 +298,8 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL #pragma mark - NSURLConnectionDelegate -- (void)connection:(NSURLConnection *)connection -didReceiveResponse:(NSURLResponse *)response +- (void)connection:(__unused NSURLConnection *)connection +didReceiveResponse:(__unused NSURLResponse *)response { self.response = (NSHTTPURLResponse *)response; From f9449753ffe1f5301e1670271a8b575209af2165 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:06:05 +1100 Subject: [PATCH 03/12] Fixes warning: property is assumed atomic by default [-Werror,-Wimplicit-atomic-properties] --- AFNetworking/AFHTTPRequestOperation.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 2256d40..c67fe14 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -96,8 +96,8 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL @property (readwrite, nonatomic, strong) NSURLRequest *request; @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; @property (readwrite, nonatomic, strong) NSError *HTTPError; -@property (assign) long long totalContentLength; -@property (assign) long long offsetContentLength; +@property (atomic, assign) long long totalContentLength; +@property (atomic, assign) long long offsetContentLength; @end @implementation AFHTTPRequestOperation From 23b8fe33ba10eaed6f4d9bced62deea0b208fa1b Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:30:28 +1100 Subject: [PATCH 04/12] Fixes warning: weak receiver may be unpredictably null in ARC mode [-Werror,-Wreceiver-is-weak] --- AFNetworking/AFURLConnectionOperation.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0d5eb14..44bc11d 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -215,8 +215,10 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat } else { __weak __typeof(&*self)weakSelf = self; [super setCompletionBlock:^ { + __typeof(&*weakSelf) operation = weakSelf; + block(); - [weakSelf setCompletionBlock:nil]; + [operation setCompletionBlock:nil]; }]; } [self.lock unlock]; From 3997dbb7e9d942edff59ff66d484b6b74556a868 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:46:04 +1100 Subject: [PATCH 05/12] Fixes warning: multiple methods named 'selector' found [-Werror,-Wstrict-selector-match] --- AFNetworking/AFHTTPClient.m | 6 ++++-- AFNetworking/AFHTTPRequestOperation.m | 4 ++++ AFNetworking/AFURLConnectionOperation.m | 10 +++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 9a54f48..b366be2 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -150,7 +150,8 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; }]; } else if([value isKindOfClass:[NSArray class]]) { - [value enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { + NSArray *array = value; + [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; } else { @@ -295,7 +296,8 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ block(status); } - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; } static const void * AFNetworkReachabilityRetainCallback(const void *info) { diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index c67fe14..2525cbf 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -30,6 +30,10 @@ #define AF_CAST_TO_BLOCK __bridge void * #endif +// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wstrict-selector-match" + NSSet * AFContentTypesFromHTTPHeader(NSString *string) { if (!string) { return nil; diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 44bc11d..7c756cf 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -310,12 +310,14 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + switch (state) { case AFOperationExecutingState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidStartNotification object:self]; break; case AFOperationFinishedState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; break; default: break; @@ -351,7 +353,9 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; } self.state = AFOperationPausedState; From f4d25341cf31522750b32b0a2c33eeb9dff6ae9b Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 19:08:41 +1100 Subject: [PATCH 06/12] Fixing tabs/spaces whitespace inconsistency. --- AFNetworking/AFHTTPClient.m | 4 ++-- AFNetworking/AFURLConnectionOperation.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index b366be2..e8898d1 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -150,7 +150,7 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; }]; } else if([value isKindOfClass:[NSArray class]]) { - NSArray *array = value; + NSArray *array = value; [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; @@ -296,7 +296,7 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ block(status); } - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; } diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 7c756cf..1f90136 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -310,7 +310,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; switch (state) { case AFOperationExecutingState: @@ -354,7 +354,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; } From d8b4dcb349e34994c37da3f4520a1120107bc471 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 17:47:14 +1100 Subject: [PATCH 07/12] Fixes warning: 'macro' is not defined, evaluates to 0 --- AFNetworking/AFImageRequestOperation.h | 18 +++++++++--------- .../AFNetworkActivityIndicatorManager.h | 2 +- .../AFNetworkActivityIndicatorManager.m | 2 +- AFNetworking/AFURLConnectionOperation.h | 2 +- AFNetworking/AFURLConnectionOperation.m | 8 ++++---- AFNetworking/UIImageView+AFNetworking.m | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/AFNetworking/AFImageRequestOperation.h b/AFNetworking/AFImageRequestOperation.h index d028a84..b906783 100644 --- a/AFNetworking/AFImageRequestOperation.h +++ b/AFNetworking/AFImageRequestOperation.h @@ -25,9 +25,9 @@ #import -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) #import #endif @@ -54,13 +54,13 @@ /** An image constructed from the response data. If an error occurs during the request, `nil` will be returned, and the `error` property will be set to the error. */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) @property (readonly, nonatomic, strong) UIImage *responseImage; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) @property (readonly, nonatomic, strong) NSImage *responseImage; #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) /** The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. */ @@ -75,10 +75,10 @@ @return A new image request operation */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(UIImage *image))success; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSImage *image))success; #endif @@ -93,12 +93,12 @@ @return A new image request operation */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elifdef __MAC_OS_X_VERSION_MIN_REQUIRED + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.h b/AFNetworking/AFNetworkActivityIndicatorManager.h index 2b4d54c..7b6cbe7 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.h +++ b/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -24,7 +24,7 @@ #import -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import /** diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.m b/AFNetworking/AFNetworkActivityIndicatorManager.m index a67cfec..afb6f00 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/AFNetworking/AFNetworkActivityIndicatorManager.m @@ -24,7 +24,7 @@ #import "AFHTTPRequestOperation.h" -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; @interface AFNetworkActivityIndicatorManager () diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 3a391b0..a6be720 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -184,7 +184,7 @@ @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler; #endif diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 1f90136..25432a9 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -21,7 +21,7 @@ // THE SOFTWARE. #import "AFURLConnectionOperation.h" -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import #endif @@ -39,7 +39,7 @@ typedef enum { typedef signed short AFOperationState; -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier; #else typedef id AFBackgroundTaskIdentifier; @@ -196,7 +196,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat _outputStream = nil; } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) if (_backgroundTaskIdentifier) { [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; _backgroundTaskIdentifier = UIBackgroundTaskInvalid; @@ -249,7 +249,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat [self didChangeValueForKey:@"outputStream"]; } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { [self.lock lock]; if (!self.backgroundTaskIdentifier) { diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 1294d61..f399c0e 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -23,7 +23,7 @@ #import #import -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import "UIImageView+AFNetworking.h" @interface AFImageCache : NSCache From 72ab802a2dbdbcad85749d0b832b29c7bc23015d Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:02:15 +1100 Subject: [PATCH 08/12] Fixes warning: atomic by default property 'X' has a user defined getter (property should be marked 'atomic' if this is intended) [-Werror,-Wcustom-atomic-properties] --- AFNetworking/AFHTTPRequestOperation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.h b/AFNetworking/AFHTTPRequestOperation.h index b7207f1..d6776b3 100644 --- a/AFNetworking/AFHTTPRequestOperation.h +++ b/AFNetworking/AFHTTPRequestOperation.h @@ -44,12 +44,12 @@ /** A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`. */ -@property (readonly) BOOL hasAcceptableStatusCode; +@property (nonatomic, readonly) BOOL hasAcceptableStatusCode; /** A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`. */ -@property (readonly) BOOL hasAcceptableContentType; +@property (nonatomic, readonly) BOOL hasAcceptableContentType; /** The callback dispatch queue on success. If `NULL` (default), the main queue is used. From 692f7126ca8baa4e564b153073d5907903839a4b Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:04:44 +1100 Subject: [PATCH 09/12] Fixes warning: 'response' was marked unused but was used [-Werror,-Wused-but-marked-unused] --- AFNetworking/AFHTTPRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 2525cbf..0e5f076 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -303,7 +303,7 @@ static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL #pragma mark - NSURLConnectionDelegate - (void)connection:(__unused NSURLConnection *)connection -didReceiveResponse:(__unused NSURLResponse *)response +didReceiveResponse:(NSURLResponse *)response { self.response = (NSHTTPURLResponse *)response; From b75c673a2c28233884a0d88fe85311173727c244 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:12:47 +1100 Subject: [PATCH 10/12] Fixes warning: 'X' is not defined, evaluates to 0 [-Werror,-Wundef] --- AFNetworking/AFHTTPClient.m | 6 +++--- AFNetworking/AFImageRequestOperation.m | 24 ++++++++++++------------ AFNetworking/AFNetworking.h | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e8898d1..c55ce85 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -35,7 +35,7 @@ #import #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import #endif @@ -230,10 +230,10 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "]; [self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]]; -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]]; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]]; #endif diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index f4f724a..cf24f31 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -32,20 +32,20 @@ static dispatch_queue_t image_request_operation_processing_queue() { } @interface AFImageRequestOperation () -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) @property (readwrite, nonatomic, strong) UIImage *responseImage; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) @property (readwrite, nonatomic, strong) NSImage *responseImage; #endif @end @implementation AFImageRequestOperation @synthesize responseImage = _responseImage; -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) @synthesize imageScale = _imageScale; #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(UIImage *image))success { @@ -55,7 +55,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { } } failure:nil]; } -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSImage *image))success { @@ -68,7 +68,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success @@ -99,7 +99,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { return requestOperation; } -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success @@ -137,7 +137,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { return nil; } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) self.imageScale = [[UIScreen mainScreen] scale]; #endif @@ -145,7 +145,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (UIImage *)responseImage { if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { UIImage *image = [UIImage imageWithData:self.responseData]; @@ -168,7 +168,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { self.responseImage = nil; } -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) - (NSImage *)responseImage { if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { // Ensure that the image is set to it's correct pixel width and height @@ -216,9 +216,9 @@ static dispatch_queue_t image_request_operation_processing_queue() { } } else { if (success) { -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) UIImage *image = nil; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) NSImage *image = nil; #endif diff --git a/AFNetworking/AFNetworking.h b/AFNetworking/AFNetworking.h index 49e596c..c0e8e62 100644 --- a/AFNetworking/AFNetworking.h +++ b/AFNetworking/AFNetworking.h @@ -36,7 +36,7 @@ #import "AFImageRequestOperation.h" -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import "AFNetworkActivityIndicatorManager.h" #import "UIImageView+AFNetworking.h" #endif From b64c6bd846ab0e216c9495f4efdd9f7860906915 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:13:43 +1100 Subject: [PATCH 11/12] Fixes warning: atomic by default property 'X' has a user defined getter (property should be marked 'atomic' if this is intended) [-Werror,-Wcustom-atomic-properties] --- AFNetworking/AFHTTPClient.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index c55ce85..28ee57e 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -729,8 +729,8 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; @property (nonatomic, assign) BOOL hasInitialBoundary; @property (nonatomic, assign) BOOL hasFinalBoundary; -@property (readonly, getter = hasBytesAvailable) BOOL bytesAvailable; -@property (readonly) unsigned long long contentLength; +@property (nonatomic, readonly, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (nonatomic, readonly) unsigned long long contentLength; - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length; @end @@ -738,8 +738,8 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; @interface AFMultipartBodyStream : NSInputStream @property (nonatomic, assign) NSUInteger numberOfBytesInPacket; @property (nonatomic, assign) NSTimeInterval delay; -@property (readonly) unsigned long long contentLength; -@property (readonly, getter = isEmpty) BOOL empty; +@property (nonatomic, readonly) unsigned long long contentLength; +@property (nonatomic, readonly, getter = isEmpty) BOOL empty; - (id)initWithStringEncoding:(NSStringEncoding)encoding; - (void)setInitialAndFinalBoundaries; From d38895e5d83bda19e874a5b6618d8a0e0eff8d9c Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:14:26 +1100 Subject: [PATCH 12/12] Fixes warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled in switch [-Werror,-Wswitch-enum] --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 28ee57e..2548253 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1176,7 +1176,7 @@ typedef enum { [self.inputStream close]; _phase = AFFinalBoundaryPhase; break; - default: + case AFFinalBoundaryPhase: _phase = AFEncapsulationBoundaryPhase; break; }