Skip to content

Commit f0054de

Browse files
authored
Fixed a log warning and about 100 other warnings found with -Weverything (GH-#719, #720).
1 parent 43764b3 commit f0054de

34 files changed

+76
-66
lines changed

Branch-SDK/Branch-SDK/BNCDebug.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515

1616
#import "BNCDebug.h"
17-
#import <sys/sysctl.h>
18-
#import <objc/runtime.h>
17+
@import Darwin.sys.sysctl;
18+
@import ObjectiveC.runtime;
1919

2020

2121
BOOL BNCDebuggerIsAttached() {
@@ -60,7 +60,7 @@ BOOL BNCDebuggerIsAttached() {
6060

6161
if (!instance) return @"Object is nil.\n";
6262

63-
const char* superclassname = "nil";
63+
const char* superclassname = "<nil>";
6464
Class class = object_getClass(instance);
6565
Class superclass = class_getSuperclass(class);
6666
if (superclass) superclassname = class_getName(superclass);
@@ -69,11 +69,11 @@ BOOL BNCDebuggerIsAttached() {
6969
NSMutableString *result = [NSMutableString stringWithCapacity:512];
7070
if (class_isMetaClass(class)) {
7171
[result appendFormat:@"\nClass %p is class '%s' of class '%s':\n",
72-
instance, class_getName(class), superclassname];
72+
(void*)instance, class_getName(class), superclassname];
7373
class = instance;
7474
} else {
7575
[result appendFormat:@"\nInstance %p is of class '%s' of class '%s':\n",
76-
instance, class_getName(class), superclassname];
76+
(void*)instance, class_getName(class), superclassname];
7777
}
7878

7979
// Ivars --
@@ -94,7 +94,7 @@ BOOL BNCDebuggerIsAttached() {
9494

9595
uint count = 0;
9696
Ivar *ivars = class_copyIvarList(class, &count);
97-
for (int i = 0; i < count; ++i) {
97+
for (uint i = 0; i < count; ++i) {
9898
const char* encoding = ivar_getTypeEncoding(ivars[i]);
9999
const char* ivarName = ivar_getName(ivars[i]);
100100
const void* ivarPtr = nil;

Branch-SDK/Branch-SDK/BNCDeviceInfo.m

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

1010
@import Foundation;
1111
@import UIKit;
12-
#import <sys/sysctl.h>
12+
@import Darwin.sys.sysctl;
1313
#import "BNCDeviceInfo.h"
1414
#import "BNCPreferenceHelper.h"
1515
#import "BNCSystemObserver.h"
@@ -229,7 +229,7 @@ + (NSString*) userAgentString {
229229
}
230230

231231
// Different case for iOS 7.0:
232-
if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) {
232+
if ([UIDevice currentDevice].systemVersion.doubleValue < 8.0) {
233233
BNCLogDebugSDK(@"Getting iOS 7 UserAgent.");
234234
dispatch_sync(dispatch_get_main_queue(), ^ {
235235
setBrowserUserAgent();

Branch-SDK/Branch-SDK/BNCEncodingUtils.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ - (NSString*) description {
2626
return [NSString stringWithFormat:@"<%@, %@>", self.key, self.value];
2727
}
2828

29-
- (BOOL) isEqual:(BNCKeyValue*)object {
29+
- (BOOL) isEqual:(id)rawObject {
30+
BNCKeyValue *object = rawObject;
3031
return
3132
[object isKindOfClass:[BNCKeyValue class]] &&
3233
[self.key isEqualToString:object.key] &&
@@ -391,8 +392,8 @@ + (NSData *) dataFromHexString:(NSString*)string {
391392
if (!bytes) goto exit;
392393

393394
int highValue = -1;
394-
uint8_t *p = (uint8_t*) [inputData bytes];
395-
for (long i = 0; i < inputData.length; ++i) {
395+
const uint8_t *p = (const uint8_t*) [inputData bytes];
396+
for (NSUInteger i = 0; i < inputData.length; ++i) {
396397
int value = -1;
397398
if (*p >= '0' && *p <= '9')
398399
value = *p - '0';
@@ -425,7 +426,7 @@ + (NSData *) dataFromHexString:(NSString*)string {
425426

426427
exit:
427428
if (bytes) {
428-
BNCLogAssert(b-bytes<=length);
429+
BNCLogAssert((size_t)(b-bytes)<=length);
429430
free(bytes);
430431
}
431432
return data;

Branch-SDK/Branch-SDK/BNCLinkCache.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ @interface BNCLinkCache ()
1818
@implementation BNCLinkCache
1919

2020
- (id)init {
21-
if (self = [super init]) {
21+
if ((self = [super init])) {
2222
self.cache = [[NSMutableDictionary alloc] init];
2323
}
2424
return self;

Branch-SDK/Branch-SDK/BNCLinkData.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ @interface BNCLinkData ()
2929
@implementation BNCLinkData
3030

3131
- (id)init {
32-
if (self = [super init]) {
32+
if ((self = [super init])) {
3333
self.data = [[NSMutableDictionary alloc] init];
3434
self.data[@"source"] = @"ios";
3535
}
@@ -169,7 +169,7 @@ - (void)encodeWithCoder:(NSCoder *)coder {
169169
}
170170

171171
- (id)initWithCoder:(NSCoder *)coder {
172-
if (self = [super init]) {
172+
if ((self = [super init])) {
173173
self.tags = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_TAGS];
174174
self.alias = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_ALIAS];
175175
self.type = [[coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_LINK_TYPE] integerValue];

Branch-SDK/Branch-SDK/BNCLocalization.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
+ (NSDictionary<NSString*, NSDictionary*>*) languageDictionaries;
1616
- (NSString*) localizeString:(NSString*)string;
1717

18-
@property (copy) NSString* currentLanguage;
19-
@property (strong, readonly) NSDictionary *currentLanguageDictionary;
18+
@property (copy, atomic) NSString* currentLanguage;
19+
@property (strong, atomic, readonly) NSDictionary *currentLanguageDictionary;
2020
@end
2121

2222
#pragma mark Convenience Functions

Branch-SDK/Branch-SDK/BNCLog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern void BNCLogSetDisplayLevel(BNCLogLevel level);
5959
* @param level The log level to convert to a string.
6060
* @return Returns the string indicating the log level.
6161
*/
62-
extern NSString *_Nonnull const BNCLogStringFromLogLevel(BNCLogLevel level);
62+
extern NSString *_Nonnull BNCLogStringFromLogLevel(BNCLogLevel level);
6363

6464
/*!
6565
* @param string A string indicating the log level.
@@ -91,7 +91,7 @@ extern BNCLogClientInitializeFunctionPtr _Null_unspecified
9191
#pragma mark - Optional Log Output Handlers
9292

9393

94-
///@info Pre-defined log message handlers --
94+
///@brief Pre-defined log message handlers --
9595

9696
typedef void (*BNCLogOutputFunctionPtr)(NSDate*_Nonnull timestamp, BNCLogLevel level, NSString*_Nullable message);
9797

Branch-SDK/Branch-SDK/BNCLog.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
#import "BNCLog.h"
17+
@import Darwin.C.stdatomic;
1718

1819

1920
#define _countof(array) (sizeof(array)/sizeof(array[0]))
@@ -490,7 +491,7 @@ void BNCLogSetDisplayLevel(BNCLogLevel level) {
490491
});
491492
}
492493

493-
NSString*const bnc_logLevelStrings[] = {
494+
static NSString*const bnc_logLevelStrings[] = {
494495
@"BNCLogLevelAll",
495496
@"BNCLogLevelBreakPoint",
496497
@"BNCLogLevelDebug",
@@ -502,14 +503,14 @@ void BNCLogSetDisplayLevel(BNCLogLevel level) {
502503
@"BNCLogLevelMax"
503504
};
504505

505-
NSString*const BNCLogStringFromLogLevel(BNCLogLevel level) {
506+
NSString* BNCLogStringFromLogLevel(BNCLogLevel level) {
506507
level = MAX(MIN(level, BNCLogLevelMax), 0);
507508
return bnc_logLevelStrings[level];
508509
}
509510

510511
BNCLogLevel BNCLogLevelFromString(NSString*string) {
511512
if (!string) return BNCLogLevelNone;
512-
for (NSInteger i = 0; i < _countof(bnc_logLevelStrings); ++i) {
513+
for (NSUInteger i = 0; i < _countof(bnc_logLevelStrings); ++i) {
513514
if ([bnc_logLevelStrings[i] isEqualToString:string]) {
514515
return i;
515516
}
@@ -522,7 +523,6 @@ BNCLogLevel BNCLogLevelFromString(NSString*string) {
522523

523524
#pragma mark - Client Initialization Function
524525

525-
#include "stdatomic.h"
526526
static _Atomic(BNCLogClientInitializeFunctionPtr) bnc_LogClientInitializeFunctionPtr = (BNCLogClientInitializeFunctionPtr) 0;
527527

528528
extern BNCLogClientInitializeFunctionPtr _Null_unspecified BNCLogSetClientInitializeFunction(

Branch-SDK/Branch-SDK/BNCPreferenceHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
4141
@property (strong, nonatomic) NSDictionary *appleSearchAdDetails;
4242
@property (strong, nonatomic) NSString *lastSystemBuildVersion;
4343
@property (strong, nonatomic) NSString *browserUserAgentString;
44-
@property (strong) NSString *branchAPIURL;
44+
@property (strong, atomic) NSString *branchAPIURL;
4545

4646
+ (BNCPreferenceHelper *)preferenceHelper;
4747

Branch-SDK/Branch-SDK/BNCPreferenceHelper.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ + (BNCPreferenceHelper *)preferenceHelper {
9999
}
100100

101101
- (id)init {
102-
if (self = [super init]) {
102+
if ((self = [super init])) {
103103
_timeout = DEFAULT_TIMEOUT;
104104
_retryCount = DEFAULT_RETRY_COUNT;
105105
_retryInterval = DEFAULT_RETRY_INTERVAL;
@@ -150,8 +150,10 @@ - (NSOperationQueue *)persistPrefsQueue {
150150
}
151151

152152
- (void) synchronize {
153-
// Flushes preference queue to persistence.
154-
[_persistPrefsQueue waitUntilAllOperationsAreFinished];
153+
@synchronized(self) {
154+
// Flushes preference queue to persistence.
155+
[_persistPrefsQueue waitUntilAllOperationsAreFinished];
156+
}
155157
}
156158

157159
- (void) dealloc {
@@ -530,7 +532,7 @@ - (void)addInstrumentationDictionaryKey:(NSString *)key value:(NSString *)value
530532
- (void)clearInstrumentationDictionary {
531533
@synchronized (self) {
532534
NSArray *keys = [_instrumentationDictionary allKeys];
533-
for (int i = 0 ; i < [keys count]; i++) {
535+
for (NSUInteger i = 0 ; i < [keys count]; i++) {
534536
[_instrumentationDictionary removeObjectForKey:keys[i]];
535537
}
536538
}
@@ -707,7 +709,7 @@ - (NSMutableDictionary *)persistenceDict {
707709
if (!error && data)
708710
persistenceDict = [NSKeyedUnarchiver unarchiveObjectWithData:data];
709711
}
710-
@catch (NSException *exception) {
712+
@catch (NSException*) {
711713
BNCLogWarning(@"Failed to load preferences from storage.");
712714
}
713715

0 commit comments

Comments
 (0)