Skip to content

Commit d2da941

Browse files
authored
Fix some static analyzer warnings (facebookarchive#2999)
1 parent 7e4bf95 commit d2da941

File tree

8 files changed

+15
-10
lines changed

8 files changed

+15
-10
lines changed

AsyncDisplayKit/ASDisplayNode.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3826,7 +3826,7 @@ - (CGRect)_frameInWindow
38263826

38273827
if (self.layerBacked) {
38283828
CALayer *rootLayer = _layer;
3829-
CALayer *nextLayer = rootLayer;
3829+
CALayer *nextLayer = nil;
38303830
while ((nextLayer = rootLayer.superlayer) != nil) {
38313831
rootLayer = nextLayer;
38323832
}

AsyncDisplayKit/ASNetworkImageNode.mm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,22 @@ - (void)_updateProgressImageBlockOnDownloaderIfNeeded
414414
} callbackQueue:dispatch_get_main_queue() withDownloadIdentifier:newDownloadIDForProgressBlock];
415415
}
416416

417-
// Update state.
417+
// Update state local state with lock held.
418418
{
419419
ASDN::MutexLocker l(__instanceLock__);
420+
// Check if the oldDownloadIDForProgressBlock still is the same as the _downloadIdentifierForProgressBlock
420421
if (_downloadIdentifierForProgressBlock == oldDownloadIDForProgressBlock) {
421422
_downloadIdentifierForProgressBlock = newDownloadIDForProgressBlock;
422-
} else {
423+
} else if (newDownloadIDForProgressBlock != nil) {
424+
// If this is not the case another thread did change the _downloadIdentifierForProgressBlock already so
425+
// we have to deregister the newDownloadIDForProgressBlock that we registered above
423426
clearAndReattempt = YES;
424427
}
425428
}
426429

427430
if (clearAndReattempt) {
431+
// In this case another thread changed the _downloadIdentifierForProgressBlock before we finished registering
432+
// the new progress block for newDownloadIDForProgressBlock ID. Let's clear it now and reattempt to register
428433
[_downloader setProgressImageBlock:nil callbackQueue:dispatch_get_main_queue() withDownloadIdentifier:newDownloadIDForProgressBlock];
429434
[self _updateProgressImageBlockOnDownloaderIfNeeded];
430435
}

AsyncDisplayKit/Details/ASCollectionDataController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
4444

4545
- (instancetype)initWithDataSource:(id<ASCollectionDataControllerSource>)dataSource eventLog:(nullable ASEventLog *)eventLog NS_DESIGNATED_INITIALIZER;
4646

47-
- (ASCellNode *)supplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
47+
- (nullable ASCellNode *)supplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
4848

4949
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section;
5050

AsyncDisplayKit/Details/ASCollectionInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
3939
*
4040
* @param indexPath The index path of the row.
4141
*/
42-
- (NSIndexPath *)convertIndexPathToCollectionNode:(NSIndexPath *)indexPath;
42+
- (nullable NSIndexPath *)convertIndexPathToCollectionNode:(NSIndexPath *)indexPath;
4343

4444
/**
4545
* Attempt to get the node index paths given the view-layer index paths.

AsyncDisplayKit/Details/ASObjectDescriptionHelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ NSString *ASObjectDescriptionMake(__autoreleasing id object, NSArray<NSDictionar
5959
* Note: `object` param is autoreleasing so that this function is dealloc-safe.
6060
* No, unsafe_unretained isn't acceptable here – the optimizer may deallocate object early.
6161
*/
62-
NSString *ASObjectDescriptionMakeTiny(__autoreleasing id object);
62+
NSString *ASObjectDescriptionMakeTiny(__autoreleasing id _Nullable object);
6363

6464
NSString * _Nullable ASStringWithQuotesIfMultiword(NSString * _Nullable string);
6565

AsyncDisplayKit/Private/ASInternalHelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CGFloat ASRoundPixelValue(CGFloat f);
5151

5252
BOOL ASClassRequiresMainThreadDeallocation(Class _Nullable c);
5353

54-
Class _Nullable ASGetClassFromType(const char *type);
54+
Class _Nullable ASGetClassFromType(const char * _Nullable type);
5555

5656
ASDISPLAYNODE_EXTERN_C_END
5757

AsyncDisplayKit/Private/ASInternalHelpers.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ BOOL ASClassRequiresMainThreadDeallocation(Class c)
124124
return NO;
125125
}
126126

127-
Class _Nullable ASGetClassFromType(const char *type)
127+
Class _Nullable ASGetClassFromType(const char * _Nullable type)
128128
{
129129
// Class types all start with @"
130130
if (type == NULL || strncmp(type, "@\"", 2) != 0) {

AsyncDisplayKit/UIImage+ASConvenience.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
3232
* @param fillColor The fill color of the rounded-corner image
3333
*/
3434
+ (UIImage *)as_resizableRoundedImageWithCornerRadius:(CGFloat)cornerRadius
35-
cornerColor:(UIColor *)cornerColor
35+
cornerColor:(nullable UIColor *)cornerColor
3636
fillColor:(UIColor *)fillColor AS_WARN_UNUSED_RESULT;
3737

3838
/**
@@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
6262
* @param scale The number of pixels per point. Provide 0.0 to use the screen scale.
6363
*/
6464
+ (UIImage *)as_resizableRoundedImageWithCornerRadius:(CGFloat)cornerRadius
65-
cornerColor:(UIColor *)cornerColor
65+
cornerColor:(nullable UIColor *)cornerColor
6666
fillColor:(UIColor *)fillColor
6767
borderColor:(nullable UIColor *)borderColor
6868
borderWidth:(CGFloat)borderWidth

0 commit comments

Comments
 (0)