Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix warnings when compiling with some -W options. #342

merged 2 commits into from

2 participants


Some people (like me) have a need to enable a few extra warnings that are not enabled by default. Many projects even enforce some of these warnings flags.

These two commits avoid (or fix, if you will) a bunch of warnings caused by both -Wno-implicit-atomic-properties and -Wsign-conversion.

Commit 9ee1ff3 also adds an extra condition (and changes another) to check whether an NSInputStream did fail a read operation.

+       NSInteger bytesRead = [stream read:buffer maxLength:sizeof(buffer)];
        if (bytesRead == 0) {
+           // 0 indicates that the end of the buffer was reached.
+           break;
+       } else if (bytesRead < 0) {
+           // A negative number means that the operation failed.


        NSInteger len = [(NSInputStream *)stream read:buf maxLength:16384];
-       if (len) {
-           [[self PACFileData] appendBytes:(const void *)buf length:len];
+       // Append only if something was actually read.
+       if (len > 0) {
+           [[self PACFileData] appendBytes:(const void *)buf length:(NSUInteger)len];

Commit 4602e69 fixes some deprecated methods in iOS 6.0.


@jogu Do you mind taking a look at these changes? Please, let me know your thoughts. I saw the deprecation warnings were already fixed, but the rest remains. You can fetch these commits and cherry-pick each one separately.

((6 lines not shown))
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
+ [[self parentViewController] dismissViewControllerAnimated:YES completion:nil];
@jogu Collaborator
jogu added a note

I'm not sure if this change (and similar ones) will break old iOS versions? asihttprequest claims compatibility back to iOS 3.0 currently

Thanks for reviewing it. You're right - they will/would break. Someone did the same in 5088999 then fixed the compatibility in 41c7432. So that commit of mine is totally out-of-date and can be ignored.

@jogu Collaborator
jogu added a note

Oh, yes, actually this pull requests has conflicts so won't merge anyway.

Do you think you can rebase it off the current master?

Just did it. Please, let me know if you find any problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jogu jogu merged commit 03bd49b into pokeb:master

@jogu Thanks for merging it. Now I'm wondering if it would make sense to enable CLANG_WARN_IMPLICIT_SIGN_CONVERSION and CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES in both .project files. I think it's the only way to make (not absolutely) sure those warnings don't get re-introduced. Not absolutely only because people can still change implementations and submit PRs without ever opening the project itself.
Any thoughts?


I have no objection to that I guess :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2014
  1. @jweyrich

    Avoid warnings about @property declarations that are implicitly atomic

    jweyrich authored
  2. @jweyrich

    Avoid warnings about implicit integer conversions that change the

    jweyrich authored
    signedness of an integer value (-Wsign-conversion).
This page is out of date. Refresh to see the latest.
6 Classes/ASIAuthenticationDialog.h
@@ -28,8 +28,8 @@ typedef enum _ASIAuthenticationType {
+ (void)presentAuthenticationDialogForRequest:(ASIHTTPRequest *)request;
+ (void)dismiss;
-@property (retain) ASIHTTPRequest *request;
-@property (assign) ASIAuthenticationType type;
-@property (assign) BOOL didEnableRotationNotifications;
+@property (atomic, retain) ASIHTTPRequest *request;
+@property (atomic, assign) ASIAuthenticationType type;
+@property (atomic, assign) BOOL didEnableRotationNotifications;
@property (retain, nonatomic) UIViewController *presentingController;
8 Classes/ASIAuthenticationDialog.m
@@ -41,7 +41,7 @@ - (void)keyboardWillShow:(NSNotification *)notification;
- (void)orientationChanged:(NSNotification *)notification;
- (void)cancelAuthenticationFromDialog:(id)sender;
- (void)loginWithCredentialsFromDialog:(id)sender;
-@property (retain) UITableView *tableView;
+@property (atomic, retain) UITableView *tableView;
@implementation ASIAuthenticationDialog
@@ -193,7 +193,7 @@ - (UIViewController *)presentingController
- (UITextField *)textFieldInRow:(NSUInteger)row section:(NSUInteger)section
return [[[[[self tableView] cellForRowAtIndexPath:
- [NSIndexPath indexPathForRow:row inSection:section]]
+ [NSIndexPath indexPathForRow:(NSInteger)row inSection:(NSInteger)section]]
contentView] subviews] objectAtIndex:0];
@@ -471,8 +471,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[textField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[textField setAutocorrectionType:UITextAutocorrectionTypeNo];
- NSUInteger s = [indexPath section];
- NSUInteger r = [indexPath row];
+ NSInteger s = [indexPath section];
+ NSInteger r = [indexPath row];
if (s == kUsernameSection && r == kUsernameRow) {
[textField setPlaceholder:@"User"];
2  Classes/ASIDataCompressor.h
@@ -38,5 +38,5 @@
// If deflating finishes or fails, this method will be called automatically
- (NSError *)closeStream;
-@property (assign, readonly) BOOL streamReady;
+@property (atomic, assign, readonly) BOOL streamReady;
4 Classes/ASIDataCompressor.m
@@ -81,7 +81,7 @@ - (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSErro
zStream.avail_in = (unsigned int)length;
zStream.avail_out = 0;
- NSInteger bytesProcessedAlready = zStream.total_out;
+ NSUInteger bytesProcessedAlready = zStream.total_out;
while (zStream.avail_out == 0) {
if (zStream.total_out-bytesProcessedAlready >= [outputData length]) {
@@ -174,7 +174,7 @@ + (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinati
// Attempt to deflate the chunk of data
- outputData = [compressor compressBytes:inputData length:readLength error:&theError shouldFinish:readLength < DATA_CHUNK_SIZE ];
+ outputData = [compressor compressBytes:inputData length:(NSUInteger)readLength error:&theError shouldFinish:readLength < DATA_CHUNK_SIZE];
if (theError) {
if (err) {
*err = theError;
2  Classes/ASIDataDecompressor.h
@@ -37,5 +37,5 @@
// If inflating finishes or fails, this method will be called automatically
- (NSError *)closeStream;
-@property (assign, readonly) BOOL streamReady;
+@property (atomic, assign, readonly) BOOL streamReady;
6 Classes/ASIDataDecompressor.m
@@ -78,7 +78,7 @@ - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSEr
zStream.avail_in = (unsigned int)length;
zStream.avail_out = 0;
- NSInteger bytesProcessedAlready = zStream.total_out;
+ NSUInteger bytesProcessedAlready = zStream.total_out;
while (zStream.avail_in != 0) {
if (zStream.total_out-bytesProcessedAlready >= [outputData length]) {
@@ -155,7 +155,7 @@ + (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destina
while ([decompressor streamReady]) {
// Read some data from the file
- readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE];
+ readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE];
// Make sure nothing went wrong
if ([inputStream streamStatus] == NSStreamStatusError) {
@@ -171,7 +171,7 @@ + (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destina
// Attempt to inflate the chunk of data
- outputData = [decompressor uncompressBytes:inputData length:readLength error:&theError];
+ outputData = [decompressor uncompressBytes:inputData length:(NSUInteger)readLength error:&theError];
if (theError) {
if (err) {
*err = theError;
4 Classes/ASIDownloadCache.h
@@ -41,6 +41,6 @@
@property (assign, nonatomic) ASICachePolicy defaultCachePolicy;
@property (retain, nonatomic) NSString *storagePath;
-@property (retain) NSRecursiveLock *accessLock;
-@property (assign) BOOL shouldRespectCacheControlHeaders;
+@property (atomic, retain) NSRecursiveLock *accessLock;
+@property (atomic, assign) BOOL shouldRespectCacheControlHeaders;
5 Classes/ASIFormDataRequest.h
@@ -70,7 +70,6 @@ typedef enum _ASIPostFormat {
// Same as above, but you can specify the content-type and file name
- (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
-@property (assign) ASIPostFormat postFormat;
-@property (assign) NSStringEncoding stringEncoding;
+@property (atomic, assign) ASIPostFormat postFormat;
+@property (atomic, assign) NSStringEncoding stringEncoding;
4 Classes/ASIFormDataRequest.m
@@ -15,8 +15,8 @@ - (void)buildMultipartFormDataPostBody;
- (void)buildURLEncodedPostBody;
- (void)appendPostString:(NSString *)string;
-@property (retain) NSMutableArray *postData;
-@property (retain) NSMutableArray *fileData;
+@property (atomic, retain) NSMutableArray *postData;
+@property (atomic, retain) NSMutableArray *fileData;
- (void)addToDebugBody:(NSString *)string;
174 Classes/ASIHTTPRequest.h
@@ -901,104 +901,104 @@ typedef void (^ASIDataBlock)(NSData *data);
#pragma mark ===
-@property (retain) NSString *username;
-@property (retain) NSString *password;
-@property (retain) NSString *userAgentString;
-@property (retain) NSString *domain;
+@property (atomic, retain) NSString *username;
+@property (atomic, retain) NSString *password;
+@property (atomic, retain) NSString *userAgentString;
+@property (atomic, retain) NSString *domain;
-@property (retain) NSString *proxyUsername;
-@property (retain) NSString *proxyPassword;
-@property (retain) NSString *proxyDomain;
+@property (atomic, retain) NSString *proxyUsername;
+@property (atomic, retain) NSString *proxyPassword;
+@property (atomic, retain) NSString *proxyDomain;
-@property (retain) NSString *proxyHost;
-@property (assign) int proxyPort;
-@property (retain) NSString *proxyType;
+@property (atomic, retain) NSString *proxyHost;
+@property (atomic, assign) int proxyPort;
+@property (atomic, retain) NSString *proxyType;
@property (retain,setter=setURL:, nonatomic) NSURL *url;
-@property (retain) NSURL *originalURL;
+@property (atomic, retain) NSURL *originalURL;
@property (assign, nonatomic) id delegate;
@property (retain, nonatomic) id queue;
@property (assign, nonatomic) id uploadProgressDelegate;
@property (assign, nonatomic) id downloadProgressDelegate;
-@property (assign) BOOL useKeychainPersistence;
-@property (assign) BOOL useSessionPersistence;
-@property (retain) NSString *downloadDestinationPath;
-@property (retain) NSString *temporaryFileDownloadPath;
-@property (retain) NSString *temporaryUncompressedDataDownloadPath;
-@property (assign) SEL didStartSelector;
-@property (assign) SEL didReceiveResponseHeadersSelector;
-@property (assign) SEL willRedirectSelector;
-@property (assign) SEL didFinishSelector;
-@property (assign) SEL didFailSelector;
-@property (assign) SEL didReceiveDataSelector;
-@property (retain,readonly) NSString *authenticationRealm;
-@property (retain,readonly) NSString *proxyAuthenticationRealm;
-@property (retain) NSError *error;
-@property (assign,readonly) BOOL complete;
-@property (retain) NSDictionary *responseHeaders;
-@property (retain) NSMutableDictionary *requestHeaders;
-@property (retain) NSMutableArray *requestCookies;
-@property (retain,readonly) NSArray *responseCookies;
-@property (assign) BOOL useCookiePersistence;
-@property (retain) NSDictionary *requestCredentials;
-@property (retain) NSDictionary *proxyCredentials;
-@property (assign,readonly) int responseStatusCode;
-@property (retain,readonly) NSString *responseStatusMessage;
-@property (retain) NSMutableData *rawResponseData;
-@property (assign) NSTimeInterval timeOutSeconds;
+@property (atomic, assign) BOOL useKeychainPersistence;
+@property (atomic, assign) BOOL useSessionPersistence;
+@property (atomic, retain) NSString *downloadDestinationPath;
+@property (atomic, retain) NSString *temporaryFileDownloadPath;
+@property (atomic, retain) NSString *temporaryUncompressedDataDownloadPath;
+@property (atomic, assign) SEL didStartSelector;
+@property (atomic, assign) SEL didReceiveResponseHeadersSelector;
+@property (atomic, assign) SEL willRedirectSelector;
+@property (atomic, assign) SEL didFinishSelector;
+@property (atomic, assign) SEL didFailSelector;
+@property (atomic, assign) SEL didReceiveDataSelector;
+@property (atomic, retain,readonly) NSString *authenticationRealm;
+@property (atomic, retain,readonly) NSString *proxyAuthenticationRealm;
+@property (atomic, retain) NSError *error;
+@property (atomic, assign,readonly) BOOL complete;
+@property (atomic, retain) NSDictionary *responseHeaders;
+@property (atomic, retain) NSMutableDictionary *requestHeaders;
+@property (atomic, retain) NSMutableArray *requestCookies;
+@property (atomic, retain,readonly) NSArray *responseCookies;
+@property (atomic, assign) BOOL useCookiePersistence;
+@property (atomic, retain) NSDictionary *requestCredentials;
+@property (atomic, retain) NSDictionary *proxyCredentials;
+@property (atomic, assign,readonly) int responseStatusCode;
+@property (atomic, retain,readonly) NSString *responseStatusMessage;
+@property (atomic, retain) NSMutableData *rawResponseData;
+@property (atomic, assign) NSTimeInterval timeOutSeconds;
@property (retain, nonatomic) NSString *requestMethod;
-@property (retain) NSMutableData *postBody;
-@property (assign) unsigned long long contentLength;
-@property (assign) unsigned long long postLength;
-@property (assign) BOOL shouldResetDownloadProgress;
-@property (assign) BOOL shouldResetUploadProgress;
-@property (assign) ASIHTTPRequest *mainRequest;
-@property (assign) BOOL showAccurateProgress;
-@property (assign) unsigned long long totalBytesRead;
-@property (assign) unsigned long long totalBytesSent;
-@property (assign) NSStringEncoding defaultResponseEncoding;
-@property (assign) NSStringEncoding responseEncoding;
-@property (assign) BOOL allowCompressedResponse;
-@property (assign) BOOL allowResumeForFileDownloads;
-@property (retain) NSDictionary *userInfo;
-@property (assign) NSInteger tag;
-@property (retain) NSString *postBodyFilePath;
-@property (assign) BOOL shouldStreamPostDataFromDisk;
-@property (assign) BOOL didCreateTemporaryPostDataFile;
-@property (assign) BOOL useHTTPVersionOne;
-@property (assign, readonly) unsigned long long partialDownloadSize;
-@property (assign) BOOL shouldRedirect;
-@property (assign) BOOL validatesSecureCertificate;
-@property (assign) BOOL shouldCompressRequestBody;
-@property (retain) NSURL *PACurl;
-@property (retain) NSString *authenticationScheme;
-@property (retain) NSString *proxyAuthenticationScheme;
-@property (assign) BOOL shouldPresentAuthenticationDialog;
-@property (assign) BOOL shouldPresentProxyAuthenticationDialog;
-@property (assign, readonly) ASIAuthenticationState authenticationNeeded;
-@property (assign) BOOL shouldPresentCredentialsBeforeChallenge;
-@property (assign, readonly) int authenticationRetryCount;
-@property (assign, readonly) int proxyAuthenticationRetryCount;
-@property (assign) BOOL haveBuiltRequestHeaders;
+@property (atomic, retain) NSMutableData *postBody;
+@property (atomic, assign) unsigned long long contentLength;
+@property (atomic, assign) unsigned long long postLength;
+@property (atomic, assign) BOOL shouldResetDownloadProgress;
+@property (atomic, assign) BOOL shouldResetUploadProgress;
+@property (atomic, assign) ASIHTTPRequest *mainRequest;
+@property (atomic, assign) BOOL showAccurateProgress;
+@property (atomic, assign) unsigned long long totalBytesRead;
+@property (atomic, assign) unsigned long long totalBytesSent;
+@property (atomic, assign) NSStringEncoding defaultResponseEncoding;
+@property (atomic, assign) NSStringEncoding responseEncoding;
+@property (atomic, assign) BOOL allowCompressedResponse;
+@property (atomic, assign) BOOL allowResumeForFileDownloads;
+@property (atomic, retain) NSDictionary *userInfo;
+@property (atomic, assign) NSInteger tag;
+@property (atomic, retain) NSString *postBodyFilePath;
+@property (atomic, assign) BOOL shouldStreamPostDataFromDisk;
+@property (atomic, assign) BOOL didCreateTemporaryPostDataFile;
+@property (atomic, assign) BOOL useHTTPVersionOne;
+@property (atomic, assign, readonly) unsigned long long partialDownloadSize;
+@property (atomic, assign) BOOL shouldRedirect;
+@property (atomic, assign) BOOL validatesSecureCertificate;
+@property (atomic, assign) BOOL shouldCompressRequestBody;
+@property (atomic, retain) NSURL *PACurl;
+@property (atomic, retain) NSString *authenticationScheme;
+@property (atomic, retain) NSString *proxyAuthenticationScheme;
+@property (atomic, assign) BOOL shouldPresentAuthenticationDialog;
+@property (atomic, assign) BOOL shouldPresentProxyAuthenticationDialog;
+@property (atomic, assign, readonly) ASIAuthenticationState authenticationNeeded;
+@property (atomic, assign) BOOL shouldPresentCredentialsBeforeChallenge;
+@property (atomic, assign, readonly) int authenticationRetryCount;
+@property (atomic, assign, readonly) int proxyAuthenticationRetryCount;
+@property (atomic, assign) BOOL haveBuiltRequestHeaders;
@property (assign, nonatomic) BOOL haveBuiltPostBody;
-@property (assign, readonly) BOOL inProgress;
-@property (assign) int numberOfTimesToRetryOnTimeout;
-@property (assign, readonly) int retryCount;
-@property (assign) BOOL shouldAttemptPersistentConnection;
-@property (assign) NSTimeInterval persistentConnectionTimeoutSeconds;
-@property (assign) BOOL shouldUseRFC2616RedirectBehaviour;
-@property (assign, readonly) BOOL connectionCanBeReused;
-@property (retain, readonly) NSNumber *requestID;
-@property (assign) id <ASICacheDelegate> downloadCache;
-@property (assign) ASICachePolicy cachePolicy;
-@property (assign) ASICacheStoragePolicy cacheStoragePolicy;
-@property (assign, readonly) BOOL didUseCachedResponse;
-@property (assign) NSTimeInterval secondsToCache;
-@property (retain) NSArray *clientCertificates;
+@property (atomic, assign, readonly) BOOL inProgress;
+@property (atomic, assign) int numberOfTimesToRetryOnTimeout;
+@property (atomic, assign, readonly) int retryCount;
+@property (atomic, assign) BOOL shouldAttemptPersistentConnection;
+@property (atomic, atomic, assign) NSTimeInterval persistentConnectionTimeoutSeconds;
+@property (atomic, assign) BOOL shouldUseRFC2616RedirectBehaviour;
+@property (atomic, assign, readonly) BOOL connectionCanBeReused;
+@property (atomic, retain, readonly) NSNumber *requestID;
+@property (atomic, assign) id <ASICacheDelegate> downloadCache;
+@property (atomic, assign) ASICachePolicy cachePolicy;
+@property (atomic, assign) ASICacheStoragePolicy cacheStoragePolicy;
+@property (atomic, assign, readonly) BOOL didUseCachedResponse;
+@property (atomic, assign) NSTimeInterval secondsToCache;
+@property (atomic, retain) NSArray *clientCertificates;
-@property (assign) BOOL shouldContinueWhenAppEntersBackground;
+@property (atomic, assign) BOOL shouldContinueWhenAppEntersBackground;
-@property (retain) ASIDataDecompressor *dataDecompressor;
-@property (assign) BOOL shouldWaitToInflateCompressedResponses;
+@property (atomic, retain) ASIDataDecompressor *dataDecompressor;
+@property (atomic, assign) BOOL shouldWaitToInflateCompressedResponses;
60 Classes/ASIHTTPRequest.m
@@ -212,7 +212,7 @@ - (void)callBlock:(ASIBasicBlock)block;
@property (retain, nonatomic) NSInputStream *postBodyReadStream;
@property (assign, nonatomic) unsigned long long lastBytesRead;
@property (assign, nonatomic) unsigned long long lastBytesSent;
-@property (retain) NSRecursiveLock *cancelledLock;
+@property (atomic, retain) NSRecursiveLock *cancelledLock;
@property (retain, nonatomic) NSOutputStream *fileDownloadOutputStream;
@property (retain, nonatomic) NSOutputStream *inflatedFileDownloadOutputStream;
@property (assign) int authenticationRetryCount;
@@ -227,7 +227,7 @@ - (void)callBlock:(ASIBasicBlock)block;
@property (retain) NSString *responseStatusMessage;
@property (assign) BOOL inProgress;
@property (assign) int retryCount;
-@property (assign) BOOL willRetryRequest;
+@property (atomic, assign) BOOL willRetryRequest;
@property (assign) BOOL connectionCanBeReused;
@property (retain, nonatomic) NSMutableDictionary *connectionInfo;
@property (retain, nonatomic) NSInputStream *readStream;
@@ -589,18 +589,21 @@ - (void)appendPostDataFromFile:(NSString *)file
[self setupPostBody];
NSInputStream *stream = [[[NSInputStream alloc] initWithFileAtPath:file] autorelease];
[stream open];
- NSUInteger bytesRead;
while ([stream hasBytesAvailable]) {
unsigned char buffer[1024*256];
- bytesRead = [stream read:buffer maxLength:sizeof(buffer)];
+ NSInteger bytesRead = [stream read:buffer maxLength:sizeof(buffer)];
if (bytesRead == 0) {
+ // 0 indicates that the end of the buffer was reached.
+ break;
+ } else if (bytesRead < 0) {
+ // A negative number means that the operation failed.
if ([self shouldStreamPostDataFromDisk]) {
- [[self postBodyWriteStream] write:buffer maxLength:bytesRead];
+ [[self postBodyWriteStream] write:buffer maxLength:(NSUInteger)bytesRead];
} else {
- [[self postBody] appendData:[NSData dataWithBytes:buffer length:bytesRead]];
+ [[self postBody] appendData:[NSData dataWithBytes:buffer length:(NSUInteger)bytesRead]];
[stream close];
@@ -1343,7 +1346,7 @@ - (void)startRequest
if (![self connectionInfo]) {
[self setConnectionInfo:[NSMutableDictionary dictionary]];
- [[self connectionInfo] setObject:[NSNumber numberWithInt:nextConnectionNumberToCreate] forKey:@"id"];
+ [[self connectionInfo] setObject:[NSNumber numberWithInt:(int)nextConnectionNumberToCreate] forKey:@"id"];
[[self connectionInfo] setObject:[[self url] host] forKey:@"host"];
[[self connectionInfo] setObject:[NSNumber numberWithInt:[[[self url] port] intValue]] forKey:@"port"];
[[self connectionInfo] setObject:[[self url] scheme] forKey:@"scheme"];
@@ -1412,7 +1415,7 @@ - (void)startRequest
if (![self mainRequest]) {
if ([self shouldResetUploadProgress]) {
if ([self showAccurateProgress]) {
- [self incrementUploadSizeBy:[self postLength]];
+ [self incrementUploadSizeBy:(long long)[self postLength]];
} else {
[self incrementUploadSizeBy:1];
@@ -1759,7 +1762,7 @@ - (void)updateUploadProgress
// We will remove this from any progress display, as kCFStreamPropertyHTTPRequestBytesWrittenCount does not tell us how much data has actually be written
if ([self uploadBufferSize] == 0 && [self totalBytesSent] != [self postLength]) {
[self setUploadBufferSize:[self totalBytesSent]];
- [self incrementUploadSizeBy:-[self uploadBufferSize]];
+ [self incrementUploadSizeBy:-(long long)[self uploadBufferSize]];
unsigned long long value = 0;
@@ -1819,7 +1822,7 @@ - (void)incrementUploadSizeBy:(long long)length
- long long progressToRemove = -[self totalBytesSent];
+ long long progressToRemove = -(long long)[self totalBytesSent];
[ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:&queue withObject:self amount:&progressToRemove callerToRetain:self];
[ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:&uploadProgressDelegate withObject:self amount:&progressToRemove callerToRetain:self];
[ASIHTTPRequest updateProgressIndicator:&uploadProgressDelegate withProgress:0 ofTotal:[self postLength]];
@@ -1827,7 +1830,7 @@ -(void)removeUploadProgressSoFar
unsigned long long totalSize = [self postLength];
- [self performBlockOnMainThread:^{ if (bytesSentBlock) { bytesSentBlock(progressToRemove, totalSize); }}];
+ [self performBlockOnMainThread:^{ if (bytesSentBlock) { bytesSentBlock((unsigned long long)progressToRemove, totalSize); }}];
@@ -2243,7 +2246,7 @@ - (void)readResponseHeaders
} else {
[theRequest setContentLength:length];
if ([self showAccurateProgress] && [self shouldResetDownloadProgress]) {
- [theRequest incrementDownloadSizeBy:[theRequest contentLength]+[theRequest partialDownloadSize]];
+ [theRequest incrementDownloadSizeBy:(long long)[theRequest contentLength]+(long long)[theRequest partialDownloadSize]];
@@ -3304,18 +3307,18 @@ - (void)handleBytesAvailable
[self setDataDecompressor:[ASIDataDecompressor decompressor]];
NSError *err = nil;
- inflatedData = [[self dataDecompressor] uncompressBytes:buffer length:bytesRead error:&err];
+ inflatedData = [[self dataDecompressor] uncompressBytes:buffer length:(NSUInteger)bytesRead error:&err];
if (err) {
[self failWithError:err];
- [self setTotalBytesRead:[self totalBytesRead]+bytesRead];
+ [self setTotalBytesRead:[self totalBytesRead]+(NSUInteger)bytesRead];
[self setLastActivityTime:[NSDate date]];
// For bandwidth measurement / throttling
- [ASIHTTPRequest incrementBandwidthUsedInLastSecond:bytesRead];
+ [ASIHTTPRequest incrementBandwidthUsedInLastSecond:(NSUInteger)bytesRead];
// If we need to redirect, and have automatic redirect on, and might be resuming a download, let's do nothing with the content
if ([self needsRedirect] && [self shouldRedirect] && [self allowResumeForFileDownloads]) {
@@ -3338,7 +3341,7 @@ - (void)handleBytesAvailable
if ([self isResponseCompressed] && ![self shouldWaitToInflateCompressedResponses]) {
data = inflatedData;
} else {
- data = [NSData dataWithBytes:buffer length:bytesRead];
+ data = [NSData dataWithBytes:buffer length:(NSUInteger)bytesRead];
[self performSelectorOnMainThread:@selector(passOnReceivedData:) withObject:data waitUntilDone:[NSThread isMainThread]];
@@ -3352,7 +3355,7 @@ - (void)handleBytesAvailable
if ([[self responseHeaders] objectForKey:@"Content-Range"]) {
append = YES;
} else {
- [self incrementDownloadSizeBy:-[self partialDownloadSize]];
+ [self incrementDownloadSizeBy:-(long long)[self partialDownloadSize]];
[self setPartialDownloadSize:0];
@@ -3361,7 +3364,7 @@ - (void)handleBytesAvailable
[[self fileDownloadOutputStream] open];
- [[self fileDownloadOutputStream] write:buffer maxLength:bytesRead];
+ [[self fileDownloadOutputStream] write:buffer maxLength:(NSUInteger)bytesRead];
if ([self isResponseCompressed] && ![self shouldWaitToInflateCompressedResponses]) {
@@ -3383,7 +3386,7 @@ - (void)handleBytesAvailable
if ([self isResponseCompressed] && ![self shouldWaitToInflateCompressedResponses]) {
[rawResponseData appendData:inflatedData];
} else {
- [rawResponseData appendBytes:buffer length:bytesRead];
+ [rawResponseData appendBytes:buffer length:(NSUInteger)bytesRead];
@@ -3589,7 +3592,7 @@ - (void)useDataFromCache
} else {
[theRequest setRawResponseData:[NSMutableData dataWithData:[[self downloadCache] cachedResponseDataForURL:[self url]]]];
- [theRequest setContentLength:[[[self responseHeaders] objectForKey:@"Content-Length"] longLongValue]];
+ [theRequest setContentLength:(unsigned long long)[[[self responseHeaders] objectForKey:@"Content-Length"] longLongValue]];
[theRequest setTotalBytesRead:[self contentLength]];
[theRequest parseStringEncodingFromHeaders];
@@ -3938,8 +3941,9 @@ - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode
// If your PAC file is larger than 16KB, you're just being cruel.
uint8_t buf[16384];
NSInteger len = [(NSInputStream *)stream read:buf maxLength:16384];
- if (len) {
- [[self PACFileData] appendBytes:(const void *)buf length:len];
+ // Append only if something was actually read.
+ if (len > 0) {
+ [[self PACFileData] appendBytes:(const void *)buf length:(NSUInteger)len];
} else if (eventCode == NSStreamEventErrorOccurred || eventCode == NSStreamEventEndEncountered) {
@@ -4821,14 +4825,14 @@ + (BOOL)isMultitaskingSupported
+ (NSString*)base64forData:(NSData*)theData {
const uint8_t* input = (const uint8_t*)[theData bytes];
- NSInteger length = [theData length];
+ NSUInteger length = [theData length];
static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
NSMutableData* data = [NSMutableData dataWithLength:((length + 2) / 3) * 4];
uint8_t* output = (uint8_t*)data.mutableBytes;
- NSInteger i,i2;
+ NSUInteger i,i2;
for (i=0; i < length; i += 3) {
NSInteger value = 0;
for (i2=0; i2<3; i2++) {
@@ -4839,10 +4843,10 @@ + (NSString*)base64forData:(NSData*)theData {
NSInteger theIndex = (i / 3) * 4;
- output[theIndex + 0] = table[(value >> 18) & 0x3F];
- output[theIndex + 1] = table[(value >> 12) & 0x3F];
- output[theIndex + 2] = (i + 1) < length ? table[(value >> 6) & 0x3F] : '=';
- output[theIndex + 3] = (i + 2) < length ? table[(value >> 0) & 0x3F] : '=';
+ output[theIndex + 0] = (uint8_t)table[(value >> 18) & 0x3F];
+ output[theIndex + 1] = (uint8_t)table[(value >> 12) & 0x3F];
+ output[theIndex + 2] = (i + 1) < length ? (uint8_t)table[(value >> 6) & 0x3F] : '=';
+ output[theIndex + 3] = (i + 2) < length ? (uint8_t)table[(value >> 0) & 0x3F] : '=';
return [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease];
2  Classes/ASIInputStream.m
@@ -61,7 +61,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len
[readLock unlock];
NSInteger rv = [stream read:buffer maxLength:toRead];
if (rv > 0)
- [ASIHTTPRequest incrementBandwidthUsedInLastSecond:rv];
+ [ASIHTTPRequest incrementBandwidthUsedInLastSecond:(NSUInteger)rv];
return rv;
30 Classes/ASINetworkQueue.h
@@ -88,21 +88,21 @@
@property (assign, nonatomic, setter=setUploadProgressDelegate:) id uploadProgressDelegate;
@property (assign, nonatomic, setter=setDownloadProgressDelegate:) id downloadProgressDelegate;
-@property (assign) SEL requestDidStartSelector;
-@property (assign) SEL requestDidReceiveResponseHeadersSelector;
-@property (assign) SEL requestWillRedirectSelector;
-@property (assign) SEL requestDidFinishSelector;
-@property (assign) SEL requestDidFailSelector;
-@property (assign) SEL queueDidFinishSelector;
-@property (assign) BOOL shouldCancelAllRequestsOnFailure;
-@property (assign) id delegate;
-@property (assign) BOOL showAccurateProgress;
-@property (assign, readonly) int requestsCount;
-@property (retain) NSDictionary *userInfo;
+@property (assign, atomic) SEL requestDidStartSelector;
+@property (assign, atomic) SEL requestDidReceiveResponseHeadersSelector;
+@property (assign, atomic) SEL requestWillRedirectSelector;
+@property (assign, atomic) SEL requestDidFinishSelector;
+@property (assign, atomic) SEL requestDidFailSelector;
+@property (assign, atomic) SEL queueDidFinishSelector;
+@property (assign, atomic) BOOL shouldCancelAllRequestsOnFailure;
+@property (assign, atomic) id delegate;
+@property (assign, atomic) BOOL showAccurateProgress;
+@property (assign, atomic, readonly) int requestsCount;
+@property (retain, atomic) NSDictionary *userInfo;
-@property (assign) unsigned long long bytesUploadedSoFar;
-@property (assign) unsigned long long totalBytesToUpload;
-@property (assign) unsigned long long bytesDownloadedSoFar;
-@property (assign) unsigned long long totalBytesToDownload;
+@property (assign, atomic) unsigned long long bytesUploadedSoFar;
+@property (assign, atomic) unsigned long long totalBytesToUpload;
+@property (assign, atomic) unsigned long long bytesDownloadedSoFar;
+@property (assign, atomic) unsigned long long totalBytesToDownload;
10 Classes/ASINetworkQueue.m
@@ -159,7 +159,7 @@ - (void)addOperation:(NSOperation *)operation
[request buildPostBody];
- [self request:nil incrementUploadSizeBy:[request postLength]];
+ [self request:nil incrementUploadSizeBy:(long long)[request postLength]];
} else {
@@ -233,7 +233,7 @@ - (void)requestFailed:(ASIHTTPRequest *)request
- (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes
- [self setBytesDownloadedSoFar:[self bytesDownloadedSoFar]+bytes];
+ [self setBytesDownloadedSoFar:[self bytesDownloadedSoFar]+(unsigned long long)bytes];
if ([self downloadProgressDelegate]) {
[ASIHTTPRequest updateProgressIndicator:&downloadProgressDelegate withProgress:[self bytesDownloadedSoFar] ofTotal:[self totalBytesToDownload]];
@@ -241,7 +241,7 @@ - (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes
- (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes
- [self setBytesUploadedSoFar:[self bytesUploadedSoFar]+bytes];
+ [self setBytesUploadedSoFar:[self bytesUploadedSoFar]+(unsigned long long)bytes];
if ([self uploadProgressDelegate]) {
[ASIHTTPRequest updateProgressIndicator:&uploadProgressDelegate withProgress:[self bytesUploadedSoFar] ofTotal:[self totalBytesToUpload]];
@@ -249,12 +249,12 @@ - (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes
- (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength
- [self setTotalBytesToDownload:[self totalBytesToDownload]+newLength];
+ [self setTotalBytesToDownload:[self totalBytesToDownload]+(unsigned long long)newLength];
- (void)request:(ASIHTTPRequest *)request incrementUploadSizeBy:(long long)newLength
- [self setTotalBytesToUpload:[self totalBytesToUpload]+newLength];
+ [self setTotalBytesToUpload:[self totalBytesToUpload]+(unsigned long long)newLength];
2  External/Reachability/Reachability.h
@@ -143,7 +143,7 @@ extern NSString *const kReachabilityChangedNotification;
-@property (copy) NSString *key; // Atomic because network operations are asynchronous.
+@property (atomic, copy) NSString *key; // Atomic because network operations are asynchronous.
// Designated Initializer.
- (Reachability *) initWithReachabilityRef: (SCNetworkReachabilityRef) ref;
6 External/Reachability/Reachability.m
@@ -442,9 +442,9 @@ - (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags {
if (flags & kSCNetworkReachabilityFlagsIsWWAN) { return kReachableViaWWAN; }
// Clear moot bits.
- flags &= ~kSCNetworkReachabilityFlagsReachable;
- flags &= ~kSCNetworkReachabilityFlagsIsDirect;
- flags &= ~kSCNetworkReachabilityFlagsIsLocalAddress; // kInternetConnection is local.
+ flags &= ~(uint32_t)kSCNetworkReachabilityFlagsReachable;
+ flags &= ~(uint32_t)kSCNetworkReachabilityFlagsIsDirect;
+ flags &= ~(uint32_t)kSCNetworkReachabilityFlagsIsLocalAddress; // kInternetConnection is local.
// Reachability Flag Status: -R ct---xx Connection down.
if (flags == kConnectionDown) { return kNotReachable; }
Something went wrong with that request. Please try again.