Skip to content

Commit c30e66e

Browse files
Fix static analyzer warnings
1 parent 3abf10e commit c30e66e

23 files changed

+65
-88
lines changed

ChatSecure.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,7 +3523,7 @@
35233523
CODE_SIGN_IDENTITY = "iPhone Developer";
35243524
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
35253525
CODE_SIGN_STYLE = Automatic;
3526-
DEVELOPMENT_TEAM = "";
3526+
DEVELOPMENT_TEAM = 4T8JLQR6GR;
35273527
FRAMEWORK_SEARCH_PATHS = (
35283528
"$(inherited)",
35293529
"$(PROJECT_DIR)/Carthage/Build/iOS",
@@ -3561,7 +3561,7 @@
35613561
CODE_SIGN_IDENTITY = "iPhone Developer";
35623562
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
35633563
CODE_SIGN_STYLE = Automatic;
3564-
DEVELOPMENT_TEAM = "";
3564+
DEVELOPMENT_TEAM = 4T8JLQR6GR;
35653565
FRAMEWORK_SEARCH_PATHS = (
35663566
"$(inherited)",
35673567
"$(PROJECT_DIR)/Carthage/Build/iOS",

ChatSecure/Classes/Controllers/FileTransferManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ public class FileTransferManager: NSObject, OTRServerCapabilitiesDelegate {
360360
}
361361
mediaItem.parentObjectKey = message.messageKey
362362
mediaItem.parentObjectCollection = message.messageCollection
363-
let newPath = OTRMediaFileManager.path(for: mediaItem, buddyUniqueId: thread.threadIdentifier)
363+
guard let newPath = OTRMediaFileManager.path(for: mediaItem, buddyUniqueId: thread.threadIdentifier) else {
364+
return
365+
}
364366
self.connection.readWrite { transaction in
365367
message.save(with: transaction)
366368
mediaItem.save(with: transaction)

ChatSecure/Classes/Controllers/OTRAttachmentPicker.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
110110
finalImage = originalImage;
111111
}
112112

113-
if ([self.delegate respondsToSelector:@selector(attachmentPicker:gotPhoto:withInfo:)]) {
113+
if (finalImage && [self.delegate respondsToSelector:@selector(attachmentPicker:gotPhoto:withInfo:)]) {
114114
[self.delegate attachmentPicker:self gotPhoto:finalImage withInfo:info];
115115
}
116116

ChatSecure/Classes/Controllers/OTRAudioPlaybackController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@property (nonatomic, strong, readonly) OTRAudioItem *currentAudioItem;
1717
@property (nonatomic, weak, readonly) OTRAudioControlsView *currentAudioControlsView;
1818

19-
- (void)playAudioItem:(OTRAudioItem *)audioItem buddyUniqueId:(NSString *)buddyUniqueId error:(NSError **)error;
19+
- (BOOL)playAudioItem:(OTRAudioItem *)audioItem buddyUniqueId:(NSString *)buddyUniqueId error:(NSError **)error;
2020

2121
- (void)attachAudioControlsView:(OTRAudioControlsView *)audioControlsView;
2222

ChatSecure/Classes/Controllers/OTRAudioPlaybackController.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ - (void)updateTimeLabel
4444
[self.currentAudioControlsView setTime:currentTime];
4545
}
4646

47-
- (void)playURL:(NSURL *)url error:(NSError **)error;
47+
- (BOOL)playURL:(NSURL *)url error:(NSError **)error;
4848
{
4949
AVURLAsset *asset = [AVURLAsset assetWithURL:url];
5050
self.duration = CMTimeGetSeconds(asset.duration);
5151
self.currentAudioControlsView.playPuaseProgressView.status = OTRPlayPauseProgressViewStatusPause;
5252
error = nil;
53-
[self.audioSessionManager playAudioWithURL:url error:error];
53+
BOOL result = [self.audioSessionManager playAudioWithURL:url error:error];
5454

5555
self.currentAudioControlsView.playPuaseProgressView.status = OTRPlayPauseProgressViewStatusPause;
5656
[self.currentAudioControlsView setTime:0];
5757

5858
[self startLabelTimer];
59+
return result;
5960
}
6061

6162
- (void)startLabelTimer
@@ -93,13 +94,13 @@ - (void)startAnimatingArc
9394

9495
#pragma - mark Public Methods
9596

96-
- (void)playAudioItem:(OTRAudioItem *)audioItem buddyUniqueId:(NSString *)buddyUniqueId error:(NSError *__autoreleasing *)error
97+
- (BOOL)playAudioItem:(OTRAudioItem *)audioItem buddyUniqueId:(NSString *)buddyUniqueId error:(NSError *__autoreleasing *)error
9798
{
9899
NSURL *audioURL = [[OTRMediaServer sharedInstance] urlForMediaItem:audioItem buddyUniqueId:buddyUniqueId];
99100

100101
_currentAudioItem = audioItem;
101102

102-
[self playURL:audioURL error:error];
103+
return [self playURL:audioURL error:error];
103104
}
104105

105106
- (void)attachAudioControlsView:(OTRAudioControlsView *)audioControlsView

ChatSecure/Classes/Controllers/OTRAudioSessionManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
@property (nonatomic, weak) id<OTRAudioSessionManagerDelegate> delegate;
2727

28-
- (void)playAudioWithURL:(NSURL *)url error:(NSError **)error;
28+
- (BOOL)playAudioWithURL:(NSURL *)url error:(NSError **)error;
2929
- (void)pausePlaying;
3030
- (void)resumePlaying;
3131
- (void)stopPlaying;
@@ -34,7 +34,7 @@
3434
- (NSURL *)currentPlayerURL;
3535
- (BOOL)isPlaying;
3636

37-
- (void)recordAudioToURL:(NSURL *)url error:(NSError **)error;
37+
- (BOOL)recordAudioToURL:(NSURL *)url error:(NSError **)error;
3838
- (void)stopRecording;
3939
- (NSTimeInterval)currentTimeRecordTime;
4040
- (NSURL *)currentRecorderURL;

ChatSecure/Classes/Controllers/OTRAudioSessionManager.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,30 @@ - (BOOL)isPlaying
4949
#pragma - mark Public Methods
5050

5151
////// Playing //////
52-
- (void)playAudioWithURL:(NSURL *)url error:(NSError **)error
52+
- (BOOL)playAudioWithURL:(NSURL *)url error:(NSError **)error
5353
{
5454
[self stopPlaying];
5555
[self stopRecording];
5656
error = nil;
5757

5858
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:error];
5959
if (error) {
60-
return;
60+
return NO;
6161
}
6262
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeSpokenAudio error:error];
6363
if (error) {
64-
return;
64+
return NO;
6565
}
6666

6767
error = nil;
6868
self.currentPlayer = [self audioPlayerWithURL:url error:error];
6969
if (error) {
70-
return;
70+
return NO;
7171
}
7272

7373
[self.currentPlayer play];
74+
75+
return YES;
7476
}
7577

