Permalink
Browse files

Fix some clang warnings

  • Loading branch information...
1 parent 775589e commit b61e3fa8edc09cac23b5eeb02ac7e9f2fe3a4297 @pokeb committed Oct 31, 2010
@@ -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 @@ - (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSErro
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,22 +133,22 @@ + (NSData *)compressData:(NSData*)uncompressedData error:(NSError **)err
-+ (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
if (![[NSFileManager defaultManager] fileExistsAtPath:sourcePath]) {
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 @@ + (void)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinati
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 @@ + (void)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinati
if (err) {
*err = theError;
}
- return;
+ return NO;
}
// Write the deflated data out to the destination file
@@ -194,13 +196,14 @@ + (void)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinati
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 @@ - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSEr
break;
}
} else if (status != Z_OK) {
- theError = [[self class] inflateErrorWithCode:status];
+ if (err) {
+ *err = [[self class] inflateErrorWithCode:status];
+ }
[self closeStream];
return nil;
}
@@ -129,22 +131,22 @@ + (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err
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
if (![[NSFileManager defaultManager] fileExistsAtPath:sourcePath]) {
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 @@ + (void)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destina
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 @@ + (void)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destina
if (err) {
*err = theError;
}
- return;
+ return NO;
}
// Write the inflated data out to the destination file
@@ -192,13 +194,14 @@ + (void)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destina
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;
}
View
@@ -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 @@ - (void)buildPostBody
[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 @@ + (BOOL)removeFileAtPath:(NSString *)path error:(NSError **)err
NSError *removeError = nil;
[[NSFileManager defaultManager] removeItemAtPath:path error:&removeError];
if (removeError) {
- *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to delete file at path '%@'",path],NSLocalizedDescriptionKey,removeError,NSUnderlyingErrorKey,nil]];
+ 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 @@ - (void)testInflateData
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 @@ - (void)testDeflateData
// 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 @@ - (void)testBlocks
__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 @@ - (void)testBlocks
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 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath
}
}
- } else if ([indexPath section] == 2) {
+ } else {
cell = [tableView dequeueReusableCellWithIdentifier:@"Response"];
if (!cell) {
@@ -111,7 +111,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath
}
}
- } else if ([indexPath section] == 3) {
+ } else {
cell = [tableView dequeueReusableCellWithIdentifier:@"HeaderCell"];
if (!cell) {
cell = [DetailCell cell];
@@ -148,7 +148,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath
} 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 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath
[[cell accessoryView] setHidden:NO];
}
- } else if ([indexPath section] == 3) {
+ } else {
cell = [tableView dequeueReusableCellWithIdentifier:@"Response"];
if (!cell) {

0 comments on commit b61e3fa

Please sign in to comment.