Skip to content

Commit 3c469b3

Browse files
Fix all IID analyzer warnings (#2613)
1 parent b76c843 commit 3c469b3

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

Firebase/InstanceID/FIRInstanceIDAuthKeyChain.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ @interface FIRInstanceIDAuthKeychain ()
3333
// cachedKeychainData is keyed by service and account, the value is an array of NSData.
3434
// It is used to cache the tokens per service, per account, as well as checkin data per service,
3535
// per account inside the keychain.
36-
@property(nonatomic, copy)
36+
@property(nonatomic)
3737
NSMutableDictionary<NSString *, NSMutableDictionary<NSString *, NSArray<NSData *> *> *>
3838
*cachedKeychainData;
3939

@@ -89,7 +89,8 @@ - (NSMutableDictionary *)keychainQueryForService:(NSString *)service account:(NS
8989
keychainQuery[(__bridge id)kSecReturnAttributes] = (__bridge id)kCFBooleanTrue;
9090
keychainQuery[(__bridge id)kSecMatchLimit] = (__bridge id)kSecMatchLimitAll;
9191
// FIRInstanceIDKeychain should only take a query and return a result, will handle the query here.
92-
CFArrayRef passwordInfos = [[FIRInstanceIDKeychain sharedInstance] itemWithQuery:keychainQuery];
92+
NSArray *passwordInfos =
93+
CFBridgingRelease([[FIRInstanceIDKeychain sharedInstance] itemWithQuery:keychainQuery]);
9394

9495
if (!passwordInfos) {
9596
// Nothing was found, simply return from this sync block.
@@ -105,19 +106,14 @@ - (NSMutableDictionary *)keychainQueryForService:(NSString *)service account:(NS
105106
}
106107
return @[];
107108
}
108-
NSInteger numPasswords = CFArrayGetCount(passwordInfos);
109+
NSInteger numPasswords = passwordInfos.count;
109110
results = [[NSMutableArray alloc] init];
110-
if (0 < numPasswords) {
111-
for (NSUInteger i = 0; i < numPasswords; i++) {
112-
NSDictionary *passwordInfo = [((__bridge NSArray *)passwordInfos) objectAtIndex:i];
113-
if (passwordInfo[(__bridge id)kSecValueData]) {
114-
[results addObject:passwordInfo[(__bridge id)kSecValueData]];
115-
}
111+
for (NSUInteger i = 0; i < numPasswords; i++) {
112+
NSDictionary *passwordInfo = [passwordInfos objectAtIndex:i];
113+
if (passwordInfo[(__bridge id)kSecValueData]) {
114+
[results addObject:passwordInfo[(__bridge id)kSecValueData]];
116115
}
117116
}
118-
if (passwordInfos != NULL) {
119-
CFRelease(passwordInfos);
120-
}
121117

122118
// We query the keychain because it didn't exist in cache, now query is done, update the result in
123119
// the cache.

Firebase/InstanceID/FIRInstanceIDKeyPairStore.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
// Query the key given a tag
6161
SecKeyRef FIRInstanceIDCachedKeyRefWithTag(NSString *tag) {
6262
_FIRInstanceIDDevAssert([tag length], @"Invalid tag for keychain specified");
63-
if (![tag length]) {
63+
if (!tag.length) {
6464
return NULL;
6565
}
6666
NSDictionary *queryKey = FIRInstanceIDKeyPairQuery(tag, YES, NO);
@@ -279,7 +279,9 @@ - (FIRInstanceIDKeyPair *)validCachedKeyPairWithSubtype:(NSString *)subtype
279279
// There is no need to reset keypair again here as FIRInstanceID init call is always
280280
// going to be ahead of this call, which already trigger keypair reset if it's new install
281281
FIRInstanceIDErrorCode code = kFIRInstanceIDErrorCodeInvalidKeyPairCreationTime;
282-
*error = [NSError errorWithFIRInstanceIDErrorCode:code];
282+
if (error) {
283+
*error = [NSError errorWithFIRInstanceIDErrorCode:code];
284+
}
283285
return nil;
284286
}
285287
}

Firebase/InstanceID/FIRInstanceIDStore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ NS_ASSUME_NONNULL_BEGIN
9696
* @return The cached token info if any for the given authorizedEntity and scope else
9797
* returns nil.
9898
*/
99-
- (FIRInstanceIDTokenInfo *)tokenInfoWithAuthorizedEntity:(NSString *)authorizedEntity
100-
scope:(NSString *)scope;
99+
- (nullable FIRInstanceIDTokenInfo *)tokenInfoWithAuthorizedEntity:(NSString *)authorizedEntity
100+
scope:(NSString *)scope;
101101
/**
102102
* Return all cached token infos from the Keychain.
103103
*

Firebase/InstanceID/FIRInstanceIDTokenDeleteOperation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
2121
@interface FIRInstanceIDTokenDeleteOperation : FIRInstanceIDTokenOperation
2222

2323
- (instancetype)initWithAuthorizedEntity:(nullable NSString *)authorizedEntity
24-
scope:(NSString *)scope
24+
scope:(nullable NSString *)scope
2525
checkinPreferences:(FIRInstanceIDCheckinPreferences *)checkinPreferences
2626
keyPair:(nullable FIRInstanceIDKeyPair *)keyPair
2727
action:(FIRInstanceIDTokenAction)action;

Firebase/InstanceID/FIRInstanceIDTokenOperation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef void (^FIRInstanceIDTokenOperationCompletion)(FIRInstanceIDTokenOperatio
5757

5858
@property(nonatomic, readonly) FIRInstanceIDTokenAction action;
5959
@property(nonatomic, readonly, nullable) NSString *authorizedEntity;
60-
@property(nonatomic, readonly) NSString *scope;
60+
@property(nonatomic, readonly, nullable) NSString *scope;
6161
@property(nonatomic, readonly, nullable) NSDictionary<NSString *, NSString *> *options;
6262
@property(nonatomic, readonly, strong) FIRInstanceIDCheckinPreferences *checkinPreferences;
6363
@property(nonatomic, readonly, strong) FIRInstanceIDKeyPair *keyPair;

0 commit comments

Comments
 (0)