7678
- (void)pausePlaying
@@ -119,30 +121,32 @@ - (NSURL *)currentPlayerURL
119121
}
120122

121123
////// Recording //////
122-
- (void)recordAudioToURL:(NSURL *)url error:(NSError **)error
124+
- (BOOL)recordAudioToURL:(NSURL *)url error:(NSError **)error
123125
{
124126
[self stopRecording];
125127
[self stopPlaying];
126128

127129
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:error];
128130
if (error) {
129-
return;
131+
return NO;
130132
}
131133
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeSpokenAudio error:error];
132134
if (error) {
133-
return;
135+
return NO;
134136
}
135137

136138
self.currentRecorder = [self audioRecorderWithURL:url error:error];
137139

138140
if (error) {
139-
return;
141+
return NO;
140142
}
141143

142144
self.currentRecorder.meteringEnabled = YES;
143145
self.recordDecibelTimer = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(updateDecibelRecording:) userInfo:nil repeats:YES];
144146

145147
[self.currentRecorder record];
148+
149+
return YES;
146150
}
147151

148152
- (void)stopRecording
@@ -179,9 +183,9 @@ - (NSURL *)currentRecorderURL
179183

180184
#pragma - mark Private Methods
181185

182-
- (void)deactivateSession:(NSError **)error
186+
- (BOOL)deactivateSession:(NSError **)error
183187
{
184-
[[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:error];
188+
return [[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:error];
185189
}
186190

187191
- (AVPlayer *)audioPlayerWithURL:(NSURL *)url error:(NSError **)error

ChatSecure/Classes/Controllers/OTRDatabaseManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
4949
directory:(nullable NSString*)directory
5050
withMediaStorage:(BOOL)withMediaStorage;
5151

52-
- (void)setDatabasePassphrase:(NSString *)passphrase remember:(BOOL)rememeber error:(NSError *_Nullable*)error;
52+
- (BOOL)setDatabasePassphrase:(NSString *)passphrase remember:(BOOL)rememeber error:(NSError *_Nullable*)error;
5353

5454

5555
- (BOOL)hasPassphrase;

ChatSecure/Classes/Controllers/OTRDatabaseManager.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,17 @@ + (BOOL)existsYapDatabase
299299
return [[NSFileManager defaultManager] fileExistsAtPath:[self defaultYapDatabasePathWithName:OTRYapDatabaseName]];
300300
}
301301

302-
- (void) setDatabasePassphrase:(NSString *)passphrase remember:(BOOL)rememeber error:(NSError**)error
302+
- (BOOL) setDatabasePassphrase:(NSString *)passphrase remember:(BOOL)rememeber error:(NSError**)error
303303
{
304+
BOOL result = NO;
304305
if (rememeber) {
305306
self.inMemoryPassphrase = nil;
306-
[SAMKeychain setPassword:passphrase forService:kOTRServiceName account:OTRYapDatabasePassphraseAccountName error:error];
307+
result = [SAMKeychain setPassword:passphrase forService:kOTRServiceName account:OTRYapDatabasePassphraseAccountName error:error];
307308
} else {
308-
[SAMKeychain deletePasswordForService:kOTRServiceName account:OTRYapDatabasePassphraseAccountName];
309+
result = [SAMKeychain deletePasswordForService:kOTRServiceName account:OTRYapDatabasePassphraseAccountName];
309310
self.inMemoryPassphrase = passphrase;
310311
}
312+
return result;
311313
}
312314

313315
- (BOOL)hasPassphrase

ChatSecure/Classes/Controllers/OTRMediaFileManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ completionQueue:(nullable dispatch_queue_t)completionQueue;
4343
buddyUniqueId:(NSString *)buddyUniqueId
4444
error:(NSError* __autoreleasing *)error;
4545

46-
+ (NSString *)pathForMediaItem:(OTRMediaItem *)mediaItem buddyUniqueId:(NSString *)buddyUniqueId;
47-
+ (NSString *)pathForMediaItem:(OTRMediaItem *)mediaItem buddyUniqueId:(NSString *)buddyUniqueId withLeadingSlash:(BOOL)includeLeadingSlash;
46+
+ (nullable NSString *)pathForMediaItem:(OTRMediaItem *)mediaItem buddyUniqueId:(NSString *)buddyUniqueId;
47+
+ (nullable NSString *)pathForMediaItem:(OTRMediaItem *)mediaItem buddyUniqueId:(NSString *)buddyUniqueId withLeadingSlash:(BOOL)includeLeadingSlash;
4848

4949
@property (class, nonatomic, readonly) OTRMediaFileManager *shared;
5050

0 commit comments

Comments
 (0)