From c50b8dd0d3140f2d718cff28f88b96fcc3c3d8a5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:44:01 -0600 Subject: [PATCH 1/9] fix compiler warning --- SignalServiceKit/src/Util/MessageSender+Promise.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/SignalServiceKit/src/Util/MessageSender+Promise.swift b/SignalServiceKit/src/Util/MessageSender+Promise.swift index e6f078918..e117f5b61 100644 --- a/SignalServiceKit/src/Util/MessageSender+Promise.swift +++ b/SignalServiceKit/src/Util/MessageSender+Promise.swift @@ -4,7 +4,6 @@ import Foundation import PromiseKit -import SignalServiceKit public extension MessageSender { From b79860ae0ff324e00a08c74cb0e40e990d5f08fd Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:45:06 -0600 Subject: [PATCH 2/9] fix compiler doc warning --- SignalServiceKit/src/Storage/TSYapDatabaseObject.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Storage/TSYapDatabaseObject.h b/SignalServiceKit/src/Storage/TSYapDatabaseObject.h index a47704e88..62864f7ca 100644 --- a/SignalServiceKit/src/Storage/TSYapDatabaseObject.h +++ b/SignalServiceKit/src/Storage/TSYapDatabaseObject.h @@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN @interface TSYapDatabaseObject : MTLModel +- (instancetype)init NS_DESIGNATED_INITIALIZER; + /** * Initializes a new database object with a unique identifier * @@ -20,8 +22,8 @@ NS_ASSUME_NONNULL_BEGIN * * @return Initialized object */ -- (instancetype)init NS_DESIGNATED_INITIALIZER; - (instancetype)initWithUniqueId:(NSString *_Nullable)uniqueId NS_DESIGNATED_INITIALIZER; + - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; /** From 24f97f12295a115c3b74725725c230501dc163c9 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:54:42 -0600 Subject: [PATCH 3/9] compiler warning: discard result explicitly --- .../ConversationView/Cells/ConversationMediaView.swift | 4 ++-- Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift | 4 ++-- Signal/src/call/UserInterface/CallUIAdapter.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/ConversationMediaView.swift b/Signal/src/ViewControllers/ConversationView/Cells/ConversationMediaView.swift index 265b57c24..7e1889f22 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/ConversationMediaView.swift +++ b/Signal/src/ViewControllers/ConversationView/Cells/ConversationMediaView.swift @@ -128,7 +128,7 @@ public class ConversationMediaView: UIView { animatedImageView.backgroundColor = Theme.offBackgroundColor addSubview(animatedImageView) animatedImageView.autoPinEdgesToSuperviewEdges() - addUploadProgressIfNecessary(animatedImageView) + _ = addUploadProgressIfNecessary(animatedImageView) loadBlock = { [weak self] in guard let strongSelf = self else { @@ -177,7 +177,7 @@ public class ConversationMediaView: UIView { stillImageView.backgroundColor = Theme.offBackgroundColor addSubview(stillImageView) stillImageView.autoPinEdgesToSuperviewEdges() - addUploadProgressIfNecessary(stillImageView) + _ = addUploadProgressIfNecessary(stillImageView) loadBlock = { [weak self] in guard let strongSelf = self else { return diff --git a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift index 6e0970623..ee237667b 100644 --- a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift +++ b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift @@ -113,7 +113,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { let call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: handle) // make sure we don't terminate audio session during call - self.audioSession.startAudioActivity(call.audioActivity) + _ = self.audioSession.startAudioActivity(call.audioActivity) // Add the new outgoing call to the app's list of calls. // So we can find it in the provider delegate callbacks. @@ -385,7 +385,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { Logger.debug("Received") - self.audioSession.startAudioActivity(self.audioActivity) + _ = self.audioSession.startAudioActivity(self.audioActivity) self.audioSession.isRTCAudioEnabled = true } diff --git a/Signal/src/call/UserInterface/CallUIAdapter.swift b/Signal/src/call/UserInterface/CallUIAdapter.swift index a7cd703dd..44f733995 100644 --- a/Signal/src/call/UserInterface/CallUIAdapter.swift +++ b/Signal/src/call/UserInterface/CallUIAdapter.swift @@ -141,7 +141,7 @@ extension CallUIAdaptee { AssertIsOnMainThread() // make sure we don't terminate audio session during call - audioSession.startAudioActivity(call.audioActivity) + _ = audioSession.startAudioActivity(call.audioActivity) let callerName = self.contactsManager.displayName(forPhoneIdentifier: call.remotePhoneNumber) adaptee.reportIncomingCall(call, callerName: callerName) From 2a1c62f6f56ba0436ba6dd0b67a17af88714ec03 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:55:00 -0600 Subject: [PATCH 4/9] remove unused delegate method declaration --- .../ConversationView/ConversationInputTextView.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.h b/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.h index 2c3c561d2..726ac1627 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.h @@ -14,8 +14,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)inputTextViewSendMessagePressed; -- (void)inputTextViewDidChangeText; - - (void)textViewDidChange:(UITextView *)textView; @end From 97e9871f19b03ffb2de8cc46201537dba9e7ae89 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:55:06 -0600 Subject: [PATCH 5/9] remove unnecessary implicitly unwrapped optional --- .../ConversationView/TypingIndicatorInteraction.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/TypingIndicatorInteraction.swift b/Signal/src/ViewControllers/ConversationView/TypingIndicatorInteraction.swift index f2bfc47cf..9ae0d7c13 100644 --- a/Signal/src/ViewControllers/ConversationView/TypingIndicatorInteraction.swift +++ b/Signal/src/ViewControllers/ConversationView/TypingIndicatorInteraction.swift @@ -43,7 +43,7 @@ public class TypingIndicatorInteraction: TSInteraction { } @objc - public override func save(with transaction: YapDatabaseReadWriteTransaction!) { + public override func save(with transaction: YapDatabaseReadWriteTransaction) { owsFailDebug("The transient interaction should not be saved in the database.") } } From 54059532f7f6c8092b7e8f8d550c0011d0f05c2d Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:55:29 -0600 Subject: [PATCH 6/9] remove unused strong capture --- Signal/src/call/OutboundCallInitiator.swift | 22 ++++++--------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Signal/src/call/OutboundCallInitiator.swift b/Signal/src/call/OutboundCallInitiator.swift index fab377192..3f996d855 100644 --- a/Signal/src/call/OutboundCallInitiator.swift +++ b/Signal/src/call/OutboundCallInitiator.swift @@ -19,13 +19,11 @@ import SignalMessaging // MARK: - Dependencies - private var contactsManager : OWSContactsManager - { + private var contactsManager: OWSContactsManager { return Environment.shared.contactsManager } - private var contactsUpdater : ContactsUpdater - { + private var contactsUpdater: ContactsUpdater { return SSKEnvironment.shared.contactsUpdater } @@ -48,7 +46,9 @@ import SignalMessaging /** * |recipientId| is a e164 formatted phone number. */ - @discardableResult @objc public func initiateCall(recipientId: String, + @discardableResult + @objc + public func initiateCall(recipientId: String, isVideo: Bool) -> Bool { guard let callUIAdapter = AppEnvironment.shared.callService.callUIAdapter else { owsFailDebug("missing callUIAdapter") @@ -71,17 +71,7 @@ import SignalMessaging return false } - // Check for microphone permissions - // Alternative way without prompting for permissions: - // if AVAudioSession.sharedInstance().recordPermission() == .denied { - frontmostViewController.ows_ask(forMicrophonePermissions: { [weak self] granted in - // Success callback; camera permissions are granted. - - guard let strongSelf = self else { - return - } - - // Here the permissions are either granted or denied + frontmostViewController.ows_ask(forMicrophonePermissions: { granted in guard granted == true else { Logger.warn("aborting due to missing microphone permissions.") OWSAlerts.showNoMicrophonePermissionAlert() From 3c450eeeaa374ed4c3d51e1cd6bfa13e3d03806d Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:55:52 -0600 Subject: [PATCH 7/9] degrade from crashing to debug assert, upon failure we return a fully (overly) redacted string --- Signal/src/call/PeerConnectionClient.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/call/PeerConnectionClient.swift b/Signal/src/call/PeerConnectionClient.swift index 02e7298f9..b2f5db84b 100644 --- a/Signal/src/call/PeerConnectionClient.swift +++ b/Signal/src/call/PeerConnectionClient.swift @@ -1163,7 +1163,7 @@ class HardenedRTCSessionDescription { options: .caseInsensitive) return regex.stringByReplacingMatches(in: sdp, options: [], range: NSRange(location: 0, length: sdp.count), withTemplate: "[ REDACTED_IPV6_ADDRESS ]") } catch { - owsFail("Could not redact IPv6 addresses.") + owsFailDebug("Could not redact IPv6 addresses.") return "[Could not redact IPv6 addresses.]" } #endif From 2bd3e5ef23795ba22614a149e5e196e3bbf3966c Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 09:59:51 -0600 Subject: [PATCH 8/9] cast to same integer signedness for comparison --- SignalMessaging/profiles/OWSProfileManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index 3f66e4766..fd371eed1 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -585,7 +585,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error); uint8_t byte = (uint8_t)(0xff & byteValue); [groupId appendBytes:&byte length:1]; } - if (groupId.length != kGroupIdLength) { + if (groupId.length != (NSUInteger)kGroupIdLength) { OWSFailDebug(@"Parsed group id has unexpected length: %@ (%lu)", groupId.hexadecimalString, (unsigned long)groupId.length); From 27f66f9f24ace6f922fbb5e34c717f6bffbb2980 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 12 Nov 2018 10:00:02 -0600 Subject: [PATCH 9/9] explicitly discard result --- SignalShareExtension/ShareViewController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index 3d0581de0..946133374 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -172,7 +172,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed // At this point, potentially lengthy DB locking migrations could be running. // Avoid blocking app launch by putting all further possible DB access in async block DispatchQueue.global().async { [weak self] in - guard let strongSelf = self else { return } + guard let _ = self else { return } Logger.info("running post launch block for registered user: \(TSAccountManager.localNumber)") // We don't need to use OWSDisappearingMessagesJob in the SAE. @@ -191,7 +191,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed if TSAccountManager.isRegistered() { DispatchQueue.main.async { [weak self] in - guard let strongSelf = self else { return } + guard let _ = self else { return } Logger.info("running post launch block for registered user: \(TSAccountManager.localNumber)") // We don't need to use the TSSocketManager in the SAE. @@ -694,7 +694,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed let loadCompletion: NSItemProvider.CompletionHandler = { [weak self] (value, error) in - guard let strongSelf = self else { return } + guard let _ = self else { return } guard error == nil else { resolver.reject(error!)