diff --git a/Signal/src/ViewControllers/ConversationView/Cells/ConversationViewCell.m b/Signal/src/ViewControllers/ConversationView/Cells/ConversationViewCell.m index de62f0786d..fe1df0749a 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/ConversationViewCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/ConversationViewCell.m @@ -21,12 +21,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)loadForDisplay { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); } - (CGSize)cellSize { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return CGSizeZero; } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 425d7105e5..78abfaee75 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2147,7 +2147,7 @@ typedef enum : NSUInteger { return; } if (![self.thread isKindOfClass:[TSContactThread class]]) { - OWSFail(@"%@ unexpected thread: %@ in %s", self.logTag, self.thread, __PRETTY_FUNCTION__); + OWSFail(@"%@ unexpected thread: %@ in %s", self.logTag, [self.thread class], __PRETTY_FUNCTION__); return; } TSContactThread *contactThread = (TSContactThread *)self.thread; @@ -2167,7 +2167,7 @@ typedef enum : NSUInteger { { // This is accessed via the contact offer. Group whitelisting happens via a different interaction. if (![self.thread isKindOfClass:[TSContactThread class]]) { - OWSFail(@"%@ unexpected thread: %@ in %s", self.logTag, self.thread, __PRETTY_FUNCTION__); + OWSFail(@"%@ unexpected thread: %@ in %s", self.logTag, [self.thread class], __PRETTY_FUNCTION__); return; } TSContactThread *contactThread = (TSContactThread *)self.thread; @@ -2865,12 +2865,10 @@ typedef enum : NSUInteger { NSError *isDirectoryError; [url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:&isDirectoryError]; if (isDirectoryError) { - OWSFail(@"%@ Determining if picked document at url: %@ was a directory failed with error: %@", - self.logTag, - url, - isDirectoryError); + OWSFail( + @"%@ Determining if picked document was a directory failed with error: %@", self.logTag, isDirectoryError); } else if ([isDirectory boolValue]) { - DDLogInfo(@"%@ User picked directory at url: %@", self.logTag, url); + DDLogInfo(@"%@ User picked directory.", self.logTag); dispatch_async(dispatch_get_main_queue(), ^{ [OWSAlerts @@ -2886,7 +2884,7 @@ typedef enum : NSUInteger { NSString *filename = url.lastPathComponent; if (!filename) { - OWSFail(@"%@ Unable to determine filename from url: %@", self.logTag, url); + OWSFail(@"%@ Unable to determine filename", self.logTag); filename = NSLocalizedString( @"ATTACHMENT_DEFAULT_FILENAME", @"Generic filename for an attachment with no known name"); } @@ -2895,7 +2893,7 @@ typedef enum : NSUInteger { OWSAssert(filename); DataSource *_Nullable dataSource = [DataSourcePath dataSourceWithURL:url shouldDeleteOnDeallocation:NO]; if (!dataSource) { - OWSFail(@"%@ attachment data was unexpectedly empty for picked document url: %@", self.logTag, url); + OWSFail(@"%@ attachment data was unexpectedly empty for picked document", self.logTag); dispatch_async(dispatch_get_main_queue(), ^{ [OWSAlerts showAlertWithTitle:NSLocalizedString(@"ATTACHMENT_PICKER_DOCUMENTS_FAILED_ALERT_TITLE", @@ -3020,7 +3018,7 @@ typedef enum : NSUInteger { [assetslibrary assetForURL:referenceURL resultBlock:resultblock failureBlock:^(NSError *error) { - OWSFail(@"Error retrieving filename for asset: %@", error); + OWSCFail(@"Error retrieving filename for asset: %@", error); }]; } @@ -3378,7 +3376,7 @@ typedef enum : NSUInteger { if (hasMalformedRowChange) { // These errors seems to be very rare; they can only be reproduced // using the more extreme actions in the debug UI. - OWSProdLogAndFail(@"%@ hasMalformedRowChange", self.logTag); + OWSFail(@"%@ hasMalformedRowChange", self.logTag); [self resetContentAndLayout]; [self updateLastVisibleTimestamp]; [self scrollToBottomAnimated:NO]; @@ -4853,16 +4851,19 @@ typedef enum : NSUInteger { TSInteraction *interaction = [viewTransaction objectAtRow:row inSection:0 withMappings:self.messageMappings]; if (!interaction) { - OWSFail(@"%@ missing interaction in message mappings: %zd / %zd.", self.logTag, row, count); + OWSFail(@"%@ missing interaction in message mappings: %lu / %lu.", + self.logTag, + (unsigned long)row, + (unsigned long)count); // TODO: Add analytics. continue; } if (!interaction.uniqueId) { - OWSFail(@"%@ invalid interaction in message mappings: %zd / %zd: %@.", + OWSFail(@"%@ invalid interaction in message mappings: %lu / %lu: %@.", self.logTag, - row, - count, - interaction.description); + (unsigned long)row, + (unsigned long)count, + interaction); // TODO: Add analytics. continue; } @@ -5136,7 +5137,7 @@ typedef enum : NSUInteger { - (nullable ConversationViewItem *)viewItemForIndex:(NSInteger)index { if (index < 0 || index >= (NSInteger)self.viewItems.count) { - OWSFail(@"%@ Invalid view item index: %zd", self.logTag, index); + OWSFail(@"%@ Invalid view item index: %lu", self.logTag, (unsigned long)index); return nil; } return self.viewItems[(NSUInteger)index]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index c4d8900d95..c1729513dc 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -716,7 +716,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) } NSData *data = [NSData dataWithContentsOfURL:[self.attachmentStream mediaURL]]; if (!data) { - OWSFail(@"%@ Could not load attachment data: %@", self.logTag, [self.attachmentStream mediaURL]); + OWSFail(@"%@ Could not load attachment data", self.logTag); return; } [UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType]; @@ -817,7 +817,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) case OWSMessageCellType_AnimatedImage: { NSData *data = [NSData dataWithContentsOfURL:[self.attachmentStream mediaURL]]; if (!data) { - OWSFail(@"%@ Could not load image data: %@", self.logTag, [self.attachmentStream mediaURL]); + OWSFail(@"%@ Could not load image data", self.logTag); return; } ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAction.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAction.m index 2f54d609f0..9d0cef5280 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAction.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAction.m @@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(success); OWSAssert(failure); - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); success(); } diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIPage.m b/Signal/src/ViewControllers/DebugUI/DebugUIPage.m index 4b0601c4a3..507c4a6e76 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIPage.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIPage.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import "DebugUIPage.h" diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index f19b85795a..7b460a8995 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -398,7 +398,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)stringForDate:(nullable NSDate *)date { if (date == nil) { - OWSProdLogAndFail(@"%@ date was unexpectedly nil", self.logTag); + OWSFail(@"%@ date was unexpectedly nil", self.logTag); return @""; } diff --git a/Signal/src/ViewControllers/MediaDetailViewController.m b/Signal/src/ViewControllers/MediaDetailViewController.m index 24fb2baa63..fc28337a51 100644 --- a/Signal/src/ViewControllers/MediaDetailViewController.m +++ b/Signal/src/ViewControllers/MediaDetailViewController.m @@ -262,7 +262,7 @@ NS_ASSUME_NONNULL_BEGIN { NSFileManager *fileManager = [NSFileManager defaultManager]; if (![fileManager fileExistsAtPath:[self.attachmentUrl path]]) { - OWSFail(@"%@ Missing video file: %@", self.logTag, self.attachmentStream.mediaURL); + OWSFail(@"%@ Missing video file", self.logTag); } OWSVideoPlayer *player = [[OWSVideoPlayer alloc] initWithUrl:self.attachmentUrl]; diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index 901b34340c..a53fb51df4 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -367,16 +367,22 @@ NS_ASSUME_NONNULL_BEGIN [contents addSection:section]; } contents.sectionForSectionIndexTitleBlock = ^NSInteger(NSString *_Nonnull title, NSInteger index) { + typeof(self) strongSelf = weakSelf; + if (!strongSelf) { + return 0; + } + // Offset the collation section to account for the noncollated sections. - NSInteger sectionIndex = [self.collation sectionForSectionIndexTitleAtIndex:index] + noncollatedSections; + NSInteger sectionIndex = + [strongSelf.collation sectionForSectionIndexTitleAtIndex:index] + noncollatedSections; if (sectionIndex < 0) { // Sentinal in case we change our section ordering in a surprising way. - OWSFail(@"Unexpected negative section index"); + OWSCFail(@"Unexpected negative section index"); return 0; } if (sectionIndex >= (NSInteger)contents.sections.count) { // Sentinal in case we change our section ordering in a surprising way. - OWSFail(@"Unexpectedly large index"); + OWSCFail(@"Unexpectedly large index"); return 0; } @@ -384,7 +390,12 @@ NS_ASSUME_NONNULL_BEGIN }; contents.sectionIndexTitlesForTableViewBlock = ^NSArray *_Nonnull { - return self.collation.sectionTitles; + typeof(self) strongSelf = weakSelf; + if (!strongSelf) { + return @[]; + } + + return strongSelf.collation.sectionTitles; }; } diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index c4fbde4820..4b1ad18e32 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -931,7 +931,7 @@ const CGFloat kIconViewLength = 24; return; } if (![self.thread isKindOfClass:[TSContactThread class]]) { - OWSFail(@"%@ unexpected thread: %@ in %s", self.logTag, self.thread, __PRETTY_FUNCTION__); + OWSFail(@"%@ unexpected thread: %@ in %s", self.logTag, [self.thread class], __PRETTY_FUNCTION__); return; } diff --git a/Signal/src/environment/NotificationsManager.m b/Signal/src/environment/NotificationsManager.m index 568e8d5d0d..f70e559a69 100644 --- a/Signal/src/environment/NotificationsManager.m +++ b/Signal/src/environment/NotificationsManager.m @@ -208,8 +208,7 @@ OWSAssert(message); if (!thread) { - OWSProdLogAndFail( - @"%@ unexpected notification not associated with a thread: %@.", self.logTag, [message class]); + OWSFail(@"%@ unexpected notification not associated with a thread: %@.", self.logTag, [message class]); [self notifyUserForThreadlessErrorMessage:message transaction:transaction]; return; } diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index f8aeb69134..1585a192a2 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -134,7 +134,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe DDLogInfo(@"%@ received content-available push", self.logTag); // If we want to re-introduce silent pushes we can remove this assert. - OWSProdLogAndFail(@"Unexpected content-available push."); + OWSFail(@"Unexpected content-available push."); [AppReadiness runNowOrWhenAppIsReady:^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ @@ -146,7 +146,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe - (void)presentOncePerActivationConversationWithThreadId:(NSString *)threadId { if (self.hasPresentedConversationSinceLastDeactivation) { - OWSProdLogAndFail(@"%@ in %s refusing to present conversation: %@ multiple times.", + OWSFail(@"%@ in %s refusing to present conversation: %@ multiple times.", self.logTag, __PRETTY_FUNCTION__, threadId); @@ -167,7 +167,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe if (threadId) { [self presentOncePerActivationConversationWithThreadId:threadId]; } else { - OWSProdLogAndFail(@"%@ threadId was unexpectedly nil in %s", self.logTag, __PRETTY_FUNCTION__); + OWSFail(@"%@ threadId was unexpectedly nil in %s", self.logTag, __PRETTY_FUNCTION__); } // We only want to receive a single local notification per launch. @@ -275,18 +275,16 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe if (threadId) { [self presentOncePerActivationConversationWithThreadId:threadId]; } else { - OWSProdLogAndFail( - @"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier); + OWSFail(@"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier); } completionHandler(); } else { - OWSProdLogAndFail(@"%@ Unhandled action with identifier: %@", self.logTag, identifier); + OWSFail(@"%@ Unhandled action with identifier: %@", self.logTag, identifier); NSString *threadId = notification.userInfo[Signal_Thread_UserInfo_Key]; if (threadId) { [self presentOncePerActivationConversationWithThreadId:threadId]; } else { - OWSProdLogAndFail( - @"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier); + OWSFail(@"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier); } completionHandler(); } @@ -296,7 +294,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe { NSString *threadId = userInfo[Signal_Thread_UserInfo_Key]; if (!threadId) { - OWSProdLogAndFail(@"%@ missing thread id for notification.", self.logTag); + OWSFail(@"%@ missing thread id for notification.", self.logTag); return; } diff --git a/Signal/src/util/OWSBackup.m b/Signal/src/util/OWSBackup.m index 1bc178db68..c477b36d0c 100644 --- a/Signal/src/util/OWSBackup.m +++ b/Signal/src/util/OWSBackup.m @@ -492,7 +492,7 @@ NS_ASSUME_NONNULL_BEGIN [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { id ext = [transaction ext:TSLazyRestoreAttachmentsDatabaseViewExtensionName]; if (!ext) { - OWSProdLogAndFail(@"%@ Could not load database view.", self.logTag); + OWSFail(@"%@ Could not load database view.", self.logTag); return; } @@ -500,7 +500,7 @@ NS_ASSUME_NONNULL_BEGIN usingBlock:^( NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) { if (![object isKindOfClass:[TSAttachmentStream class]]) { - OWSProdLogAndFail(@"%@ Unexpected object: %@ in collection:%@", + OWSFail(@"%@ Unexpected object: %@ in collection:%@", self.logTag, [object class], collection); @@ -508,7 +508,7 @@ NS_ASSUME_NONNULL_BEGIN } TSAttachmentStream *attachmentStream = object; if (!attachmentStream.lazyRestoreFragment) { - OWSProdLogAndFail(@"%@ Invalid object: %@ in collection:%@", + OWSFail(@"%@ Invalid object: %@ in collection:%@", self.logTag, [object class], collection); @@ -526,7 +526,7 @@ NS_ASSUME_NONNULL_BEGIN [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { id ext = [transaction ext:TSLazyRestoreAttachmentsDatabaseViewExtensionName]; if (!ext) { - OWSProdLogAndFail(@"%@ Could not load database view.", self.logTag); + OWSFail(@"%@ Could not load database view.", self.logTag); return; } diff --git a/Signal/src/util/OWSBackupExportJob.m b/Signal/src/util/OWSBackupExportJob.m index fc01ecac5d..97ddab4c46 100644 --- a/Signal/src/util/OWSBackupExportJob.m +++ b/Signal/src/util/OWSBackupExportJob.m @@ -117,7 +117,7 @@ NS_ASSUME_NONNULL_BEGIN NSData *_Nullable data = [NSKeyedArchiver archivedDataWithRootObject:object]; if (!data) { - OWSProdLogAndFail(@"%@ couldn't serialize database object: %@", self.logTag, [object class]); + OWSFail(@"%@ couldn't serialize database object: %@", self.logTag, [object class]); return NO; } @@ -131,7 +131,7 @@ NS_ASSUME_NONNULL_BEGIN NSError *error; SignalIOSProtoBackupSnapshotBackupEntity *_Nullable entity = [entityBuilder buildAndReturnError:&error]; if (!entity || error) { - OWSProdLogAndFail(@"%@ couldn't build proto: %@", self.logTag, error); + OWSFail(@"%@ couldn't build proto: %@", self.logTag, error); return NO; } @@ -165,7 +165,7 @@ NS_ASSUME_NONNULL_BEGIN NSError *error; NSData *_Nullable uncompressedData = [self.backupSnapshotBuilder buildSerializedDataAndReturnError:&error]; if (!uncompressedData || error) { - OWSProdLogAndFail(@"%@ couldn't serialize proto: %@", self.logTag, error); + OWSFail(@"%@ couldn't serialize proto: %@", self.logTag, error); return NO; } @@ -173,7 +173,7 @@ NS_ASSUME_NONNULL_BEGIN self.backupSnapshotBuilder = nil; self.cachedItemCount = 0; if (!uncompressedData) { - OWSProdLogAndFail(@"%@ couldn't convert database snapshot to data.", self.logTag); + OWSFail(@"%@ couldn't convert database snapshot to data.", self.logTag); return NO; } @@ -181,7 +181,7 @@ NS_ASSUME_NONNULL_BEGIN OWSBackupEncryptedItem *_Nullable encryptedItem = [self.backupIO encryptDataAsTempFile:compressedData]; if (!encryptedItem) { - OWSProdLogAndFail(@"%@ couldn't encrypt database snapshot.", self.logTag); + OWSFail(@"%@ couldn't encrypt database snapshot.", self.logTag); return NO; } @@ -256,7 +256,6 @@ NS_ASSUME_NONNULL_BEGIN NSString *attachmentsDirPath = [TSAttachmentStream attachmentsFolder]; if (![self.attachmentFilePath hasPrefix:attachmentsDirPath]) { - DDLogError(@"%@ attachment has unexpected path.", self.logTag); OWSFail(@"%@ attachment has unexpected path: %@", self.logTag, self.attachmentFilePath); return NO; } @@ -269,7 +268,6 @@ NS_ASSUME_NONNULL_BEGIN OWSBackupEncryptedItem *_Nullable encryptedItem = [self.backupIO encryptFileAsTempFile:self.attachmentFilePath]; if (!encryptedItem) { - DDLogError(@"%@ attachment could not be encrypted.", self.logTag); OWSFail(@"%@ attachment could not be encrypted: %@", self.logTag, self.attachmentFilePath); return NO; } @@ -401,7 +399,7 @@ NS_ASSUME_NONNULL_BEGIN DDLogVerbose(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); if (![self ensureJobTempDir]) { - OWSProdLogAndFail(@"%@ Could not create jobTempDirPath.", self.logTag); + OWSFail(@"%@ Could not create jobTempDirPath.", self.logTag); return completion(NO); } @@ -473,7 +471,7 @@ NS_ASSUME_NONNULL_BEGIN YapDatabaseConnection *_Nullable dbConnection = self.primaryStorage.newDatabaseConnection; if (!dbConnection) { - OWSProdLogAndFail(@"%@ Could not create dbConnection.", self.logTag); + OWSFail(@"%@ Could not create dbConnection.", self.logTag); return NO; } @@ -503,7 +501,7 @@ NS_ASSUME_NONNULL_BEGIN return; } if (![object isKindOfClass:expectedClass]) { - OWSProdLogAndFail(@"%@ unexpected class: %@", self.logTag, [object class]); + OWSFail(@"%@ unexpected class: %@", self.logTag, [object class]); return; } TSYapDatabaseObject *entity = object; @@ -600,7 +598,7 @@ NS_ASSUME_NONNULL_BEGIN @autoreleasepool { if (![exportStream flush]) { - OWSProdLogAndFail(@"%@ Could not flush database snapshots.", self.logTag); + OWSFail(@"%@ Could not flush database snapshots.", self.logTag); return NO; } } @@ -914,7 +912,7 @@ NS_ASSUME_NONNULL_BEGIN NSData *_Nullable jsonData = [NSJSONSerialization dataWithJSONObject:json options:NSJSONWritingPrettyPrinted error:&error]; if (!jsonData || error) { - OWSProdLogAndFail(@"%@ error encoding manifest file: %@", self.logTag, error); + OWSFail(@"%@ error encoding manifest file: %@", self.logTag, error); return nil; } return [self.backupIO encryptDataAsTempFile:jsonData encryptionKey:self.delegate.backupEncryptionKey]; diff --git a/Signal/src/util/OWSBackupIO.m b/Signal/src/util/OWSBackupIO.m index 4575b2ff5d..fda6b027f9 100644 --- a/Signal/src/util/OWSBackupIO.m +++ b/Signal/src/util/OWSBackupIO.m @@ -53,7 +53,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA { NSString *filePath = [self generateTempFilePath]; if (![OWSFileSystem ensureFileExists:filePath]) { - OWSProdLogAndFail(@"%@ could not create temp file.", self.logTag); + OWSFail(@"%@ could not create temp file.", self.logTag); return nil; } return filePath; @@ -80,7 +80,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA // TODO: Encrypt the file without loading it into memory. NSData *_Nullable srcData = [NSData dataWithContentsOfFile:srcFilePath]; if (srcData.length < 1) { - OWSProdLogAndFail(@"%@ could not load file into memory for encryption.", self.logTag); + OWSFail(@"%@ could not load file into memory for encryption.", self.logTag); return nil; } return [self encryptDataAsTempFile:srcData encryptionKey:encryptionKey]; @@ -114,7 +114,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA NSError *error; BOOL success = [encryptedData writeToFile:dstFilePath options:NSDataWritingAtomic error:&error]; if (!success || error) { - OWSProdLogAndFail(@"%@ error writing encrypted data: %@", self.logTag, error); + OWSFail(@"%@ error writing encrypted data: %@", self.logTag, error); return nil; } [OWSFileSystem protectFileOrFolderAtPath:dstFilePath]; @@ -146,7 +146,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA NSError *error; BOOL success = [data writeToFile:dstFilePath options:NSDataWritingAtomic error:&error]; if (!success || error) { - OWSProdLogAndFail(@"%@ error writing decrypted data: %@", self.logTag, error); + OWSFail(@"%@ error writing decrypted data: %@", self.logTag, error); return NO; } [OWSFileSystem protectFileOrFolderAtPath:dstFilePath]; @@ -169,7 +169,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA NSData *_Nullable srcData = [NSData dataWithContentsOfFile:srcFilePath]; if (srcData.length < 1) { - OWSProdLogAndFail(@"%@ could not load file into memory for decryption.", self.logTag); + OWSFail(@"%@ could not load file into memory for decryption.", self.logTag); return nil; } @@ -201,7 +201,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA @autoreleasepool { if (!srcData) { - OWSProdLogAndFail(@"%@ missing unencrypted data.", self.logTag); + OWSFail(@"%@ missing unencrypted data.", self.logTag); return nil; } @@ -238,7 +238,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA @autoreleasepool { if (!srcData) { - OWSProdLogAndFail(@"%@ missing unencrypted data.", self.logTag); + OWSFail(@"%@ missing unencrypted data.", self.logTag); return nil; } diff --git a/Signal/src/util/OWSBackupImportJob.m b/Signal/src/util/OWSBackupImportJob.m index e7421e4099..1f678f7867 100644 --- a/Signal/src/util/OWSBackupImportJob.m +++ b/Signal/src/util/OWSBackupImportJob.m @@ -175,7 +175,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe DDLogVerbose(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); if (![self ensureJobTempDir]) { - OWSProdLogAndFail(@"%@ Could not create jobTempDirPath.", self.logTag); + OWSFail(@"%@ Could not create jobTempDirPath.", self.logTag); return NO; } @@ -310,7 +310,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe YapDatabaseConnection *_Nullable dbConnection = self.primaryStorage.newDatabaseConnection; if (!dbConnection) { - OWSProdLogAndFail(@"%@ Could not create dbConnection.", self.logTag); + OWSFail(@"%@ Could not create dbConnection.", self.logTag); return completion(NO); } diff --git a/Signal/src/util/OWSBackupJob.m b/Signal/src/util/OWSBackupJob.m index 990cf0e307..52c81f8d69 100644 --- a/Signal/src/util/OWSBackupJob.m +++ b/Signal/src/util/OWSBackupJob.m @@ -84,7 +84,7 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService"; self.jobTempDirPath = [temporaryDirectory stringByAppendingPathComponent:[NSUUID UUID].UUIDString]; if (![OWSFileSystem ensureDirectoryExists:self.jobTempDirPath]) { - OWSProdLogAndFail(@"%@ Could not create jobTempDirPath.", self.logTag); + OWSFail(@"%@ Could not create jobTempDirPath.", self.logTag); return NO; } return YES; @@ -126,7 +126,7 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService"; - (void)failWithError:(NSError *)error { - OWSProdLogAndFail(@"%@ %s %@", self.logTag, __PRETTY_FUNCTION__, error); + OWSFail(@"%@ %s %@", self.logTag, __PRETTY_FUNCTION__, error); dispatch_async(dispatch_get_main_queue(), ^{ OWSAssert(!self.hasSucceeded); @@ -178,7 +178,7 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService"; failure:^(NSError *error) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // The manifest file is critical so any error downloading it is unrecoverable. - OWSProdLogAndFail(@"%@ Could not download manifest.", weakSelf.logTag); + OWSCFail(@"%@ Could not download manifest.", weakSelf.logTag); failure(error); }); }]; @@ -203,7 +203,7 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService"; NSData *_Nullable manifestDataDecrypted = [backupIO decryptDataAsData:manifestDataEncrypted encryptionKey:self.delegate.backupEncryptionKey]; if (!manifestDataDecrypted) { - OWSProdLogAndFail(@"%@ Could not decrypt manifest.", self.logTag); + OWSFail(@"%@ Could not decrypt manifest.", self.logTag); return failure(); } @@ -211,7 +211,7 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService"; NSDictionary *_Nullable json = [NSJSONSerialization JSONObjectWithData:manifestDataDecrypted options:0 error:&error]; if (![json isKindOfClass:[NSDictionary class]]) { - OWSProdLogAndFail(@"%@ Could not download manifest.", self.logTag); + OWSFail(@"%@ Could not download manifest.", self.logTag); return failure(); } @@ -241,18 +241,18 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService"; OWSAssert(key.length); if (![json isKindOfClass:[NSDictionary class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid data: %@.", self.logTag, key); + OWSFail(@"%@ manifest has invalid data.", self.logTag); return nil; } NSArray *itemMaps = json[key]; if (![itemMaps isKindOfClass:[NSArray class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid data: %@.", self.logTag, key); + OWSFail(@"%@ manifest has invalid data.", self.logTag); return nil; } NSMutableArray *items = [NSMutableArray new]; for (NSDictionary *itemMap in itemMaps) { if (![itemMap isKindOfClass:[NSDictionary class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid item: %@.", self.logTag, key); + OWSFail(@"%@ manifest has invalid item.", self.logTag); return nil; } NSString *_Nullable recordName = itemMap[kOWSBackup_ManifestKey_RecordName]; @@ -261,31 +261,33 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService"; NSString *_Nullable attachmentId = itemMap[kOWSBackup_ManifestKey_AttachmentId]; NSNumber *_Nullable uncompressedDataLength = itemMap[kOWSBackup_ManifestKey_DataSize]; if (![recordName isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid recordName: %@.", self.logTag, key); + OWSFail(@"%@ manifest has invalid recordName: %@.", self.logTag, recordName); return nil; } if (![encryptionKeyString isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid encryptionKey: %@.", self.logTag, key); + OWSFail(@"%@ manifest has invalid encryptionKey.", self.logTag); return nil; } // relativeFilePath is an optional field. if (relativeFilePath && ![relativeFilePath isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid relativeFilePath: %@.", self.logTag, key); + DDLogDebug(@"%@ manifest has invalid relativeFilePath: %@.", self.logTag, relativeFilePath); + OWSFail(@"%@ manifest has invalid relativeFilePath", self.logTag); return nil; } // attachmentId is an optional field. if (attachmentId && ![attachmentId isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid attachmentId: %@.", self.logTag, key); + DDLogDebug(@"%@ manifest has invalid attachmentId: %@.", self.logTag, attachmentId); + OWSFail(@"%@ manifest has invalid attachmentId", self.logTag); return nil; } NSData *_Nullable encryptionKey = [NSData dataFromBase64String:encryptionKeyString]; if (!encryptionKey) { - OWSProdLogAndFail(@"%@ manifest has corrupt encryptionKey: %@.", self.logTag, key); + OWSFail(@"%@ manifest has corrupt encryptionKey", self.logTag); return nil; } // uncompressedDataLength is an optional field. if (uncompressedDataLength && ![uncompressedDataLength isKindOfClass:[NSNumber class]]) { - OWSProdLogAndFail(@"%@ manifest has invalid uncompressedDataLength: %@.", self.logTag, key); + OWSFail(@"%@ manifest has invalid uncompressedDataLength: %@.", self.logTag, uncompressedDataLength); return nil; } diff --git a/Signal/src/util/OWSOrphanDataCleaner.m b/Signal/src/util/OWSOrphanDataCleaner.m index 133a3f6c5d..5f47d162e7 100644 --- a/Signal/src/util/OWSOrphanDataCleaner.m +++ b/Signal/src/util/OWSOrphanDataCleaner.m @@ -66,9 +66,10 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); NSNumber *fileSize = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error][NSFileSize]; if (error) { if ([error.domain isEqualToString:NSCocoaErrorDomain] && error.code == 260) { - DDLogWarn(@"%@ can't find size of missing file: %@", self.logTag, filePath); + DDLogWarn(@"%@ can't find size of missing file.", self.logTag); + DDLogDebug(@"%@ can't find size of missing file: %@", self.logTag, filePath); } else { - OWSProdLogAndFail(@"%@ attributesOfItemAtPath: %@ error: %@", self.logTag, filePath, error); + OWSFail(@"%@ attributesOfItemAtPath: %@ error: %@", self.logTag, filePath, error); } return 0; } @@ -96,7 +97,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); NSError *error; NSArray *fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dirPath error:&error]; if (error) { - OWSProdLogAndFail(@"%@ contentsOfDirectoryAtPath error: %@", self.logTag, error); + OWSFail(@"%@ contentsOfDirectoryAtPath error: %@", self.logTag, error); return [NSSet new]; } for (NSString *fileName in fileNames) { @@ -230,7 +231,8 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); NSError *error; NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error]; if (!attributes || error) { - OWSProdLogAndFail(@"%@ Could not get attributes of file at: %@", self.logTag, filePath); + DDLogDebug(@"%@ Could not get attributes of file at: %@", self.logTag, filePath); + OWSFail(@"%@ Could not get attributes of file", self.logTag); continue; } DDLogVerbose(@"%@ temp file: %@, %@", @@ -318,7 +320,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); if (filePath) { [allAttachmentFilePaths addObject:filePath]; } else { - OWSProdLogAndFail(@"%@ attachment has no file path.", self.logTag); + OWSFail(@"%@ attachment has no file path.", self.logTag); } NSString *_Nullable thumbnailPath = [attachmentStream thumbnailPath]; @@ -472,11 +474,11 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); OWSAssert(databaseConnection); if (!AppReadiness.isAppReady) { - OWSProdLogAndFail(@"%@ can't audit orphan data until app is ready.", self.logTag); + OWSFail(@"%@ can't audit orphan data until app is ready.", self.logTag); return; } if (!CurrentAppContext().isMainApp) { - OWSProdLogAndFail(@"%@ can't audit orphan data in app extensions.", self.logTag); + OWSFail(@"%@ can't audit orphan data in app extensions.", self.logTag); return; } @@ -674,7 +676,8 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); NSError *error; NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error]; if (!attributes || error) { - OWSProdLogAndFail(@"%@ Could not get attributes of file at: %@", self.logTag, filePath); + DDLogDebug(@"%@ Could not get attributes of file at: %@", self.logTag, filePath); + OWSFail(@"%@ Could not get attributes of file", self.logTag); continue; } // Don't delete files which were created in the last N minutes. @@ -692,7 +695,8 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); } [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]; if (error) { - OWSProdLogAndFail(@"%@ Could not remove orphan file at: %@", self.logTag, filePath); + DDLogDebug(@"%@ Could not remove orphan file at: %@", self.logTag, filePath); + OWSFail(@"%@ Could not remove orphan file", self.logTag); } } DDLogInfo(@"%@ Deleted orphan attachment files: %zu", self.logTag, filesRemoved); diff --git a/Signal/src/util/UIViewController+Permissions.m b/Signal/src/util/UIViewController+Permissions.m index 59c85169d3..584ed3aa2f 100644 --- a/Signal/src/util/UIViewController+Permissions.m +++ b/Signal/src/util/UIViewController+Permissions.m @@ -2,8 +2,8 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "Signal-Swift.h" #import "UIViewController+Permissions.h" +#import "Signal-Swift.h" #import #import #import diff --git a/SignalMessaging/ViewControllers/NewNonContactConversationViewController.m b/SignalMessaging/ViewControllers/NewNonContactConversationViewController.m index 9c07fe231d..64236df96c 100644 --- a/SignalMessaging/ViewControllers/NewNonContactConversationViewController.m +++ b/SignalMessaging/ViewControllers/NewNonContactConversationViewController.m @@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)contactsSectionTitle { - OWSFail(@"Method should never be called."); + OWSFail(@"%s Method should never be called.", __PRETTY_FUNCTION__); return nil; } @@ -84,14 +84,14 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)canSignalAccountBeSelected:(SignalAccount *)signalAccount { - OWSFail(@"Method should never be called."); + OWSFail(@"%s Method should never be called.", __PRETTY_FUNCTION__); return NO; } - (nullable NSString *)accessoryMessageForSignalAccount:(SignalAccount *)signalAccount { - OWSFail(@"Method should never be called."); + OWSFail(@"%s Method should never be called.", __PRETTY_FUNCTION__); return nil; } diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index aff3b67600..f6b6f0a705 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -2,8 +2,8 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSMath.h" #import "UIView+OWS.h" +#import "OWSMath.h" #import NS_ASSUME_NONNULL_BEGIN diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index 4d9465a2ae..e52144f5be 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -350,8 +350,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob [OWSFileSystem protectFileOrFolderAtPath:defaultSoundPath fileProtectionType:NSFileProtectionNone]; if (!success) { - OWSProdLogAndFail( - @"%@ Unable to write new default sound data from: %@ to :%@", self.logTag, soundURL, defaultSoundPath); + OWSFail(@"%@ Unable to write new default sound data from: %@ to :%@", self.logTag, soundURL, defaultSoundPath); return; } diff --git a/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m b/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m index 7491cf2918..621136a12c 100644 --- a/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m +++ b/SignalMessaging/environment/migrations/OWS104CreateRecipientIdentities.m @@ -37,7 +37,7 @@ static NSString *const OWS104CreateRecipientIdentitiesMigrationId = @"104"; OWSFail(@"%@ Unexpected object in trusted keys collection key: %@ object: %@", self.logTag, recipientId, - object); + [object class]); return; } NSData *identityKey = (NSData *)object; diff --git a/SignalMessaging/profiles/OWSUserProfile.m b/SignalMessaging/profiles/OWSUserProfile.m index daa4648d2e..71cdd5ed31 100644 --- a/SignalMessaging/profiles/OWSUserProfile.m +++ b/SignalMessaging/profiles/OWSUserProfile.m @@ -9,10 +9,10 @@ #import #import #import +#import #import #import #import -#import NS_ASSUME_NONNULL_BEGIN @@ -448,7 +448,7 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId"; enumerateCollectionObjectsWithTransaction:transaction usingBlock:^(id object, BOOL *stop) { if (![object isKindOfClass:[OWSUserProfile class]]) { - OWSProdLogAndFail(@"%@ unexpected object in user profiles: %@", + OWSFail(@"%@ unexpected object in user profiles: %@", self.logTag, [object class]); return; diff --git a/SignalMessaging/utils/OWSAvatarBuilder.m b/SignalMessaging/utils/OWSAvatarBuilder.m index c5a01120c3..7155ff1c85 100644 --- a/SignalMessaging/utils/OWSAvatarBuilder.m +++ b/SignalMessaging/utils/OWSAvatarBuilder.m @@ -3,12 +3,12 @@ // #import "OWSAvatarBuilder.h" +#import "JSQMessagesAvatarImageFactory.h" #import "OWSContactAvatarBuilder.h" #import "OWSGroupAvatarBuilder.h" #import "TSContactThread.h" #import "TSGroupThread.h" #import "UIColor+OWS.h" -#import "JSQMessagesAvatarImageFactory.h" NS_ASSUME_NONNULL_BEGIN @@ -89,13 +89,13 @@ NS_ASSUME_NONNULL_BEGIN - (nullable UIImage *)buildSavedImage { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return nil; } - (UIImage *)buildDefaultImage { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return [UIImage new]; } diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index 6d8c62cd18..de8902bcfa 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -728,7 +728,7 @@ NS_ASSUME_NONNULL_BEGIN NSArray *_Nullable uniqueIds = [transaction allKeysInCollection:collection]; if (!uniqueIds) { - OWSProdLogAndFail(@"%@ couldn't load uniqueIds for collection: %@.", self.logTag, collection); + OWSFail(@"%@ couldn't load uniqueIds for collection: %@.", self.logTag, collection); return; } DDLogInfo(@"%@ Deleting %lu objects from: %@", self.logTag, (unsigned long)uniqueIds.count, collection); @@ -738,7 +738,7 @@ NS_ASSUME_NONNULL_BEGIN // work. TSYapDatabaseObject *_Nullable object = [class fetchObjectWithUniqueID:uniqueId transaction:transaction]; if (!object) { - OWSProdLogAndFail(@"%@ couldn't load object for deletion: %@.", self.logTag, collection); + OWSFail(@"%@ couldn't load object for deletion: %@.", self.logTag, collection); continue; } [object removeWithTransaction:transaction]; diff --git a/SignalServiceKit/src/Contacts/CDSQuote.m b/SignalServiceKit/src/Contacts/CDSQuote.m index 1b3d7a6e8f..e82e6b6465 100644 --- a/SignalServiceKit/src/Contacts/CDSQuote.m +++ b/SignalServiceKit/src/Contacts/CDSQuote.m @@ -50,13 +50,13 @@ static const long SGX_XFRM_RESERVED = 0xFFFFFFFFFFFFFFF8L; uint16_t version = parser.nextShort; if (version < 1 || version > 2) { - OWSProdLogAndFail(@"%@ unexpected quote version: %d", self.logTag, (int)version); + OWSFail(@"%@ unexpected quote version: %d", self.logTag, (int)version); return nil; } uint16_t signType = parser.nextShort; if ((signType & ~1) != 0) { - OWSProdLogAndFail(@"%@ invalid signType: %d", self.logTag, (int)signType); + OWSFail(@"%@ invalid signType: %d", self.logTag, (int)signType); return nil; } @@ -69,19 +69,19 @@ static const long SGX_XFRM_RESERVED = 0xFFFFFFFFFFFFFFF8L; pceSvn = parser.nextShort; } else { if (![parser readZero:2]) { - OWSProdLogAndFail(@"%@ non-zero pceSvn.", self.logTag); + OWSFail(@"%@ non-zero pceSvn.", self.logTag); return nil; } } if (![parser readZero:4]) { - OWSProdLogAndFail(@"%@ non-zero xeid.", self.logTag); + OWSFail(@"%@ non-zero xeid.", self.logTag); return nil; } NSData *_Nullable basename = [parser readBytes:32]; if (!basename) { - OWSProdLogAndFail(@"%@ couldn't read basename.", self.logTag); + OWSFail(@"%@ couldn't read basename.", self.logTag); return nil; } @@ -89,69 +89,69 @@ static const long SGX_XFRM_RESERVED = 0xFFFFFFFFFFFFFFF8L; NSData *_Nullable cpuSvn = [parser readBytes:16]; if (!cpuSvn) { - OWSProdLogAndFail(@"%@ couldn't read cpuSvn.", self.logTag); + OWSFail(@"%@ couldn't read cpuSvn.", self.logTag); return nil; } if (![parser readZero:4]) { - OWSProdLogAndFail(@"%@ non-zero misc_select.", self.logTag); + OWSFail(@"%@ non-zero misc_select.", self.logTag); return nil; } if (![parser readZero:28]) { - OWSProdLogAndFail(@"%@ non-zero reserved1.", self.logTag); + OWSFail(@"%@ non-zero reserved1.", self.logTag); return nil; } uint64_t flags = parser.nextLong; if ((flags & SGX_FLAGS_RESERVED) != 0 || (flags & SGX_FLAGS_INITTED) == 0 || (flags & SGX_FLAGS_MODE64BIT) == 0) { - OWSProdLogAndFail(@"%@ invalid flags.", self.logTag); + OWSFail(@"%@ invalid flags.", self.logTag); return nil; } uint64_t xfrm = parser.nextLong; if ((xfrm & SGX_XFRM_RESERVED) != 0) { - OWSProdLogAndFail(@"%@ invalid xfrm.", self.logTag); + OWSFail(@"%@ invalid xfrm.", self.logTag); return nil; } NSData *_Nullable mrenclave = [parser readBytes:32]; if (!mrenclave) { - OWSProdLogAndFail(@"%@ couldn't read mrenclave.", self.logTag); + OWSFail(@"%@ couldn't read mrenclave.", self.logTag); return nil; } if (![parser readZero:32]) { - OWSProdLogAndFail(@"%@ non-zero reserved2.", self.logTag); + OWSFail(@"%@ non-zero reserved2.", self.logTag); return nil; } NSData *_Nullable mrsigner = [parser readBytes:32]; if (!mrsigner) { - OWSProdLogAndFail(@"%@ couldn't read mrsigner.", self.logTag); + OWSFail(@"%@ couldn't read mrsigner.", self.logTag); return nil; } if (![parser readZero:96]) { - OWSProdLogAndFail(@"%@ non-zero reserved3.", self.logTag); + OWSFail(@"%@ non-zero reserved3.", self.logTag); return nil; } uint16_t isvProdId = parser.nextShort; uint16_t isvSvn = parser.nextShort; if (![parser readZero:60]) { - OWSProdLogAndFail(@"%@ non-zero reserved4.", self.logTag); + OWSFail(@"%@ non-zero reserved4.", self.logTag); return nil; } NSData *_Nullable reportData = [parser readBytes:64]; if (!reportData) { - OWSProdLogAndFail(@"%@ couldn't read reportData.", self.logTag); + OWSFail(@"%@ couldn't read reportData.", self.logTag); return nil; } // quote signature uint32_t signatureLength = parser.nextInt; if (signatureLength != quoteData.length - 436) { - OWSProdLogAndFail(@"%@ invalid signatureLength.", self.logTag); + OWSFail(@"%@ invalid signatureLength.", self.logTag); return nil; } NSData *_Nullable signature = [parser readBytes:signatureLength]; if (!signature) { - OWSProdLogAndFail(@"%@ couldn't read signature.", self.logTag); + OWSFail(@"%@ couldn't read signature.", self.logTag); return nil; } diff --git a/SignalServiceKit/src/Contacts/CDSSigningCertificate.m b/SignalServiceKit/src/Contacts/CDSSigningCertificate.m index 7f8af2f3d6..1c9c8d50d8 100644 --- a/SignalServiceKit/src/Contacts/CDSSigningCertificate.m +++ b/SignalServiceKit/src/Contacts/CDSSigningCertificate.m @@ -57,14 +57,14 @@ NS_ASSUME_NONNULL_BEGIN NSArray *_Nullable anchorCertificates = [self anchorCertificates]; if (anchorCertificates.count < 1) { - OWSProdLogAndFail(@"%@ Could not load anchor certificates.", self.logTag); + OWSFail(@"%@ Could not load anchor certificates.", self.logTag); return nil; } NSArray *_Nullable certificateDerDatas = [self convertPemToDer:certificatePem]; if (certificateDerDatas.count < 1) { - OWSProdLogAndFail(@"%@ Could not parse PEM.", self.logTag); + OWSFail(@"%@ Could not parse PEM.", self.logTag); return nil; } @@ -75,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN return nil; } if (![self verifyDistinguishedNameOfCertificate:leafCertificateData]) { - OWSProdLogAndFail(@"%@ Leaf certificate has invalid name.", self.logTag); + OWSFail(@"%@ Leaf certificate has invalid name.", self.logTag); return nil; } @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN for (NSData *certificateDerData in certificateDerDatas) { SecCertificateRef certificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certificateDerData)); if (!certificate) { - OWSProdLogAndFail(@"%@ Could not load DER.", self.logTag); + OWSFail(@"%@ Could not load DER.", self.logTag); return nil; } [certificates addObject:(__bridge_transfer id)certificate]; @@ -124,7 +124,7 @@ NS_ASSUME_NONNULL_BEGIN for (NSData *certificateData in anchorCertificates) { SecCertificateRef certificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certificateData)); if (!certificate) { - OWSProdLogAndFail(@"%@ Could not load DER.", self.logTag); + OWSFail(@"%@ Could not load DER.", self.logTag); return nil; } @@ -175,7 +175,7 @@ NS_ASSUME_NONNULL_BEGIN options:NSRegularExpressionCaseInsensitive | NSRegularExpressionDotMatchesLineSeparators error:&error]; if (!regex || error) { - OWSProdLogAndFail(@"%@ could parse regex: %@.", self.logTag, error); + OWSFail(@"%@ could parse regex: %@.", self.logTag, error); return nil; } @@ -184,19 +184,19 @@ NS_ASSUME_NONNULL_BEGIN range:NSMakeRange(0, pemString.length) usingBlock:^(NSTextCheckingResult *_Nullable result, NSMatchingFlags flags, BOOL *stop) { if (result.numberOfRanges != 2) { - OWSProdLogAndFail(@"%@ invalid PEM regex match.", self.logTag); + OWSFail(@"%@ invalid PEM regex match.", self.logTag); return; } NSString *_Nullable derString = [pemString substringWithRange:[result rangeAtIndex:1]]; if (derString.length < 1) { - OWSProdLogAndFail(@"%@ empty PEM match.", self.logTag); + OWSFail(@"%@ empty PEM match.", self.logTag); return; } // dataFromBase64String will ignore whitespace, which is // necessary. NSData *_Nullable derData = [NSData dataFromBase64String:derString]; if (derData.length < 1) { - OWSProdLogAndFail(@"%@ could not parse PEM match.", self.logTag); + OWSFail(@"%@ could not parse PEM match.", self.logTag); return; } [certificateDatas addObject:derData]; @@ -213,7 +213,7 @@ NS_ASSUME_NONNULL_BEGIN // We need to use an Intel certificate as the anchor for IAS verification. NSData *_Nullable anchorCertificate = [self certificateDataForService:@"ias-root"]; if (!anchorCertificate) { - OWSProdLogAndFail(@"%@ could not load anchor certificate.", self.logTag); + OWSFail(@"%@ could not load anchor certificate.", self.logTag); OWSRaiseException(@"OWSSignalService_CouldNotLoadCertificate", @"%s", __PRETTY_FUNCTION__); } else { anchorCertificates = @[ anchorCertificate ]; @@ -228,7 +228,7 @@ NS_ASSUME_NONNULL_BEGIN NSString *path = [bundle pathForResource:service ofType:@"cer"]; if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { - OWSProdLogAndFail(@"%@ could not locate certificate file.", self.logTag); + OWSFail(@"%@ could not locate certificate file.", self.logTag); return nil; } @@ -247,7 +247,7 @@ NS_ASSUME_NONNULL_BEGIN NSData *_Nullable hashData = [Cryptography computeSHA256Digest:bodyData]; if (hashData.length != CC_SHA256_DIGEST_LENGTH) { - OWSProdLogAndFail(@"%@ could not SHA256 for signature verification.", self.logTag); + OWSFail(@"%@ could not SHA256 for signature verification.", self.logTag); return NO; } size_t hashBytesSize = CC_SHA256_DIGEST_LENGTH; @@ -258,7 +258,7 @@ NS_ASSUME_NONNULL_BEGIN BOOL isValid = status == errSecSuccess; if (!isValid) { - OWSProdLogAndFail(@"%@ signatures do not match.", self.logTag); + OWSFail(@"%@ signatures do not match.", self.logTag); return NO; } return YES; diff --git a/SignalServiceKit/src/Contacts/Contact.m b/SignalServiceKit/src/Contacts/Contact.m index c74d3ee36b..d3c5708171 100644 --- a/SignalServiceKit/src/Contacts/Contact.m +++ b/SignalServiceKit/src/Contacts/Contact.m @@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN if (hashData) { [hashData getBytes:&hashValue length:sizeof(hashValue)]; } else { - OWSProdLogAndFail(@"%@ could not compute hash for avatar.", self.logTag); + OWSFail(@"%@ could not compute hash for avatar.", self.logTag); } _imageHash = hashValue; } else { @@ -310,15 +310,15 @@ NS_ASSUME_NONNULL_BEGIN NSError *error; NSArray *_Nullable contacts = [CNContactVCardSerialization contactsWithData:data error:&error]; if (!contacts || error) { - OWSProdLogAndFail(@"%@ could not parse vcard: %@", self.logTag, error); + OWSFail(@"%@ could not parse vcard: %@", self.logTag, error); return nil; } if (contacts.count < 1) { - OWSProdLogAndFail(@"%@ empty vcard: %@", self.logTag, error); + OWSFail(@"%@ empty vcard: %@", self.logTag, error); return nil; } if (contacts.count > 1) { - OWSProdLogAndFail(@"%@ more than one contact in vcard: %@", self.logTag, error); + OWSFail(@"%@ more than one contact in vcard: %@", self.logTag, error); } return contacts.firstObject; } diff --git a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m index 20338efef6..59cfc21a3c 100644 --- a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m +++ b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m @@ -82,11 +82,11 @@ NS_ASSUME_NONNULL_BEGIN } if (!derivedMaterial) { - OWSProdLogAndFail(@"%@ missing derived service key.", self.logTag); + OWSFail(@"%@ missing derived service key.", self.logTag); return NO; } if (derivedMaterial.length != kAES256_KeyByteLength * 2) { - OWSProdLogAndFail(@"%@ derived service key has unexpected length.", self.logTag); + OWSFail(@"%@ derived service key has unexpected length.", self.logTag); return NO; } @@ -94,7 +94,7 @@ NS_ASSUME_NONNULL_BEGIN [derivedMaterial subdataWithRange:NSMakeRange(kAES256_KeyByteLength * 0, kAES256_KeyByteLength)]; OWSAES256Key *_Nullable clientKey = [OWSAES256Key keyWithData:clientKeyData]; if (!clientKey) { - OWSProdLogAndFail(@"%@ clientKey has unexpected length.", self.logTag); + OWSFail(@"%@ clientKey has unexpected length.", self.logTag); return NO; } @@ -102,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN [derivedMaterial subdataWithRange:NSMakeRange(kAES256_KeyByteLength * 1, kAES256_KeyByteLength)]; OWSAES256Key *_Nullable serverKey = [OWSAES256Key keyWithData:serverKeyData]; if (!serverKey) { - OWSProdLogAndFail(@"%@ serverKey has unexpected length.", self.logTag); + OWSFail(@"%@ serverKey has unexpected length.", self.logTag); return NO; } @@ -172,7 +172,7 @@ NS_ASSUME_NONNULL_BEGIN { NSString *_Nullable valueString = self[key]; if (![valueString isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ couldn't parse string for key: %@", self.logTag, key); + OWSFail(@"%@ couldn't parse string for key: %@", self.logTag, key); return nil; } return valueString; @@ -182,12 +182,12 @@ NS_ASSUME_NONNULL_BEGIN { NSString *_Nullable valueString = self[key]; if (![valueString isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ couldn't parse base 64 value for key: %@", self.logTag, key); + OWSFail(@"%@ couldn't parse base 64 value for key: %@", self.logTag, key); return nil; } NSData *_Nullable valueData = [[NSData alloc] initWithBase64EncodedString:valueString options:0]; if (!valueData) { - OWSProdLogAndFail(@"%@ couldn't decode base 64 value for key: %@", self.logTag, key); + OWSFail(@"%@ couldn't decode base 64 value for key: %@", self.logTag, key); return nil; } return valueData; @@ -197,11 +197,15 @@ NS_ASSUME_NONNULL_BEGIN { NSData *_Nullable valueData = [self base64DataForKey:key]; if (valueData && valueData.length != expectedLength) { - OWSProdLogAndFail(@"%@ decoded base 64 value for key: %@, has unexpected length: %zd != %zd", + DDLogDebug(@"%@ decoded base 64 value for key: %@, has unexpected length: %zd != %zd", self.logTag, key, valueData.length, expectedLength); + OWSFail(@"%@ decoded base 64 value for key has unexpected length: %lu != %lu", + self.logTag, + (unsigned long)valueData.length, + (unsigned long)expectedLength); return nil; } return valueData; @@ -292,13 +296,13 @@ NS_ASSUME_NONNULL_BEGIN NSDictionary *responseDict = response; NSString *_Nullable password = [responseDict stringForKey:@"password"]; if (password.length < 1) { - OWSProdLogAndFail(@"%@ missing or empty password.", self.logTag); + OWSFail(@"%@ missing or empty password.", self.logTag); return nil; } NSString *_Nullable username = [responseDict stringForKey:@"username"]; if (username.length < 1) { - OWSProdLogAndFail(@"%@ missing or empty username.", self.logTag); + OWSFail(@"%@ missing or empty username.", self.logTag); return nil; } @@ -359,14 +363,14 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(enclaveId.length > 0); if (![response isKindOfClass:[NSHTTPURLResponse class]]) { - OWSProdLogAndFail(@"%@ unexpected response type.", self.logTag); + OWSFail(@"%@ unexpected response type.", self.logTag); return nil; } NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:httpResponse.allHeaderFields forURL:[NSURL new]]; if (cookies.count < 1) { - OWSProdLogAndFail(@"%@ couldn't parse cookie.", self.logTag); + OWSFail(@"%@ couldn't parse cookie.", self.logTag); return nil; } @@ -377,52 +381,52 @@ NS_ASSUME_NONNULL_BEGIN NSData *_Nullable serverEphemeralPublic = [responseDict base64DataForKey:@"serverEphemeralPublic" expectedLength:32]; if (!serverEphemeralPublic) { - OWSProdLogAndFail(@"%@ couldn't parse serverEphemeralPublic.", self.logTag); + OWSFail(@"%@ couldn't parse serverEphemeralPublic.", self.logTag); return nil; } NSData *_Nullable serverStaticPublic = [responseDict base64DataForKey:@"serverStaticPublic" expectedLength:32]; if (!serverStaticPublic) { - OWSProdLogAndFail(@"%@ couldn't parse serverStaticPublic.", self.logTag); + OWSFail(@"%@ couldn't parse serverStaticPublic.", self.logTag); return nil; } NSData *_Nullable encryptedRequestId = [responseDict base64DataForKey:@"ciphertext"]; if (!encryptedRequestId) { - OWSProdLogAndFail(@"%@ couldn't parse encryptedRequestId.", self.logTag); + OWSFail(@"%@ couldn't parse encryptedRequestId.", self.logTag); return nil; } NSData *_Nullable encryptedRequestIv = [responseDict base64DataForKey:@"iv" expectedLength:12]; if (!encryptedRequestIv) { - OWSProdLogAndFail(@"%@ couldn't parse encryptedRequestIv.", self.logTag); + OWSFail(@"%@ couldn't parse encryptedRequestIv.", self.logTag); return nil; } NSData *_Nullable encryptedRequestTag = [responseDict base64DataForKey:@"tag" expectedLength:16]; if (!encryptedRequestTag) { - OWSProdLogAndFail(@"%@ couldn't parse encryptedRequestTag.", self.logTag); + OWSFail(@"%@ couldn't parse encryptedRequestTag.", self.logTag); return nil; } NSData *_Nullable quoteData = [responseDict base64DataForKey:@"quote"]; if (!quoteData) { - OWSProdLogAndFail(@"%@ couldn't parse quote data.", self.logTag); + OWSFail(@"%@ couldn't parse quote data.", self.logTag); return nil; } NSString *_Nullable signatureBody = [responseDict stringForKey:@"signatureBody"]; if (![signatureBody isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ couldn't parse signatureBody.", self.logTag); + OWSFail(@"%@ couldn't parse signatureBody.", self.logTag); return nil; } NSData *_Nullable signature = [responseDict base64DataForKey:@"signature"]; if (!signature) { - OWSProdLogAndFail(@"%@ couldn't parse signature.", self.logTag); + OWSFail(@"%@ couldn't parse signature.", self.logTag); return nil; } NSString *_Nullable encodedCertificates = [responseDict stringForKey:@"certificates"]; if (![encodedCertificates isKindOfClass:[NSString class]]) { - OWSProdLogAndFail(@"%@ couldn't parse encodedCertificates.", self.logTag); + OWSFail(@"%@ couldn't parse encodedCertificates.", self.logTag); return nil; } NSString *_Nullable certificates = [encodedCertificates stringByRemovingPercentEncoding]; if (!certificates) { - OWSProdLogAndFail(@"%@ couldn't parse certificates.", self.logTag); + OWSFail(@"%@ couldn't parse certificates.", self.logTag); return nil; } @@ -430,13 +434,13 @@ NS_ASSUME_NONNULL_BEGIN serverEphemeralPublic:serverEphemeralPublic serverStaticPublic:serverStaticPublic]; if (!keys) { - OWSProdLogAndFail(@"%@ couldn't derive keys.", self.logTag); + OWSFail(@"%@ couldn't derive keys.", self.logTag); return nil; } CDSQuote *_Nullable quote = [CDSQuote parseQuoteFromData:quoteData]; if (!quote) { - OWSProdLogAndFail(@"%@ couldn't parse quote.", self.logTag); + OWSFail(@"%@ couldn't parse quote.", self.logTag); return nil; } NSData *_Nullable requestId = [self decryptRequestId:encryptedRequestId @@ -444,12 +448,12 @@ NS_ASSUME_NONNULL_BEGIN encryptedRequestTag:encryptedRequestTag keys:keys]; if (!requestId) { - OWSProdLogAndFail(@"%@ couldn't decrypt request id.", self.logTag); + OWSFail(@"%@ couldn't decrypt request id.", self.logTag); return nil; } if (![self verifyServerQuote:quote keys:keys enclaveId:enclaveId]) { - OWSProdLogAndFail(@"%@ couldn't verify quote.", self.logTag); + OWSFail(@"%@ couldn't verify quote.", self.logTag); return nil; } @@ -457,7 +461,7 @@ NS_ASSUME_NONNULL_BEGIN signatureBody:signatureBody signature:signature quoteData:quoteData]) { - OWSProdLogAndFail(@"%@ couldn't verify ias signature.", self.logTag); + OWSFail(@"%@ couldn't verify ias signature.", self.logTag); return nil; } @@ -485,43 +489,42 @@ NS_ASSUME_NONNULL_BEGIN CDSSigningCertificate *_Nullable certificate = [CDSSigningCertificate parseCertificateFromPem:certificates]; if (!certificate) { - OWSProdLogAndFail(@"%@ could not parse signing certificate.", self.logTag); + OWSFail(@"%@ could not parse signing certificate.", self.logTag); return NO; } if (![certificate verifySignatureOfBody:signatureBody signature:signature]) { - OWSProdLogAndFail(@"%@ could not verify signature.", self.logTag); + OWSFail(@"%@ could not verify signature.", self.logTag); return NO; } SignatureBodyEntity *_Nullable signatureBodyEntity = [self parseSignatureBodyEntity:signatureBody]; if (!signatureBodyEntity) { - OWSProdLogAndFail(@"%@ could not parse signature body.", self.logTag); + OWSFail(@"%@ could not parse signature body.", self.logTag); return NO; } // Compare the first N bytes of the quote data with the signed quote body. const NSUInteger kQuoteBodyComparisonLength = 432; if (signatureBodyEntity.isvEnclaveQuoteBody.length < kQuoteBodyComparisonLength) { - OWSProdLogAndFail(@"%@ isvEnclaveQuoteBody has unexpected length.", self.logTag); + OWSFail(@"%@ isvEnclaveQuoteBody has unexpected length.", self.logTag); return NO; } if (quoteData.length < kQuoteBodyComparisonLength) { - OWSProdLogAndFail(@"%@ quoteData has unexpected length.", self.logTag); + OWSFail(@"%@ quoteData has unexpected length.", self.logTag); return NO; } NSData *isvEnclaveQuoteBodyForComparison = [signatureBodyEntity.isvEnclaveQuoteBody subdataWithRange:NSMakeRange(0, kQuoteBodyComparisonLength)]; NSData *quoteDataForComparison = [quoteData subdataWithRange:NSMakeRange(0, kQuoteBodyComparisonLength)]; if (![isvEnclaveQuoteBodyForComparison ows_constantTimeIsEqualToData:quoteDataForComparison]) { - OWSProdLogAndFail(@"%@ isvEnclaveQuoteBody and quoteData do not match.", self.logTag); + OWSFail(@"%@ isvEnclaveQuoteBody and quoteData do not match.", self.logTag); return NO; } // TODO: Before going to production, remove GROUP_OUT_OF_DATE. if (![@"OK" isEqualToString:signatureBodyEntity.isvEnclaveQuoteStatus] && ![@"GROUP_OUT_OF_DATE" isEqualToString:signatureBodyEntity.isvEnclaveQuoteStatus]) { - OWSProdLogAndFail( - @"%@ invalid isvEnclaveQuoteStatus: %@.", self.logTag, signatureBodyEntity.isvEnclaveQuoteStatus); + OWSFail(@"%@ invalid isvEnclaveQuoteStatus: %@.", self.logTag, signatureBodyEntity.isvEnclaveQuoteStatus); return NO; } @@ -531,7 +534,7 @@ NS_ASSUME_NONNULL_BEGIN [dateFormatter setDateFormat:@"yyy-MM-dd'T'HH:mm:ss.SSSSSS"]; NSDate *timestampDate = [dateFormatter dateFromString:signatureBodyEntity.timestamp]; if (!timestampDate) { - OWSProdLogAndFail(@"%@ could not parse signature body timestamp.", self.logTag); + OWSFail(@"%@ could not parse signature body timestamp.", self.logTag); return NO; } @@ -545,7 +548,7 @@ NS_ASSUME_NONNULL_BEGIN BOOL isExpired = [now isAfterDate:timestampDatePlus1Day]; if (isExpired) { - OWSProdLogAndFail(@"%@ Signature is expired.", self.logTag); + OWSFail(@"%@ Signature is expired.", self.logTag); return NO; } @@ -562,22 +565,22 @@ NS_ASSUME_NONNULL_BEGIN options:0 error:&error]; if (error || ![jsonDict isKindOfClass:[NSDictionary class]]) { - OWSProdLogAndFail(@"%@ could not parse signature body JSON: %@.", self.logTag, error); + OWSFail(@"%@ could not parse signature body JSON: %@.", self.logTag, error); return nil; } NSString *_Nullable timestamp = [jsonDict stringForKey:@"timestamp"]; if (timestamp.length < 1) { - OWSProdLogAndFail(@"%@ could not parse signature timestamp.", self.logTag); + OWSFail(@"%@ could not parse signature timestamp.", self.logTag); return nil; } NSData *_Nullable isvEnclaveQuoteBody = [jsonDict base64DataForKey:@"isvEnclaveQuoteBody"]; if (isvEnclaveQuoteBody.length < 1) { - OWSProdLogAndFail(@"%@ could not parse signature isvEnclaveQuoteBody.", self.logTag); + OWSFail(@"%@ could not parse signature isvEnclaveQuoteBody.", self.logTag); return nil; } NSString *_Nullable isvEnclaveQuoteStatus = [jsonDict stringForKey:@"isvEnclaveQuoteStatus"]; if (isvEnclaveQuoteStatus.length < 1) { - OWSProdLogAndFail(@"%@ could not parse signature isvEnclaveQuoteStatus.", self.logTag); + OWSFail(@"%@ could not parse signature isvEnclaveQuoteStatus.", self.logTag); return nil; } @@ -595,7 +598,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(enclaveId.length > 0); if (quote.reportData.length < keys.serverStaticPublic.length) { - OWSProdLogAndFail(@"%@ reportData has unexpected length: %zd != %zd.", + OWSFail(@"%@ reportData has unexpected length: %zd != %zd.", self.logTag, quote.reportData.length, keys.serverStaticPublic.length); @@ -605,11 +608,11 @@ NS_ASSUME_NONNULL_BEGIN NSData *_Nullable theirServerPublicStatic = [quote.reportData subdataWithRange:NSMakeRange(0, keys.serverStaticPublic.length)]; if (theirServerPublicStatic.length != keys.serverStaticPublic.length) { - OWSProdLogAndFail(@"%@ could not extract server public static.", self.logTag); + OWSFail(@"%@ could not extract server public static.", self.logTag); return NO; } if (![keys.serverStaticPublic ows_constantTimeIsEqualToData:theirServerPublicStatic]) { - OWSProdLogAndFail(@"%@ server public statics do not match.", self.logTag); + OWSFail(@"%@ server public statics do not match.", self.logTag); return NO; } // It's easier to compare as hex data than parsing hexadecimal. @@ -618,12 +621,12 @@ NS_ASSUME_NONNULL_BEGIN [quote.mrenclave.hexadecimalString dataUsingEncoding:NSUTF8StringEncoding]; if (!ourEnclaveIdHexData || !theirEnclaveIdHexData || ![ourEnclaveIdHexData ows_constantTimeIsEqualToData:theirEnclaveIdHexData]) { - OWSProdLogAndFail(@"%@ enclave ids do not match.", self.logTag); + OWSFail(@"%@ enclave ids do not match.", self.logTag); return NO; } // TODO: Reverse this condition in production. if (!quote.isDebugQuote) { - OWSProdLogAndFail(@"%@ quote has invalid isDebugQuote value.", self.logTag); + OWSFail(@"%@ quote has invalid isDebugQuote value.", self.logTag); return NO; } return YES; @@ -641,7 +644,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAES256Key *_Nullable key = keys.serverKey; if (!key) { - OWSProdLogAndFail(@"%@ invalid server key.", self.logTag); + OWSFail(@"%@ invalid server key.", self.logTag); return nil; } NSData *_Nullable decryptedData = [Cryptography decryptAESGCMWithInitializationVector:encryptedRequestIv @@ -650,7 +653,7 @@ NS_ASSUME_NONNULL_BEGIN authTag:encryptedRequestTag key:key]; if (!decryptedData) { - OWSProdLogAndFail(@"%@ couldn't decrypt request id.", self.logTag); + OWSFail(@"%@ couldn't decrypt request id.", self.logTag); return nil; } return decryptedData; diff --git a/SignalServiceKit/src/Contacts/SignalRecipient.m b/SignalServiceKit/src/Contacts/SignalRecipient.m index 993a3bba85..e4b1ee550f 100644 --- a/SignalServiceKit/src/Contacts/SignalRecipient.m +++ b/SignalServiceKit/src/Contacts/SignalRecipient.m @@ -189,7 +189,7 @@ NS_ASSUME_NONNULL_BEGIN // be strict about using persisted SignalRecipients as a cache to // reflect "last known registration status". Forcing our codebase to // use those methods helps ensure that we update the cache deliberately. - OWSProdLogAndFail(@"%@ Don't call saveWithTransaction from outside this class.", self.logTag); + OWSFail(@"%@ Don't call saveWithTransaction from outside this class.", self.logTag); [self saveWithTransaction_internal:transaction]; } diff --git a/SignalServiceKit/src/Contacts/TSThread.m b/SignalServiceKit/src/Contacts/TSThread.m index a6108a0fda..7b8eb4e60e 100644 --- a/SignalServiceKit/src/Contacts/TSThread.m +++ b/SignalServiceKit/src/Contacts/TSThread.m @@ -101,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN [interactionsByThread enumerateKeysInGroup:self.uniqueId usingBlock:^(NSString *collection, NSString *key, NSUInteger index, BOOL *stop) { if (![key isKindOfClass:[NSString class]] || key.length < 1) { - OWSProdLogAndFail(@"%@ invalid key in thread interactions: %@, %@.", + OWSFail(@"%@ invalid key in thread interactions: %@, %@.", self.logTag, key, [key class]); @@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN TSInteraction *_Nullable interaction = [TSInteraction fetchObjectWithUniqueID:interactionId transaction:transaction]; if (!interaction) { - OWSProdLogAndFail(@"%@ couldn't load thread's interaction for deletion.", self.logTag); + OWSFail(@"%@ couldn't load thread's interaction for deletion.", self.logTag); continue; } [interaction removeWithTransaction:transaction]; @@ -131,7 +131,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark To be subclassed. - (BOOL)isGroupThread { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return NO; } @@ -143,14 +143,14 @@ NS_ASSUME_NONNULL_BEGIN } - (NSString *)name { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return nil; } - (NSArray *)recipientIdentifiers { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return @[]; } @@ -242,7 +242,7 @@ NS_ASSUME_NONNULL_BEGIN NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) { if (![object conformsToProtocol:@protocol(OWSReadTracking)]) { - OWSFail(@"%@ Unexpected object in unseen messages: %@", self.logTag, object); + OWSFail(@"%@ Unexpected object in unseen messages: %@", self.logTag, [object class]); return; } [messages addObject:(id)object]; @@ -461,7 +461,7 @@ NS_ASSUME_NONNULL_BEGIN if (hashData) { [hashData getBytes:&hash length:hashingLength]; } else { - OWSProdLogAndFail(@"%@ could not compute hash for color seed.", self.logTag); + OWSFail(@"%@ could not compute hash for color seed.", self.logTag); } NSUInteger index = (hash % [self.conversationColorNames count]); diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m index c111185ff2..b3bb181af0 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m @@ -448,7 +448,8 @@ NS_ASSUME_NONNULL_BEGIN } CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)self.mediaURL, NULL); - OWSAssert(imageSource != NULL) NSDictionary *imageOptions = @{ + OWSAssert(imageSource != NULL); + NSDictionary *imageOptions = @{ (NSString const *)kCGImageSourceCreateThumbnailFromImageIfAbsent : (NSNumber const *)kCFBooleanTrue, (NSString const *)kCGImageSourceThumbnailMaxPixelSize : @(thumbnailSize), (NSString const *)kCGImageSourceCreateThumbnailWithTransform : (NSNumber const *)kCFBooleanTrue diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m b/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m index d2a1d62f8c..5127293732 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m @@ -70,7 +70,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable SSKProtoSyncMessageBuilder *)syncMessageBuilder { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return [SSKProtoSyncMessageBuilder new]; } diff --git a/SignalServiceKit/src/Messages/Interactions/OWSContact.m b/SignalServiceKit/src/Messages/Interactions/OWSContact.m index 80d5f02ebd..dabcb5b965 100644 --- a/SignalServiceKit/src/Messages/Interactions/OWSContact.m +++ b/SignalServiceKit/src/Messages/Interactions/OWSContact.m @@ -311,7 +311,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value) [self ensureDisplayName]; if (_displayName.length < 1) { - OWSProdLogAndFail(@"%@ could not derive a valid display name.", self.logTag); + OWSFail(@"%@ could not derive a valid display name.", self.logTag); return NSLocalizedString(@"CONTACT_WITHOUT_NAME", @"Indicates that a contact has no name."); } return _displayName; @@ -569,7 +569,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value) + (nullable OWSContact *)contactForSystemContact:(CNContact *)systemContact { if (!systemContact) { - OWSProdLogAndFail(@"%@ Missing contact.", self.logTag); + OWSFail(@"%@ Missing contact.", self.logTag); return nil; } @@ -664,7 +664,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value) + (nullable CNContact *)systemContactForContact:(OWSContact *)contact imageData:(nullable NSData *)imageData { if (!contact) { - OWSProdLogAndFail(@"%@ Missing contact.", self.logTag); + OWSFail(@"%@ Missing contact.", self.logTag); return nil; } @@ -921,7 +921,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value) return nil; } if (contactProto.number.count < 1 && contactProto.email.count < 1 && contactProto.address.count < 1) { - OWSProdLogAndFail(@"%@ contact has neither phone, email or address.", self.logTag); + OWSFail(@"%@ contact has neither phone, email or address.", self.logTag); return nil; } return contactProto; diff --git a/SignalServiceKit/src/Messages/Interactions/TSMessage.m b/SignalServiceKit/src/Messages/Interactions/TSMessage.m index aadc7f2356..857dc0ca35 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSMessage.m @@ -156,7 +156,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4; { uint32_t maxExpirationDuration = [OWSDisappearingMessagesConfiguration maxDurationSeconds]; if (expiresInSeconds > maxExpirationDuration) { - OWSProdLogAndFail(@"%@ in %s using `maxExpirationDuration` instead of: %u", + OWSFail(@"%@ in %s using `maxExpirationDuration` instead of: %u", self.logTag, __PRETTY_FUNCTION__, maxExpirationDuration); @@ -293,7 +293,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4; TSAttachment *_Nullable attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction]; if (!attachment) { - OWSProdLogAndFail(@"%@ couldn't load interaction's attachment for deletion.", self.logTag); + OWSFail(@"%@ couldn't load interaction's attachment for deletion.", self.logTag); continue; } [attachment removeWithTransaction:transaction]; diff --git a/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyErrorMessage.m b/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyErrorMessage.m index efcc7b01d9..78fbbcc30e 100644 --- a/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyErrorMessage.m +++ b/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyErrorMessage.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import "TSInvalidIdentityKeyErrorMessage.h" @@ -10,18 +10,18 @@ NS_ASSUME_NONNULL_BEGIN - (void)acceptNewIdentityKey { - OWSFail(@"Method needs to be implemented in subclasses of TSInvalidIdentityKeyErrorMessage."); + OWSAbstractMethod(); } - (nullable NSData *)newIdentityKey { - OWSFail(@"Method needs to be implemented in subclasses of TSInvalidIdentityKeyErrorMessage."); + OWSAbstractMethod(); return nil; } - (NSString *)theirSignalId { - OWSFail(@"Method needs to be implemented in subclasses of TSInvalidIdentityKeyErrorMessage."); + OWSAbstractMethod(); return nil; } diff --git a/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyReceivingErrorMessage.m b/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyReceivingErrorMessage.m index 0a1800273b..02296503ba 100644 --- a/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyReceivingErrorMessage.m +++ b/SignalServiceKit/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeyReceivingErrorMessage.m @@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN NSError *error; SSKProtoEnvelope *_Nullable envelope = [SSKProtoEnvelope parseData:self.envelopeData error:&error]; if (error || envelope == nil) { - OWSProdLogAndFail(@"%@ Could not parse proto: %@", self.logTag, error); + OWSFail(@"%@ Could not parse proto: %@", self.logTag, error); } else { _envelope = envelope; } diff --git a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m index 3e0f5d1769..6d948be4b3 100644 --- a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m +++ b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m @@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN SSKProtoEnvelope *_Nullable result = [SSKProtoEnvelope parseData:self.envelopeData error:&error]; if (error) { - OWSProdLogAndFail(@"%@ paring SSKProtoEnvelope failed with error: %@", self.logTag, error); + OWSFail(@"%@ paring SSKProtoEnvelope failed with error: %@", self.logTag, error); return nil; } @@ -405,7 +405,7 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo transaction:transaction]; } } @catch (NSException *exception) { - OWSProdLogAndFail(@"%@ Received an invalid envelope: %@", self.logTag, exception.debugDescription); + OWSFail(@"%@ Received an invalid envelope: %@", self.logTag, exception.debugDescription); reportFailure(transaction); } [processedJobs addObject:job]; diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m index 58494b18f0..d542f364a1 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesFinder.m @@ -58,7 +58,7 @@ static NSString *const OWSDisappearingMessageFinderExpiresAtIndex = @"index_mess OWSFail(@"%@ in %s object was unexpected class: %@", self.logTag, __PRETTY_FUNCTION__, - object); + [object class]); return; } @@ -138,7 +138,7 @@ static NSString *const OWSDisappearingMessageFinderExpiresAtIndex = @"index_mess if ([message isKindOfClass:[TSMessage class]]) { block(message); } else { - OWSProdLogAndFail(@"%@ unexpected object: %@", self.logTag, message); + OWSFail(@"%@ unexpected object: %@", self.logTag, [message class]); } } } @@ -152,12 +152,12 @@ static NSString *const OWSDisappearingMessageFinderExpiresAtIndex = @"index_mess TSMessage *_Nullable message = [TSMessage fetchObjectWithUniqueID:expiringMessageId transaction:transaction]; if (![message isKindOfClass:[TSMessage class]]) { - OWSProdLogAndFail(@"%@ unexpected object: %@", self.logTag, message); + OWSFail(@"%@ unexpected object: %@", self.logTag, [message class]); continue; } if (![message shouldStartExpireTimerWithTransaction:transaction]) { - OWSProdLogAndFail(@"%@ object: %@ shouldn't expire.", self.logTag, message); + OWSFail(@"%@ object: %@ shouldn't expire.", self.logTag, message); continue; } diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m index 5abcc2d8df..e5308548b9 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m @@ -375,7 +375,7 @@ void AssertIsOnDisappearingMessagesQueue() // exception is if we're in close proximity to the disappearanceTimer, in which case a race condition // is inevitable. if (!recentlyScheduledDisappearanceTimer && deletedCount > 0) { - OWSProdLogAndFail(@"%@ unexpectedly deleted disappearing messages via fallback timer.", self.logTag); + OWSFail(@"%@ unexpectedly deleted disappearing messages via fallback timer.", self.logTag); } }); } @@ -395,8 +395,7 @@ void AssertIsOnDisappearingMessagesQueue() { [self.disappearingMessagesFinder enumerateMessagesWhichFailedToStartExpiringWithBlock:^(TSMessage *_Nonnull message) { - OWSProdLogAndFail( - @"%@ starting old timer for message timestamp: %lu", self.logTag, (unsigned long)message.timestamp); + OWSFail(@"%@ starting old timer for message timestamp: %lu", self.logTag, (unsigned long)message.timestamp); // We don't know when it was actually read, so assume it was read as soon as it was received. uint64_t readTimeBestGuess = message.timestampForSorting; diff --git a/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m b/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m index 3d9ce0d92a..52e00be5b3 100644 --- a/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m +++ b/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m @@ -100,8 +100,7 @@ static NSString *const OWSIncompleteCallsJobCallTypeIndex = @"index_calls_on_cal [call updateCallType:RPRecentCallTypeIncomingMissed transaction:transaction]; OWSAssert(call.callType == RPRecentCallTypeIncomingMissed); } else { - OWSProdLogAndFail( - @"%@ call has unexpected call type: %@", self.logTag, NSStringFromCallType(call.callType)); + OWSFail(@"%@ call has unexpected call type: %@", self.logTag, NSStringFromCallType(call.callType)); return; } count++; diff --git a/SignalServiceKit/src/Messages/OWSMessageDecrypter.m b/SignalServiceKit/src/Messages/OWSMessageDecrypter.m index 20863d8a8e..94d2efec72 100644 --- a/SignalServiceKit/src/Messages/OWSMessageDecrypter.m +++ b/SignalServiceKit/src/Messages/OWSMessageDecrypter.m @@ -178,7 +178,7 @@ NS_ASSUME_NONNULL_BEGIN break; } } @catch (NSException *exception) { - OWSProdLogAndFail(@"%@ Received an invalid envelope: %@", self.logTag, exception.debugDescription); + OWSFail(@"%@ Received an invalid envelope: %@", self.logTag, exception.debugDescription); OWSProdFail([OWSAnalyticsEvents messageManagerErrorInvalidProtocolMessage]); [[OWSPrimaryStorage.sharedManager newDatabaseConnection] diff --git a/SignalServiceKit/src/Messages/OWSMessageHandler.m b/SignalServiceKit/src/Messages/OWSMessageHandler.m index 2e1f3626b9..76beb5cfa2 100644 --- a/SignalServiceKit/src/Messages/OWSMessageHandler.m +++ b/SignalServiceKit/src/Messages/OWSMessageHandler.m @@ -150,7 +150,6 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope) } else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) { [description appendString:@"ConfigurationRequest"]; } else { - // Shouldn't happen OWSFail(@"Unknown sync message request type"); [description appendString:@"UnknownRequest"]; } @@ -163,7 +162,6 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope) [NSString stringWithFormat:@"Verification for: %@", syncMessage.verified.destination]; [description appendString:verifiedString]; } else { - // Shouldn't happen OWSFail(@"Unknown sync message type"); [description appendString:@"Unknown"]; } diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index e655ab11bd..f87fb9ec31 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -179,8 +179,6 @@ NS_ASSUME_NONNULL_BEGIN DDLogInfo(@"%@ handling decrypted envelope: %@", self.logTag, [self descriptionForEnvelope:envelope]); if (!envelope.source.isValidE164) { - DDLogVerbose( - @"%@ incoming envelope has invalid source: %@", self.logTag, [self descriptionForEnvelope:envelope]); OWSFail(@"%@ incoming envelope has invalid source", self.logTag); return; } diff --git a/SignalServiceKit/src/Messages/OWSMessageReceiver.m b/SignalServiceKit/src/Messages/OWSMessageReceiver.m index c7b0d5cc37..a8ea49e9eb 100644 --- a/SignalServiceKit/src/Messages/OWSMessageReceiver.m +++ b/SignalServiceKit/src/Messages/OWSMessageReceiver.m @@ -330,7 +330,7 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin SSKProtoEnvelope *_Nullable envelope = job.envelopeProto; if (!envelope) { - OWSProdLogAndFail(@"%@ Could not parse proto.", self.logTag); + OWSFail(@"%@ Could not parse proto.", self.logTag); // TODO: Add analytics. [[OWSPrimaryStorage.sharedManager newDatabaseConnection] diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index ff11f19d87..6e45ebe202 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -177,7 +177,7 @@ void AssertIsOnSendingQueue() - (void)didSucceed { if (self.message.messageState != TSOutgoingMessageStateSent) { - OWSProdLogAndFail(@"%@ unexpected message status: %@", self.logTag, self.message.statusDescription); + OWSFail(@"%@ unexpected message status: %@", self.logTag, self.message.statusDescription); } self.successHandler(); @@ -570,7 +570,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; failure:failureHandler]; } else { // Neither a group nor contact thread? This should never happen. - OWSFail(@"%@ Unknown message type: %@", self.logTag, NSStringFromClass([message class])); + OWSFail(@"%@ Unknown message type: %@", self.logTag, [message class]); NSError *error = OWSErrorMakeFailedToSendOutgoingMessageError(); [error setIsRetryable:NO]; diff --git a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m index 7f1880824e..f1421cdcbb 100644 --- a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m +++ b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m @@ -452,12 +452,12 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE uint64_t messageIdTimestamp = readReceiptProto.timestamp; if (senderId.length == 0) { - OWSProdLogAndFail(@"%@ in %s senderId was unexpectedly nil", self.logTag, __PRETTY_FUNCTION__); + OWSFail(@"%@ in %s senderId was unexpectedly nil", self.logTag, __PRETTY_FUNCTION__); continue; } if (messageIdTimestamp == 0) { - OWSProdLogAndFail(@"%@ in %s messageIdTimestamp was unexpectedly 0", self.logTag, __PRETTY_FUNCTION__); + OWSFail(@"%@ in %s messageIdTimestamp was unexpectedly 0", self.logTag, __PRETTY_FUNCTION__); continue; } @@ -529,12 +529,11 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE BOOL *stop) { if (![object conformsToProtocol:@protocol(OWSReadTracking)]) { - OWSFail( - @"Expected to conform to OWSReadTracking: object with class: %@ collection: %@ " + OWSFail(@"Expected to conform to OWSReadTracking: object with class: %@ collection: %@ " @"key: %@", - [object class], - collection, - key); + [object class], + collection, + key); return; } id possiblyRead = (id)object; diff --git a/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m b/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m index 4f03207a09..61f01144d2 100644 --- a/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m +++ b/SignalServiceKit/src/Messages/PreKeyBundle+jsonDict.m @@ -15,14 +15,14 @@ NS_ASSUME_NONNULL_BEGIN id identityKeyObject = [dictionary objectForKey:@"identityKey"]; if (![identityKeyObject isKindOfClass:[NSString class]]) { - OWSFail(@"Unexpected identityKeyObject: %@", identityKeyObject); + OWSFail(@"Unexpected identityKeyObject: %@", [identityKeyObject class]); return nil; } NSString *identityKeyString = (NSString *)identityKeyObject; id devicesObject = [dictionary objectForKey:@"devices"]; if (![devicesObject isKindOfClass:[NSArray class]]) { - OWSFail(@"Unexpected devicesObject: %@", devicesObject); + OWSFail(@"Unexpected devicesObject: %@", [devicesObject class]); return nil; } NSArray *devicesArray = (NSArray *)devicesObject; diff --git a/SignalServiceKit/src/Network/API/OWSUploadOperation.m b/SignalServiceKit/src/Network/API/OWSUploadOperation.m index efaaff82e2..f9019e628f 100644 --- a/SignalServiceKit/src/Network/API/OWSUploadOperation.m +++ b/SignalServiceKit/src/Network/API/OWSUploadOperation.m @@ -123,7 +123,7 @@ static const CGFloat kAttachmentUploadProgressTheta = 0.001f; NSData *_Nullable encryptedAttachmentData = [Cryptography encryptAttachmentData:attachmentData outKey:&encryptionKey outDigest:&digest]; if (!encryptedAttachmentData) { - OWSProdLogAndFail(@"%@ could not encrypt attachment data.", self.logTag); + OWSFail(@"%@ could not encrypt attachment data.", self.logTag); error = OWSErrorMakeFailedToSendOutgoingMessageError(); error.isRetryable = YES; [self reportError:error]; diff --git a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m index f527c08f46..15eb3166e1 100644 --- a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m +++ b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m @@ -485,7 +485,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ options:(NSJSONWritingOptions)0 error:&error]; if (!jsonData || error) { - OWSProdLogAndFail(@"%@ could not serialize request JSON: %@", self.logTag, error); + OWSFail(@"%@ could not serialize request JSON: %@", self.logTag, error); [socketMessage didFailBeforeSending]; return; } @@ -516,7 +516,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ NSData *_Nullable messageData = [messageBuilder buildSerializedDataAndReturnError:&error]; if (!messageData || error) { - OWSProdLogAndFail(@"%@ could not serialize proto: %@.", self.logTag, error); + OWSFail(@"%@ could not serialize proto: %@.", self.logTag, error); [socketMessage didFailBeforeSending]; return; } @@ -529,7 +529,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ BOOL wasScheduled = [self.websocket sendDataNoCopy:messageData error:&error]; if (!wasScheduled || error) { - OWSProdLogAndFail(@"%@ could not send socket request: %@", self.logTag, error); + OWSFail(@"%@ could not send socket request: %@", self.logTag, error); [socketMessage didFailBeforeSending]; return; } @@ -587,7 +587,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ id _Nullable responseJson = [NSJSONSerialization JSONObjectWithData:responseData options:(NSJSONReadingOptions)0 error:&error]; if (!responseJson || error) { - OWSProdLogAndFail(@"%@ could not parse WebSocket response JSON: %@.", self.logTag, error); + OWSFail(@"%@ could not parse WebSocket response JSON: %@.", self.logTag, error); hasValidResponse = NO; } else { responseObject = responseJson; @@ -745,7 +745,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ [self.messageReceiver handleReceivedEnvelopeData:decryptedPayload]; } @catch (NSException *exception) { - OWSProdLogAndFail(@"%@ Received an invalid envelope: %@", self.logTag, exception.debugDescription); + OWSFail(@"%@ Received an invalid envelope: %@", self.logTag, exception.debugDescription); // TODO: Add analytics. [[OWSPrimaryStorage.sharedManager newDatabaseConnection] readWriteWithBlock:^( diff --git a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m index bcb7a00ca7..ac119f0c0f 100644 --- a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m +++ b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SessionStore.m @@ -183,7 +183,7 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey"; for (id deviceId in sessionRecords) { id object = sessionRecords[deviceId]; if (![object isKindOfClass:[SessionRecord class]]) { - OWSFail(@"Unexpected object in session dict: %@", object); + OWSFail(@"Unexpected object in session dict: %@", [object class]); continue; } @@ -218,8 +218,9 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey"; id _Nonnull deviceSessionsObject, BOOL *_Nonnull stop) { if (![deviceSessionsObject isKindOfClass:[NSDictionary class]]) { - OWSFail( - @"%@ Unexpected type: %@ in collection.", tag, deviceSessionsObject); + OWSFail(@"%@ Unexpected type: %@ in collection.", + tag, + [deviceSessionsObject class]); return; } NSDictionary *deviceSessions = (NSDictionary *)deviceSessionsObject; @@ -230,7 +231,7 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey"; if (![sessionRecordObject isKindOfClass:[SessionRecord class]]) { OWSFail(@"%@ Unexpected type: %@ in collection.", tag, - sessionRecordObject); + [sessionRecordObject class]); return; } SessionRecord *sessionRecord = (SessionRecord *)sessionRecordObject; diff --git a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SignedPreKeyStore.m b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SignedPreKeyStore.m index 1b3565ce8c..dd4f83b645 100644 --- a/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SignedPreKeyStore.m +++ b/SignalServiceKit/src/Storage/AxolotlStore/OWSPrimaryStorage+SignedPreKeyStore.m @@ -3,7 +3,6 @@ // #import "OWSPrimaryStorage+SignedPreKeyStore.h" -#import "Cryptography.h" #import "OWSIdentityManager.h" #import "OWSPrimaryStorage+PreKeyStore.h" #import "OWSPrimaryStorage+keyFromIntLong.h" @@ -176,7 +175,7 @@ NSString *const OWSPrimaryStorageKeyPrekeyCurrentSignedPrekeyId = @"currentSigne if (![signedPreKeyObject isKindOfClass:[SignedPreKeyRecord class]]) { OWSFail(@"%@ Was expecting SignedPreKeyRecord, but found: %@", tag, - signedPreKeyObject); + [signedPreKeyObject class]); return; } SignedPreKeyRecord *signedPreKeyRecord diff --git a/SignalServiceKit/src/Storage/OWSPrimaryStorage.m b/SignalServiceKit/src/Storage/OWSPrimaryStorage.m index d21dcebea7..2a9d27050e 100644 --- a/SignalServiceKit/src/Storage/OWSPrimaryStorage.m +++ b/SignalServiceKit/src/Storage/OWSPrimaryStorage.m @@ -39,8 +39,7 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage) DDLogVerbose(@"Verifying database extension: %@", extensionName); YapDatabaseViewTransaction *_Nullable viewTransaction = [transaction ext:extensionName]; if (!viewTransaction) { - OWSProdLogAndCFail( - @"VerifyRegistrationsForPrimaryStorage missing database extension: %@", extensionName); + OWSCFail(@"VerifyRegistrationsForPrimaryStorage missing database extension: %@", extensionName); [OWSStorage incrementVersionOfDatabaseExtension:extensionName]; } diff --git a/SignalServiceKit/src/Storage/OWSStorage.m b/SignalServiceKit/src/Storage/OWSStorage.m index 6e23bc3949..d4d898dd02 100644 --- a/SignalServiceKit/src/Storage/OWSStorage.m +++ b/SignalServiceKit/src/Storage/OWSStorage.m @@ -207,7 +207,7 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ - (void)encodeWithCoder:(NSCoder *)aCoder { - OWSProdLogAndFail(@"%@ Tried to save object from unknown collection", self.logTag); + OWSFail(@"%@ Tried to save object from unknown collection", self.logTag); return [super encodeWithCoder:aCoder]; } @@ -224,21 +224,21 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ - (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction { - OWSProdLogAndFail(@"%@ Tried to save unknown object", self.logTag); + OWSFail(@"%@ Tried to save unknown object", self.logTag); // No-op. } - (void)touchWithTransaction:(YapDatabaseReadWriteTransaction *)transaction { - OWSProdLogAndFail(@"%@ Tried to touch unknown object", self.logTag); + OWSFail(@"%@ Tried to touch unknown object", self.logTag); // No-op. } - (void)removeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction { - OWSProdLogAndFail(@"%@ Tried to remove unknown object", self.logTag); + OWSFail(@"%@ Tried to remove unknown object", self.logTag); // No-op. } @@ -262,7 +262,7 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ if ([name isEqualToString:@"TSRecipient"]) { DDLogError(@"%@ Could not decode object: %@", self.logTag, name); } else { - OWSProdLogAndFail(@"%@ Could not decode object: %@", self.logTag, name); + OWSFail(@"%@ Could not decode object: %@", self.logTag, name); } OWSProdCritical([OWSAnalyticsEvents storageErrorCouldNotDecodeClass]); return [OWSUnknownDBObject class]; @@ -344,14 +344,14 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ - (BOOL)areAsyncRegistrationsComplete { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return NO; } - (BOOL)areSyncRegistrationsComplete { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return NO; } @@ -363,12 +363,12 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ - (void)runSyncRegistrations { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); } - (void)runAsyncRegistrationsWithCompletion:(void (^_Nonnull)(void))completion { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); } + (void)registerExtensionsWithMigrationBlock:(OWSStorageMigrationBlock)migrationBlock @@ -482,7 +482,7 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ return ^id(NSString __unused *collection, NSString __unused *key, NSData *data) { if (!data || data.length <= 0) { - OWSProdLogAndFail(@"%@ can't deserialize null object: %@", self.logTag, collection); + OWSFail(@"%@ can't deserialize null object: %@", self.logTag, collection); return [OWSUnknownDBObject new]; } @@ -492,7 +492,7 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ return [unarchiver decodeObjectForKey:@"root"]; } @catch (NSException *exception) { // Sync log in case we bail. - OWSProdLogAndFail(@"%@ error deserializing object: %@, %@", self.logTag, collection, exception); + OWSFail(@"%@ error deserializing object: %@, %@", self.logTag, collection, exception); OWSProdCritical([OWSAnalyticsEvents storageErrorDeserialization]); @throw exception; } @@ -592,7 +592,7 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ // This method needs to be able to update the versionTag of all extensions. // If we start using other extension types, we need to modify this method to // handle them as well. - OWSProdLogAndFail(@"%@ Unknown extension type: %@", self.logTag, [extension class]); + OWSFail(@"%@ Unknown extension type: %@", self.logTag, [extension class]); return extension; } @@ -689,21 +689,21 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_ - (NSString *)databaseFilePath { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return @""; } - (NSString *)databaseFilePath_SHM { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return @""; } - (NSString *)databaseFilePath_WAL { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return @""; } diff --git a/SignalServiceKit/src/Storage/TSDatabaseView.m b/SignalServiceKit/src/Storage/TSDatabaseView.m index 8e0d1e0b23..1d11011d83 100644 --- a/SignalServiceKit/src/Storage/TSDatabaseView.m +++ b/SignalServiceKit/src/Storage/TSDatabaseView.m @@ -128,7 +128,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *( YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) { if (![object isKindOfClass:[TSInteraction class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); return nil; } TSInteraction *interaction = (TSInteraction *)object; @@ -156,7 +156,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *( YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) { if (![object isKindOfClass:[TSInteraction class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); return nil; } TSInteraction *interaction = (TSInteraction *)object; @@ -197,7 +197,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *( YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) { if (![object isKindOfClass:[TSThread class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); return nil; } TSThread *thread = (TSThread *)object; @@ -270,11 +270,11 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" NSString *key2, id object2) { if (![object1 isKindOfClass:[TSThread class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); return NSOrderedSame; } if (![object2 isKindOfClass:[TSThread class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); return NSOrderedSame; } TSThread *thread1 = (TSThread *)object1; @@ -297,11 +297,11 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" NSString *key2, id object2) { if (![object1 isKindOfClass:[TSInteraction class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); return NSOrderedSame; } if (![object2 isKindOfClass:[TSInteraction class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); return NSOrderedSame; } TSInteraction *message1 = (TSInteraction *)object1; @@ -316,7 +316,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *_Nullable( YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) { if (![object isKindOfClass:[OWSDevice class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); return nil; } OWSDevice *device = (OWSDevice *)object; @@ -336,11 +336,11 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" NSString *key2, id object2) { if (![object1 isKindOfClass:[OWSDevice class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); return NSOrderedSame; } if (![object2 isKindOfClass:[OWSDevice class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); return NSOrderedSame; } OWSDevice *device1 = (OWSDevice *)object1; @@ -366,7 +366,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *_Nullable( YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) { if (![object isKindOfClass:[TSAttachment class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object class], collection); return nil; } if (![object isKindOfClass:[TSAttachmentStream class]]) { @@ -390,11 +390,11 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" NSString *key2, id object2) { if (![object1 isKindOfClass:[TSAttachmentStream class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object1 class], collection1); return NSOrderedSame; } if (![object2 isKindOfClass:[TSAttachmentStream class]]) { - OWSProdLogAndFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); + OWSFail(@"%@ Unexpected entity %@ in collection: %@", self.logTag, [object2 class], collection2); return NSOrderedSame; } diff --git a/SignalServiceKit/src/Util/DataSource.m b/SignalServiceKit/src/Util/DataSource.m index fcebd4511f..322bf624b8 100755 --- a/SignalServiceKit/src/Util/DataSource.m +++ b/SignalServiceKit/src/Util/DataSource.m @@ -32,31 +32,31 @@ NS_ASSUME_NONNULL_BEGIN - (NSData *)data { - OWSFail(@"%@ Missing required method: data", self.logTag); + OWSAbstractMethod(); return nil; } - (nullable NSURL *)dataUrl { - OWSFail(@"%@ Missing required method: dataUrl", self.logTag); + OWSAbstractMethod(); return nil; } - (nullable NSString *)dataPathIfOnDisk { - OWSFail(@"%@ Missing required method: dataPathIfOnDisk", self.logTag); + OWSAbstractMethod(); return nil; } - (NSUInteger)dataLength { - OWSFail(@"%@ Missing required method: dataLength", self.logTag); + OWSAbstractMethod(); return 0; } - (BOOL)writeToPath:(NSString *)dstFilePath { - OWSFail(@"%@ Missing required method: writeToPath:", self.logTag); + OWSAbstractMethod(); return NO; } @@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN // Returns the MIME type, if known. - (nullable NSString *)mimeType { - OWS_ABSTRACT_METHOD(); + OWSAbstractMethod(); return nil; } @@ -188,7 +188,8 @@ NS_ASSUME_NONNULL_BEGIN if ([self writeToPath:filePath]) { self.cachedFilePath = filePath; } else { - OWSFail(@"%@ Could not write data to disk: %@", self.logTag, self.fileExtension); + DDLogDebug(@"%@ Could not write data to disk: %@", self.logTag, self.fileExtension); + OWSFail(@"%@ Could not write data to disk.", self.logTag); } } @@ -219,7 +220,8 @@ NS_ASSUME_NONNULL_BEGIN BOOL success = [dataCopy writeToFile:dstFilePath atomically:YES]; if (!success) { - OWSFail(@"%@ Could not write data to disk: %@", self.logTag, dstFilePath); + DDLogDebug(@"%@ Could not write data to disk: %@", self.logTag, dstFilePath); + OWSFail(@"%@ Could not write data to disk.", self.logTag); return NO; } else { return YES; @@ -318,7 +320,8 @@ NS_ASSUME_NONNULL_BEGIN self.cachedData = [NSData dataWithContentsOfFile:self.filePath]; } if (!self.cachedData) { - OWSFail(@"%@ Could not read data from disk: %@", self.logTag, self.filePath); + DDLogDebug(@"%@ Could not read data from disk: %@", self.logTag, self.filePath); + OWSFail(@"%@ Could not read data from disk.", self.logTag); self.cachedData = [NSData new]; } return self.cachedData; @@ -357,7 +360,8 @@ NS_ASSUME_NONNULL_BEGIN NSDictionary *_Nullable attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.filePath error:&error]; if (!attributes || error) { - OWSFail(@"%@ Could not read data length from disk: %@, %@", self.logTag, self.filePath, error); + DDLogDebug(@"%@ Could not read data length from disk: %@, %@", self.logTag, self.filePath, error); + OWSFail(@"%@ Could not read data length from disk with error: %@", self.logTag, error); self.cachedDataLength = @(0); } else { uint64_t fileSize = [attributes fileSize]; @@ -375,8 +379,9 @@ NS_ASSUME_NONNULL_BEGIN NSError *error; BOOL success = [[NSFileManager defaultManager] copyItemAtPath:self.filePath toPath:dstFilePath error:&error]; if (!success || error) { - OWSFail( + DDLogDebug( @"%@ Could not write data from path: %@, to path: %@, %@", self.logTag, self.filePath, dstFilePath, error); + OWSFail(@"%@ Could not write data with error: %@", self.logTag, error); return NO; } else { return YES; diff --git a/SignalServiceKit/src/Util/NSString+SSK.m b/SignalServiceKit/src/Util/NSString+SSK.m index 549d23f4e6..b6fb032d27 100644 --- a/SignalServiceKit/src/Util/NSString+SSK.m +++ b/SignalServiceKit/src/Util/NSString+SSK.m @@ -212,8 +212,10 @@ NS_ASSUME_NONNULL_BEGIN return YES; } else if (range.location != index || range.length < 1) { // This should never happen. - OWSFail( - @"%@ unexpected composed character sequence: %lu, %@", self.logTag, (unsigned long)index, NSStringFromRange(range)); + OWSFail(@"%@ unexpected composed character sequence: %lu, %@", + self.logTag, + (unsigned long)index, + NSStringFromRange(range)); return YES; } index = range.location + range.length; diff --git a/SignalServiceKit/src/Util/OWSAsserts.h b/SignalServiceKit/src/Util/OWSAsserts.h index db908206a9..73d355b4de 100755 --- a/SignalServiceKit/src/Util/OWSAsserts.h +++ b/SignalServiceKit/src/Util/OWSAsserts.h @@ -19,55 +19,56 @@ NS_ASSUME_NONNULL_BEGIN // OWSCAssert() and OWSCFail() should be used in free functions. #define OWSAssert(X) \ - if (!(X)) { \ - DDLogError(@"%s Assertion failed: %s", __PRETTY_FUNCTION__, CONVERT_EXPR_TO_STRING(X)); \ - [DDLog flushLog]; \ - NSAssert(0, @"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - } + do { \ + if (!(X)) { \ + DDLogError(@"%s Assertion failed: %s", __PRETTY_FUNCTION__, CONVERT_EXPR_TO_STRING(X)); \ + [DDLog flushLog]; \ + NSAssert(0, @"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ + } \ + } while (NO) #define OWSCAssert(X) \ - if (!(X)) { \ - DDLogError(@"%s Assertion failed: %s", __PRETTY_FUNCTION__, CONVERT_EXPR_TO_STRING(X)); \ - [DDLog flushLog]; \ - NSCAssert(0, @"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ - } + do { \ + if (!(X)) { \ + DDLogError(@"%s Assertion failed: %s", __PRETTY_FUNCTION__, CONVERT_EXPR_TO_STRING(X)); \ + [DDLog flushLog]; \ + NSCAssert(0, @"Assertion failed: %s", CONVERT_EXPR_TO_STRING(X)); \ + } \ + } while (NO) -#define OWSFail(message, ...) \ - { \ +#define OWSFailWithoutLogging(message, ...) \ + do { \ NSString *formattedMessage = [NSString stringWithFormat:message, ##__VA_ARGS__]; \ - DDLogError(@"%s %@", __PRETTY_FUNCTION__, formattedMessage); \ - [DDLog flushLog]; \ NSAssert(0, formattedMessage); \ - } + } while (NO) -#define OWSCFail(message, ...) \ - { \ + +#define OWSCFailWithoutLogging(message, ...) \ + do { \ NSString *formattedMessage = [NSString stringWithFormat:message, ##__VA_ARGS__]; \ - DDLogError(@"%s %@", __PRETTY_FUNCTION__, formattedMessage); \ - [DDLog flushLog]; \ NSCAssert(0, formattedMessage); \ - } + } while (NO) #define OWSFailNoFormat(message) \ - { \ + do { \ DDLogError(@"%s %@", __PRETTY_FUNCTION__, message); \ [DDLog flushLog]; \ NSAssert(0, message); \ - } + } while (NO) #define OWSCFailNoFormat(message) \ - { \ + do { \ DDLogError(@"%s %@", __PRETTY_FUNCTION__, message); \ [DDLog flushLog]; \ NSCAssert(0, message); \ - } + } while (NO) #else #define OWSAssert(X) #define OWSCAssert(X) -#define OWSFail(message, ...) -#define OWSCFail(message, ...) +#define OWSFailWithoutLogging(message, ...) +#define OWSCFailWithoutLogging(message, ...) #define OWSFailNoFormat(X) #define OWSCFailNoFormat(X) @@ -75,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN #endif -#define OWS_ABSTRACT_METHOD() OWSFail(@"%@ Method needs to be implemented by subclasses.", self.logTag) +#define OWSAbstractMethod() OWSFail(@"%@ Method needs to be implemented by subclasses.", self.logTag) #pragma mark - Singleton Asserts @@ -123,19 +124,19 @@ NS_ASSUME_NONNULL_BEGIN // This macro is intended for use in Objective-C. #define OWSAssertIsOnMainThread() OWSCAssert([NSThread isMainThread]) -#define OWSProdLogAndFail(_messageFormat, ...) \ - { \ +#define OWSFail(_messageFormat, ...) \ + do { \ DDLogError(_messageFormat, ##__VA_ARGS__); \ [DDLog flushLog]; \ - OWSFail(_messageFormat, ##__VA_ARGS__); \ - } + OWSFailWithoutLogging(_messageFormat, ##__VA_ARGS__); \ + } while (0) -#define OWSProdLogAndCFail(_messageFormat, ...) \ - { \ +#define OWSCFail(_messageFormat, ...) \ + do { \ DDLogError(_messageFormat, ##__VA_ARGS__); \ [DDLog flushLog]; \ - OWSCFail(_messageFormat, ##__VA_ARGS__); \ - } + OWSCFailWithoutLogging(_messageFormat, ##__VA_ARGS__); \ + } while (NO) // Avoids Clang analyzer warning: @@ -154,23 +155,23 @@ __attribute__((annotate("returns_localized_nsstring"))) static inline NSString * void SwiftAssertIsOnMainThread(NSString *functionName); #define OWSRaiseException(name, formatParam, ...) \ - { \ + do { \ DDLogError(@"Exception: %@ %@", name, [NSString stringWithFormat:formatParam, ##__VA_ARGS__]); \ [DDLog flushLog]; \ @throw [NSException exceptionWithName:name \ reason:[NSString stringWithFormat:formatParam, ##__VA_ARGS__] \ userInfo:nil]; \ - } + } while (NO) #define OWSRaiseExceptionWithUserInfo(name, userInfoParam, formatParam, ...) \ - { \ + do { \ DDLogError( \ @"Exception: %@ %@ %@", name, userInfoParam, [NSString stringWithFormat:formatParam, ##__VA_ARGS__]); \ [DDLog flushLog]; \ @throw [NSException exceptionWithName:name \ reason:[NSString stringWithFormat:formatParam, ##__VA_ARGS__] \ userInfo:userInfoParam]; \ - } + } while (NO) // UI JANK diff --git a/SignalServiceKit/src/Util/OWSFileSystem.m b/SignalServiceKit/src/Util/OWSFileSystem.m index 88c53f0914..247675c552 100644 --- a/SignalServiceKit/src/Util/OWSFileSystem.m +++ b/SignalServiceKit/src/Util/OWSFileSystem.m @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN BOOL isDirectory; BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory]; if (!exists) { - OWSFail(@"%@ error retrieving file attributes for issing file", self.logTag); + OWSFail(@"%@ error retrieving file attributes for missing file", self.logTag); return; } @@ -137,11 +137,12 @@ NS_ASSUME_NONNULL_BEGIN NSError *_Nullable error; BOOL success = [fileManager moveItemAtPath:oldFilePath toPath:newFilePath error:&error]; if (!success || error) { - OWSProdLogAndFail(@"%@ Could not move file or directory from: %@ to: %@, error: %@", + DDLogDebug(@"%@ Could not move file or directory from: %@ to: %@, error: %@", self.logTag, oldFilePath, newFilePath, error); + OWSFail(@"%@ Could not move file or directory with error: %@", self.logTag, error); return error; } return nil; @@ -166,10 +167,11 @@ NS_ASSUME_NONNULL_BEGIN } if ([fileManager fileExistsAtPath:newFilePath]) { - OWSProdLogAndFail(@"%@ Can't move file or directory from: %@ to: %@; destination already exists.", + DDLogDebug(@"%@ Can't move file or directory from: %@ to: %@; destination already exists.", self.logTag, oldFilePath, newFilePath); + OWSFail(@"%@ Can't move file or directory; destination already exists.", self.logTag); return OWSErrorWithCodeDescription( OWSErrorCodeMoveFileToSharedDataContainerError, @"Can't move file; destination already exists."); } @@ -179,15 +181,17 @@ NS_ASSUME_NONNULL_BEGIN NSError *_Nullable error; BOOL success = [fileManager moveItemAtPath:oldFilePath toPath:newFilePath error:&error]; if (!success || error) { - OWSProdLogAndFail(@"%@ Could not move file or directory from: %@ to: %@, error: %@", + DDLogDebug(@"%@ Could not move file or directory from: %@ to: %@, error: %@", self.logTag, oldFilePath, newFilePath, error); + OWSFail(@"%@ Could not move file or directory with error: %@", self.logTag, error); return error; } - DDLogInfo(@"%@ Moved file or directory from: %@ to: %@ in: %f", + DDLogInfo(@"%@ Moved file or directory in: %f", self.logTag, fabs([startDate timeIntervalSinceNow])); + DDLogDebug(@"%@ Moved file or directory from: %@ to: %@ in: %f", self.logTag, oldFilePath, newFilePath, diff --git a/SignalServiceKit/src/Util/OWSOperation.m b/SignalServiceKit/src/Util/OWSOperation.m index da9fa32e89..a57743ea90 100644 --- a/SignalServiceKit/src/Util/OWSOperation.m +++ b/SignalServiceKit/src/Util/OWSOperation.m @@ -71,7 +71,7 @@ NSString *const OWSOperationKeyIsFinished = @"isFinished"; // Called every retry, this is where the bulk of the operation's work should go. - (void)run { - OWSFail(@"%@ Abstract method", self.logTag); + OWSAbstractMethod(); } // Called at most one time. diff --git a/SignalShareExtension/utils/ShareAppExtensionContext.m b/SignalShareExtension/utils/ShareAppExtensionContext.m index 92ea289805..6e58f2042e 100644 --- a/SignalShareExtension/utils/ShareAppExtensionContext.m +++ b/SignalShareExtension/utils/ShareAppExtensionContext.m @@ -210,7 +210,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)runNowOrWhenMainAppIsActive:(AppActiveBlock)block { - OWSProdLogAndFail(@"%@ cannot run main app active blocks in share extension.", self.logTag); + OWSFail(@"%@ cannot run main app active blocks in share extension.", self.logTag); } @end