diff --git a/Libraries/ProtocolBuffers/CodedInputStream.m b/Libraries/ProtocolBuffers/CodedInputStream.m index 46ff9c852..516a37366 100644 --- a/Libraries/ProtocolBuffers/CodedInputStream.m +++ b/Libraries/ProtocolBuffers/CodedInputStream.m @@ -598,7 +598,7 @@ int64_t decodeZigZag64(int64_t n) { bufferPos = 0; bufferSize = 0; if (input != nil) { - bufferSize = [input read:buffer.mutableBytes maxLength:buffer.length]; + bufferSize = (int32_t)[input read:buffer.mutableBytes maxLength:buffer.length]; } if (bufferSize <= 0) { @@ -610,7 +610,7 @@ int64_t decodeZigZag64(int64_t n) { } } else { [self recomputeBufferSizeAfterLimit]; - int32_t totalBytesRead = totalBytesRetired + bufferSize + bufferSizeAfterLimit; + NSInteger totalBytesRead = totalBytesRetired + bufferSize + bufferSizeAfterLimit; if (totalBytesRead > sizeLimit || totalBytesRead < 0) { @throw [NSException exceptionWithName:@"InvalidProtocolBuffer" reason:@"sizeLimitExceeded" userInfo:nil]; } @@ -713,7 +713,7 @@ int64_t decodeZigZag64(int64_t n) { while (pos < (int32_t)chunk.length) { int32_t n = 0; if (input != nil) { - n = [input read:(((uint8_t*) chunk.mutableBytes) + pos) maxLength:chunk.length - (NSUInteger)pos]; + n = (int32_t)[input read:(((uint8_t*) chunk.mutableBytes) + pos) maxLength:chunk.length - (NSUInteger)pos]; } if (n <= 0) { @throw [NSException exceptionWithName:@"InvalidProtocolBuffer" reason:@"truncatedMessage" userInfo:nil]; diff --git a/Libraries/ProtocolBuffers/TextFormat.m b/Libraries/ProtocolBuffers/TextFormat.m index c822ff16e..e2d4c4e0b 100644 --- a/Libraries/ProtocolBuffers/TextFormat.m +++ b/Libraries/ProtocolBuffers/TextFormat.m @@ -86,7 +86,7 @@ BOOL isHex(unichar c) { if (isSigned) { result = strtol(in_string, &out_string, 0); } else { - result = convertUInt32ToInt32(strtoul(in_string, &out_string, 0)); + result = convertUInt32ToInt32((unsigned int)strtoul(in_string, &out_string, 0)); } } diff --git a/Signal/src/audio/incall_audio/RemoteIOBufferListWrapper.m b/Signal/src/audio/incall_audio/RemoteIOBufferListWrapper.m index e3ec7df51..d32527f43 100644 --- a/Signal/src/audio/incall_audio/RemoteIOBufferListWrapper.m +++ b/Signal/src/audio/incall_audio/RemoteIOBufferListWrapper.m @@ -8,7 +8,7 @@ AudioBufferList* audioBufferList = malloc(sizeof(AudioBufferList)); audioBufferList->mNumberBuffers = 1; audioBufferList->mBuffers[0].mNumberChannels = 1; - audioBufferList->mBuffers[0].mDataByteSize = bufferSize; + audioBufferList->mBuffers[0].mDataByteSize = (UInt32)bufferSize; audioBufferList->mBuffers[0].mData = malloc(bufferSize); RemoteIOBufferListWrapper* w = [RemoteIOBufferListWrapper new]; diff --git a/Signal/src/audio/incall_audio/processing/AudioStretcher.m b/Signal/src/audio/incall_audio/processing/AudioStretcher.m index 648a1fd90..75b21d0a0 100644 --- a/Signal/src/audio/incall_audio/processing/AudioStretcher.m +++ b/Signal/src/audio/incall_audio/processing/AudioStretcher.m @@ -22,7 +22,7 @@ checkOperationDescribe(time_scale_rate(&timeScaleState, (float)stretchFactor) == 0, @"Changing time scaling"); - int inputSampleCount = [audioData length]/sizeof(int16_t); + int inputSampleCount = (unsigned int)[audioData length]/sizeof(int16_t); int maxOutputSampleCount = [self getSafeMaxOutputSampleCountFromInputSampleCount:inputSampleCount]; int16_t* input = (int16_t*)[audioData bytes]; diff --git a/Signal/src/contact/ContactsManager.m b/Signal/src/contact/ContactsManager.m index 59bb0b115..e13458a22 100644 --- a/Signal/src/contact/ContactsManager.m +++ b/Signal/src/contact/ContactsManager.m @@ -375,7 +375,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in -(NSArray*) contactsForContactIds:(NSArray *)contactIds { NSMutableArray *contacts = [NSMutableArray array]; for (NSNumber *favouriteId in contactIds) { - Contact *contact = [self latestContactWithRecordId:[favouriteId integerValue]]; + Contact *contact = [self latestContactWithRecordId:[favouriteId intValue]]; if (contact) { [contacts addObject:contact]; @@ -427,7 +427,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in #pragma mark - Whisper User Management --(unsigned int) checkForNewWhisperUsers { +-(NSUInteger) checkForNewWhisperUsers { NSArray *currentUsers = [self getWhisperUsersFromContactsArray:[latestContactsById allValues]]; NSArray *newUsers = [self getNewItemsFrom:currentUsers comparedTo:[latestWhisperUsersById allValues]]; diff --git a/Signal/src/environment/SGNKeychainUtil.m b/Signal/src/environment/SGNKeychainUtil.m index 979f3fa75..90f3300c4 100644 --- a/Signal/src/environment/SGNKeychainUtil.m +++ b/Signal/src/environment/SGNKeychainUtil.m @@ -112,7 +112,7 @@ NSData *data = [self dataForKey:key]; if ([data length] != length) { - DDLogError(@"Length of data not matching. Got %lu, expected %u", [data length], length); + DDLogError(@"Length of data not matching. Got %lu, expected %u", (unsigned long)[data length], length); } return data; diff --git a/Signal/src/network/dns/DnsManager.m b/Signal/src/network/dns/DnsManager.m index 254e97750..c567fa106 100644 --- a/Signal/src/network/dns/DnsManager.m +++ b/Signal/src/network/dns/DnsManager.m @@ -67,8 +67,8 @@ void handleDnsCompleted(CFHostRef hostRef, CFHostInfoType typeInfo, const CFStre Boolean startedSuccess = CFHostStartInfoResolution(hostRef, kCFHostAddresses, &d->error); CFRelease(hostRef); if (!startedSuccess) { - [d->futureResultSource trySetFailure:[OperationFailed new:[NSString stringWithFormat:@"DNS query failed to start. Error code: %ld", - d->error.error]]]; + [d->futureResultSource trySetFailure:[OperationFailed new:[NSString stringWithFormat:@"DNS query failed to start. Error code: %d", + (int)d->error.error]]]; } [unlessCancelledToken whenCancelledTryCancel:d->futureResultSource]; diff --git a/Signal/src/network/http/HttpRequest.m b/Signal/src/network/http/HttpRequest.m index d84692315..7075d17d3 100644 --- a/Signal/src/network/http/HttpRequest.m +++ b/Signal/src/network/http/HttpRequest.m @@ -36,7 +36,7 @@ NSMutableDictionary* headers = [NSMutableDictionary dictionary]; if (optionalBody != nil) { - [headers setObject:[[NSNumber numberWithLongLong:[optionalBody length]] stringValue] forKey:@"Content-Length"]; + [headers setObject:[[NSNumber numberWithUnsignedInteger:[optionalBody length]] stringValue] forKey:@"Content-Length"]; } HttpRequest* s = [HttpRequest new]; @@ -58,7 +58,7 @@ NSMutableDictionary* headers = [NSMutableDictionary dictionary]; if (optionalBody != nil) { - [headers setObject:[[NSNumber numberWithLongLong:[optionalBody length]] stringValue] forKey:@"Content-Length"]; + [headers setObject:[[NSNumber numberWithUnsignedInteger:[optionalBody length]] stringValue] forKey:@"Content-Length"]; } [headers setObject:[HttpRequest computeBasicAuthorizationTokenForLocalNumber:localNumber andPassword:password] forKey:@"Authorization"]; @@ -81,7 +81,7 @@ NSMutableDictionary* headers = [NSMutableDictionary dictionary]; if (optionalBody != nil) { - [headers setObject:[[NSNumber numberWithLongLong:[optionalBody length]] stringValue] forKey:@"Content-Length"]; + [headers setObject:[[NSNumber numberWithUnsignedInteger:[optionalBody length]] stringValue] forKey:@"Content-Length"]; } [headers setObject:[HttpRequest computeOtpAuthorizationTokenForLocalNumber:localNumber andCounterValue:counter andPassword:password] forKey:@"Authorization"]; diff --git a/Signal/src/network/http/HttpResponse.m b/Signal/src/network/http/HttpResponse.m index 81101392f..2abb8d173 100644 --- a/Signal/src/network/http/HttpResponse.m +++ b/Signal/src/network/http/HttpResponse.m @@ -106,7 +106,7 @@ NSString* body = [self getOptionalBodyText]; if (body != nil) { [r addObject:@"Content-Length: "]; - [r addObject:[[NSNumber numberWithLongLong:[body length]] stringValue]]; + [r addObject:[[NSNumber numberWithUnsignedInteger:[body length]] stringValue]]; [r addObject:@"\r\n"]; [r addObject:body]; } else { @@ -120,8 +120,8 @@ } -(NSString*) description { - return [NSString stringWithFormat:@"%d %@%@", - statusCode, + return [NSString stringWithFormat:@"%lu %@%@", + (unsigned long)statusCode, statusText, ![self hasBody] ? @"" : [self hasEmptyBody] ? @" [empty body]" diff --git a/Signal/src/network/rtp/RtpPacket.m b/Signal/src/network/rtp/RtpPacket.m index aa54225d6..ec7656321 100644 --- a/Signal/src/network/rtp/RtpPacket.m +++ b/Signal/src/network/rtp/RtpPacket.m @@ -266,7 +266,7 @@ andSynchronizationSourceIdentifier:(uint32_t)synchronizedSourceIdentifier } -(NSData*) generateCcrcData { return [[contributingSourceIdentifiers map:^id(NSNumber* ccsrc) { - return [NSData dataWithBigEndianBytesOfUInt32:[ccsrc unsignedLongValue]]; + return [NSData dataWithBigEndianBytesOfUInt32:[ccsrc unsignedIntValue]]; }] concatDatas]; } -(NSData*) generateExtensionHeaderData { diff --git a/Signal/src/network/tcp/tls/Certificate.m b/Signal/src/network/tcp/tls/Certificate.m index 678173229..9e781b60a 100644 --- a/Signal/src/network/tcp/tls/Certificate.m +++ b/Signal/src/network/tcp/tls/Certificate.m @@ -49,8 +49,8 @@ CFRelease(anchorCerts); checkOperationDescribe(setAnchorResult == 0, - ([NSString stringWithFormat:@"SecTrustSetAnchorCertificates failed with error code: %ld", - setAnchorResult])); + ([NSString stringWithFormat:@"SecTrustSetAnchorCertificates failed with error code: %d", + (int)setAnchorResult])); } -(NSString *)description { diff --git a/Signal/src/network/tcp/tls/NetworkStream.m b/Signal/src/network/tcp/tls/NetworkStream.m index d28c7a903..1f15d47d9 100644 --- a/Signal/src/network/tcp/tls/NetworkStream.m +++ b/Signal/src/network/tcp/tls/NetworkStream.m @@ -74,7 +74,6 @@ NSStreamStatus status = [outputStream streamStatus]; if (status < NSStreamStatusOpen) return; if (status >= NSStreamStatusAtEnd) { - DDLogError(@"Status of the stream: %lu", status); [rawDataHandler handleError:@"Wrote to ended/closed/errored stream." relatedInfo:nil causedTermination:false]; @@ -83,15 +82,16 @@ while ([writeBuffer enqueuedLength] > 0 && [outputStream hasSpaceAvailable]) { NSData* data = [writeBuffer peekVolatileHeadOfData]; - int d = [outputStream write:[data bytes] maxLength:[data length]]; + NSInteger d = [outputStream write:[data bytes] maxLength:[data length]]; // reached destination buffer capacity? if (d == 0) break; - // error? if (d < 0) { id error = [outputStream streamError]; - if (error == nil) error = @"Unknown error when writing to stream."; + if (error == nil){ + error = @"Unknown error when writing to stream."; + } [rawDataHandler handleError:error relatedInfo:nil causedTermination:false]; return; } @@ -167,7 +167,7 @@ if ([inputStream streamError]) { error = [inputStream streamError]; - DDLogError(@"Error on incoming stream : %@"); + DDLogError(@"Error on incoming stream : %@", error); } else if ([outputStream streamError]){ error = [outputStream streamError]; DDLogError(@"Error on outgoing stream: %@", error); @@ -184,7 +184,7 @@ if (![[futureConnectedAndWritableSource forceGetResult] isEqual:@YES]) return; while ([inputStream hasBytesAvailable]) { - int numRead = [inputStream read:[readBuffer mutableBytes] maxLength:[readBuffer length]]; + NSInteger numRead = [inputStream read:[readBuffer mutableBytes] maxLength:[readBuffer length]]; if (numRead < 0) [self onErrorOccurred:@"Read Error"]; if (numRead <= 0) break; @@ -230,9 +230,9 @@ break; default: - [self onErrorOccurred:[NSString stringWithFormat:@"Unexpected %@ stream event: %d.", + [self onErrorOccurred:[NSString stringWithFormat:@"Unexpected %@ stream event: %lu.", isInputStream ? @"input" : @"output", - event]]; + (unsigned long)event]]; } } } diff --git a/Signal/src/network/tcp/tls/SecureEndPoint.m b/Signal/src/network/tcp/tls/SecureEndPoint.m index 18c7186cb..c5dd6c88a 100644 --- a/Signal/src/network/tcp/tls/SecureEndPoint.m +++ b/Signal/src/network/tcp/tls/SecureEndPoint.m @@ -69,7 +69,7 @@ SecTrustResultType trustResult = kSecTrustResultInvalid; OSStatus evalResult = SecTrustEvaluate(trust, &trustResult); checkSecurityOperation(evalResult == 0, - ([NSString stringWithFormat:@"NetworkStream: SecTrustEvaluate failed with error code: %ld", evalResult])); + ([NSString stringWithFormat:@"NetworkStream: SecTrustEvaluate failed with error code: %d", (int)evalResult])); checkSecurityOperation(trustResult != kSecTrustResultProceed, @"Unexpected: User approved certificate somehow? Failing safe."); checkSecurityOperation(trustResult == kSecTrustResultUnspecified, diff --git a/Signal/src/phone/signaling/CallConnectUtil_Server.m b/Signal/src/phone/signaling/CallConnectUtil_Server.m index 3f6b0f695..ef25cf4e0 100644 --- a/Signal/src/phone/signaling/CallConnectUtil_Server.m +++ b/Signal/src/phone/signaling/CallConnectUtil_Server.m @@ -126,8 +126,7 @@ Future* futureEndPoint = [futureDnsResult then:^(NSArray* ipAddresses) { require([ipAddresses count] > 0); - // @todo: is this the correct way to pick an address (random)? What about low latency? Different each time? dns beforehand? - IpAddress* address = [ipAddresses objectAtIndex:arc4random_uniform([ipAddresses count])]; + IpAddress* address = [ipAddresses objectAtIndex:arc4random_uniform((unsigned int)[ipAddresses count])]; return [IpEndPoint ipEndPointAtAddress:address onPort:sessionDescriptor.relayUdpPort]; }]; diff --git a/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilter.m b/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilter.m index 4da3528d2..2cb2c2e92 100644 --- a/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilter.m +++ b/Signal/src/phone/signaling/number directory/PhoneNumberDirectoryFilter.m @@ -40,7 +40,7 @@ NSString* hashCountHeader = [[response getHeaders] objectForKey:HASH_COUNT_HEADER_KEY]; checkOperation(hashCountHeader != nil); - int hashCountValue = [hashCountHeader integerValue]; + int hashCountValue = [hashCountHeader intValue]; checkOperation(hashCountValue > 0); NSData* responseBody = [response getOptionalBodyData]; diff --git a/Signal/src/profiling/CategorizingLogger.m b/Signal/src/profiling/CategorizingLogger.m index 860b60fe8..f83c8ea89 100644 --- a/Signal/src/profiling/CategorizingLogger.m +++ b/Signal/src/profiling/CategorizingLogger.m @@ -60,7 +60,7 @@ [self log:@"JitterQueue arrival" details:[NSString stringWithFormat:@"sequence: %d", sequenceNumber]]; } -(void) notifyDequeue:(uint16_t)sequenceNumber withRemainingEnqueuedItemCount:(NSUInteger)remainingCount { - [self log:@"JitterQueue dequeue" details:[NSString stringWithFormat:@"sequence: %d, remaining: %d", sequenceNumber, remainingCount]]; + [self log:@"JitterQueue dequeue" details:[NSString stringWithFormat:@"sequence: %d, remaining: %lu", sequenceNumber, (unsigned long)remainingCount]]; } -(void) notifyBadArrival:(uint16_t)sequenceNumber ofType:(enum JitterBadArrivalType)arrivalType { [self log:@"JitterQueue bad arrival" details:[NSString stringWithFormat:@"sequence: %d, arrival type: %d", sequenceNumber, arrivalType]]; diff --git a/Signal/src/util/Crc32.m b/Signal/src/util/Crc32.m index a4d8cedb4..eb17a68fb 100644 --- a/Signal/src/util/Crc32.m +++ b/Signal/src/util/Crc32.m @@ -31,7 +31,7 @@ void generateCRC32Table(uint32_t *pTable, uint32_t poly) { uint32_t crc = seed; uint8_t *pBytes = (uint8_t *)[self bytes]; - uint32_t length = [self length]; + NSUInteger length = [self length]; while (length--) { crc = (crc>>8) ^ pTable[(crc & 0xFF) ^ *pBytes++]; diff --git a/Signal/src/util/collections/CyclicalBuffer.m b/Signal/src/util/collections/CyclicalBuffer.m index 7caabd976..818d9a3b0 100644 --- a/Signal/src/util/collections/CyclicalBuffer.m +++ b/Signal/src/util/collections/CyclicalBuffer.m @@ -2,7 +2,7 @@ #import "Constraints.h" #import "Util.h" -#define INITIAL_CAPACITY 100 +#define INITIAL_CAPACITY 100 // The buffer size can not be longer than an unsigned int. @implementation CyclicalBuffer @@ -55,7 +55,7 @@ -(void) discard:(NSUInteger)length { require(length <= count); count -= length; - readOffset = (readOffset + length)%[buffer length]; + readOffset = (readOffset + length)%(unsigned int)[buffer length]; } -(NSData*) peekDataWithLength:(NSUInteger)length{ diff --git a/Signal/src/view controllers/InCallViewController.m b/Signal/src/view controllers/InCallViewController.m index 0528fb2d7..8848451be 100644 --- a/Signal/src/view controllers/InCallViewController.m +++ b/Signal/src/view controllers/InCallViewController.m @@ -119,7 +119,7 @@ static NSInteger connectingFlashCounter = 0; - (void)rotateConnectingIndicator { [_connectingIndicatorImageView setImage:[UIImage imageNamed:SPINNER_RINGING_IMAGE_NAME]]; [UIView animateWithDuration:RINGING_ROTATION_DURATION delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{ - _connectingIndicatorImageView.transform = CGAffineTransformRotate(_connectingIndicatorImageView.transform, M_PI_2); + _connectingIndicatorImageView.transform = CGAffineTransformRotate(_connectingIndicatorImageView.transform, (float)M_PI_2); } completion:nil]; } diff --git a/Signal/src/view controllers/TabBarParentViewController.m b/Signal/src/view controllers/TabBarParentViewController.m index 1149d96d9..a78401443 100644 --- a/Signal/src/view controllers/TabBarParentViewController.m +++ b/Signal/src/view controllers/TabBarParentViewController.m @@ -173,7 +173,7 @@ CGRectGetMinY(_tabBarInboxButton.frame), CGRectGetWidth(_tabBarInboxButton.frame), CGRectGetHeight(_tabBarInboxButton.frame) - CGRectGetHeight(_missedCallCountLabel.frame)); - _missedCallCountLabel.text = [NSString stringWithFormat:@"%d",missedCallCount]; + _missedCallCountLabel.text = [NSString stringWithFormat:@"%lu",(unsigned long)missedCallCount]; _missedCallCountLabel.hidden = NO; } else { _tabBarInboxButton.frame = CGRectMake(CGRectGetMinX(_tabBarInboxButton.frame), diff --git a/Signal/src/view controllers/xibs/RegisterViewController.xib b/Signal/src/view controllers/xibs/RegisterViewController.xib index 7046b7985..6615fe04f 100644 --- a/Signal/src/view controllers/xibs/RegisterViewController.xib +++ b/Signal/src/view controllers/xibs/RegisterViewController.xib @@ -1,5 +1,5 @@ - + @@ -40,7 +40,7 @@ - +