Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some "type mismatch" compiler warnings #101

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
*.pbxuser
*.mode1v3
*.mode2v3
xcuserdata
*~
*xcuserdata*
*xcworkspace*
._*
11 changes: 9 additions & 2 deletions Core/Categories/DDData.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ - (NSString *)hexStringValue
NSMutableString *stringBuffer = [NSMutableString stringWithCapacity:([self length] * 2)];

const unsigned char *dataBuffer = [self bytes];
int i;
NSUInteger i = 0;

for (i = 0; i < [self length]; ++i)
for (i = 0; i != [self length]; ++i)
{
[stringBuffer appendFormat:@"%02x", (unsigned int)dataBuffer[i]];
}
Expand All @@ -43,6 +43,9 @@ - (NSString *)hexStringValue

- (NSString *)base64Encoded
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wconversion"
const unsigned char *bytes = [self bytes];
NSMutableString *result = [NSMutableString stringWithCapacity:[self length]];
unsigned long ixtext = 0;
Expand Down Expand Up @@ -91,6 +94,7 @@ - (NSString *)base64Encoded
}

return [NSString stringWithString:result];
#pragma clang diagnostic pop
}

- (NSData *)base64Decoded
Expand Down Expand Up @@ -140,9 +144,12 @@ - (NSData *)base64Decoded
if( ixinbuf == 4 )
{
ixinbuf = 0;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
outbuf [0] = ( inbuf[0] << 2 ) | ( ( inbuf[1] & 0x30) >> 4 );
outbuf [1] = ( ( inbuf[1] & 0x0F ) << 4 ) | ( ( inbuf[2] & 0x3C ) >> 2 );
outbuf [2] = ( ( inbuf[2] & 0x03 ) << 6 ) | ( inbuf[3] & 0x3F );
#pragma clang diagnostic pop

for( i = 0; i < ctcharsinbuf; i++ )
[result appendBytes:&outbuf[i] length:1];
Expand Down
9 changes: 9 additions & 0 deletions Core/HTTPConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@

@interface HTTPConfig : NSObject
{
#if __has_feature(objc_arc_weak)
HTTPServer __weak *server;
#else
HTTPServer __unsafe_unretained *server;
#endif
NSString __strong *documentRoot;
dispatch_queue_t queue;
}

- (id)initWithServer:(HTTPServer *)server documentRoot:(NSString *)documentRoot;
- (id)initWithServer:(HTTPServer *)server documentRoot:(NSString *)documentRoot queue:(dispatch_queue_t)q;

#if __has_feature(objc_arc_weak)
@property (nonatomic, weak, readonly) HTTPServer *server;
#else
@property (nonatomic, unsafe_unretained, readonly) HTTPServer *server;
#endif

@property (nonatomic, strong, readonly) NSString *documentRoot;
@property (nonatomic, readonly) dispatch_queue_t queue;

Expand Down
10 changes: 6 additions & 4 deletions Core/HTTPConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ + (NSString *)generateNonce
[recentNonces addObject:newNonce];
}});

double delayInSeconds = TIMEOUT_NONCE;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
uint64_t delayInSeconds = TIMEOUT_NONCE;
int64_t delay = (int64_t)(delayInSeconds * NSEC_PER_SEC);

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delay);
dispatch_after(popTime, recentNonceQueue, ^{ @autoreleasepool {

[recentNonces removeObject:newNonce];
Expand Down Expand Up @@ -819,7 +821,7 @@ - (BOOL)parseRangeRequest:(NSString *)rangeHeader withContentLength:(UInt64)cont
// r2 is the number of ending bytes to include in the range

if(!hasR2) return NO;
if(r2 > contentLength) return NO;
if(r2 > contentLength) r2 = contentLength;

UInt64 startIndex = contentLength - r2;

Expand All @@ -842,7 +844,7 @@ - (BOOL)parseRangeRequest:(NSString *)rangeHeader withContentLength:(UInt64)cont
// Note: The range is inclusive. So 0-1 has a length of 2 bytes.

if(r1 > r2) return NO;
if(r2 >= contentLength) return NO;
if(r2 >= contentLength) r2 = contentLength - 1;

[ranges addObject:[NSValue valueWithDDRange:DDMakeRange(r1, r2 - r1 + 1)]];
}
Expand Down
11 changes: 9 additions & 2 deletions Core/HTTPMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,21 @@ - (void)dealloc
}
}

-(BOOL)booleanToBool:( Boolean )value
{
BOOL result = ( 0 == value ) ? NO : YES;
return result;
}

- (BOOL)appendData:(NSData *)data
{
return CFHTTPMessageAppendBytes(message, [data bytes], [data length]);
CFIndex cfDataLength = (CFIndex)[data length];
return [ self booleanToBool: CFHTTPMessageAppendBytes(message, [data bytes], cfDataLength) ];
}

- (BOOL)isHeaderComplete
{
return CFHTTPMessageIsHeaderComplete(message);
return [ self booleanToBool: CFHTTPMessageIsHeaderComplete(message) ];
}

- (NSString *)version
Expand Down
Loading