Ben Copsey

Fix some clang warnings

... ... @@ -28,7 +28,7 @@
+ (NSData *)compressData:(NSData*)uncompressedData error:(NSError **)err;
// Convenience method - pass it a file containing the data to compress in sourcePath, and it will write deflated data to destinationPath
+ (void)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err;
+ (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err;
// Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'compressor'
- (NSError *)setupStream;
... ...
... ... @@ -97,7 +97,9 @@
if (status == Z_STREAM_END) {
theError = [self closeStream];
} else if (status != Z_OK) {
theError = [[self class] deflateErrorWithCode:status];
if (err) {
*err = [[self class] deflateErrorWithCode:status];
}
[self closeStream];
return NO;
}
... ... @@ -131,14 +133,14 @@
+ (void)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err
+ (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err
{
// Create an empty file at the destination path
if (![[NSFileManager defaultManager] createFileAtPath:destinationPath contents:[NSData data] attributes:nil]) {
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were to create a file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,nil]];
}
return;
return NO;
}
// Ensure the source file exists
... ... @@ -146,7 +148,7 @@
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed the file does not exist",sourcePath],NSLocalizedDescriptionKey,nil]];
}
return;
return NO;
}
UInt8 inputData[DATA_CHUNK_SIZE];
... ... @@ -173,7 +175,7 @@
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]];
}
return;
return NO;
}
// Attempt to inflate the chunk of data
... ... @@ -182,7 +184,7 @@
if (err) {
*err = theError;
}
return;
return NO;
}
// Write the deflated data out to the destination file
... ... @@ -194,13 +196,14 @@
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to write to the destination data file at &@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
}
return;
return NO;
}
}
[inputStream close];
[outputStream close];
return YES;
}
+ (NSError *)deflateErrorWithCode:(int)code
... ...
... ... @@ -28,7 +28,7 @@
+ (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err;
// Convenience method - pass it a file containing deflated data in sourcePath, and it will write inflated data to destinationPath
+ (void)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err;
+ (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err;
// Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'decompressor'
- (NSError *)setupStream;
... ...
... ... @@ -97,7 +97,9 @@
break;
}
} else if (status != Z_OK) {
theError = [[self class] inflateErrorWithCode:status];
if (err) {
*err = [[self class] inflateErrorWithCode:status];
}
[self closeStream];
return nil;
}
... ... @@ -129,14 +131,14 @@
return outputData;
}
+ (void)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err
+ (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err
{
// Create an empty file at the destination path
if (![[NSFileManager defaultManager] createFileAtPath:destinationPath contents:[NSData data] attributes:nil]) {
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were to create a file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,nil]];
}
return;
return NO;
}
// Ensure the source file exists
... ... @@ -144,7 +146,7 @@
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed the file does not exist",sourcePath],NSLocalizedDescriptionKey,nil]];
}
return;
return NO;
}
UInt8 inputData[DATA_CHUNK_SIZE];
... ... @@ -171,7 +173,7 @@
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]];
}
return;
return NO;
}
// Attempt to inflate the chunk of data
... ... @@ -180,7 +182,7 @@
if (err) {
*err = theError;
}
return;
return NO;
}
// Write the inflated data out to the destination file
... ... @@ -192,13 +194,14 @@
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at &@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
}
return;
return NO;
}
}
[inputStream close];
[outputStream close];
return YES;
}
... ...
... ... @@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.7-122 2010-10-31";
NSString *ASIHTTPRequestVersion = @"v1.7-125 2010-10-31";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ... @@ -413,8 +413,7 @@ static NSOperationQueue *sharedQueue = nil;
[self setCompressedPostBodyFilePath:[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]]];
NSError *err = nil;
[ASIDataCompressor compressDataFromFile:[self postBodyFilePath] toFile:[self compressedPostBodyFilePath] error:&err];
if (err) {
if (![ASIDataCompressor compressDataFromFile:[self postBodyFilePath] toFile:[self compressedPostBodyFilePath] error:&err]) {
[self failWithError:err];
return;
}
... ... @@ -3435,7 +3434,9 @@ static NSOperationQueue *sharedQueue = nil;
NSError *removeError = nil;
[[NSFileManager defaultManager] removeItemAtPath:path error:&removeError];
if (removeError) {
if (err) {
*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to delete file at path '%@'",path],NSLocalizedDescriptionKey,removeError,NSUnderlyingErrorKey,nil]];
}
return NO;
}
}
... ...
... ... @@ -63,8 +63,7 @@
GHFail(@"Failed to remove old file, cannot proceed with test");
}
[ASIDataDecompressor uncompressDataFromFile:gzippedFilePath toFile:inflatedFilePath error:&error];
if (error) {
if (![ASIDataDecompressor uncompressDataFromFile:gzippedFilePath toFile:inflatedFilePath error:&error]) {
GHFail(@"Inflate failed because %@",error);
}
... ... @@ -124,8 +123,7 @@
// Test file to file deflate
[ASIHTTPRequest removeFileAtPath:gzippedFilePath error:&error];
[ASIDataCompressor compressDataFromFile:filePath toFile:gzippedFilePath error:&error];
if (error) {
if (![ASIDataCompressor compressDataFromFile:filePath toFile:gzippedFilePath error:&error]) {
GHFail(@"Deflate failed because %@",error);
}
[ASIHTTPRequest removeFileAtPath:filePath error:&error];
... ...
... ... @@ -31,7 +31,7 @@
__block unsigned long long totalUploadSize = 0;
NSMutableData *dataReceived = [NSMutableData data];
ASIHTTPRequest *request = [[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/blocks"]] retain];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/blocks"]];
[request setStartedBlock:^(ASIHTTPRequest *request) {
started = YES;
}];
... ... @@ -70,14 +70,14 @@
GHAssertTrue(complete,@"Failed to call completed block");
BOOL success = (totalBytesReceived == 130050);
GHAssertTrue(complete,@"Failed to call bytes received block, or got wrong amount of data");
GHAssertTrue(success,@"Failed to call bytes received block, or got wrong amount of data");
success = (totalDownloadSize == 130050);
GHAssertTrue(complete,@"Failed to call download size increment block");
GHAssertTrue(success,@"Failed to call download size increment block");
success = (totalBytesSent == [dataToSend length]);
GHAssertTrue(complete,@"Failed to call bytes sent block");
GHAssertTrue(success,@"Failed to call bytes sent block");
success = (totalUploadSize == [dataToSend length]);
GHAssertTrue(complete,@"Failed to call upload size increment block");
GHAssertTrue(success,@"Failed to call upload size increment block");
request = [ASIHTTPRequest requestWithURL:nil];
... ...
... ... @@ -171,7 +171,7 @@ static NSString *intro = @"Demonstrates fetching content from an area that requi
}
}
} else if ([indexPath section] == 2) {
} else {
cell = [tableView dequeueReusableCellWithIdentifier:@"Response"];
if (!cell) {
... ...
... ... @@ -111,7 +111,7 @@ static NSString *intro = @"Demonstrates fetching a web page synchronously, the H
}
}
} else if ([indexPath section] == 3) {
} else {
cell = [tableView dequeueReusableCellWithIdentifier:@"HeaderCell"];
if (!cell) {
cell = [DetailCell cell];
... ...
... ... @@ -148,7 +148,7 @@ static NSString *intro = @"Demonstrates POSTing content to a URL, showing upload
} else if ([indexPath section] == 1) {
return nil;
} else if ([indexPath section] == 2) {
} else {
cell = [tableView dequeueReusableCellWithIdentifier:@"Response"];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"] autorelease];
... ...
... ... @@ -220,7 +220,7 @@ static NSString *intro = @"ASIWebPageRequest lets you download complete webpages
[[cell accessoryView] setHidden:NO];
}
} else if ([indexPath section] == 3) {
} else {
cell = [tableView dequeueReusableCellWithIdentifier:@"Response"];
if (!cell) {
... ...