Skip to content

Commit 4baf9bd

Browse files
Hannah Troisiappleguy
authored andcommitted
[Infer] Fix Infer errors/warnings (facebookarchive#1938)
* [Infer] Fix 11 Infer errors/warnings * fix build error
1 parent abf8d5b commit 4baf9bd

File tree

10 files changed

+54
-24
lines changed

10 files changed

+54
-24
lines changed

AsyncDisplayKit/ASControlNode.mm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ - (void)addTarget:(id)target action:(SEL)action forControlEvents:(ASControlNodeE
286286
{
287287
// Create the dispatch table for this event.
288288
eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable];
289-
_controlEventDispatchTable[eventKey] = eventDispatchTable;
289+
if (eventKey) {
290+
[_controlEventDispatchTable setObject:eventDispatchTable forKey:eventKey];
291+
}
290292
}
291293

292294
// Have we seen this target before for this event?
@@ -442,9 +444,11 @@ - (void)sendActionsForControlEvents:(ASControlNodeEvent)controlEvents withEvent:
442444

443445
void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, void (^block)(ASControlNodeEvent anEvent))
444446
{
447+
if (block == nil) {
448+
return;
449+
}
445450
// Start with our first event (touch down) and work our way up to the last event (touch cancel)
446-
for (ASControlNodeEvent thisEvent = ASControlNodeEventTouchDown; thisEvent <= ASControlNodeEventTouchCancel; thisEvent <<= 1)
447-
{
451+
for (ASControlNodeEvent thisEvent = ASControlNodeEventTouchDown; thisEvent <= ASControlNodeEventTouchCancel; thisEvent <<= 1){
448452
// If it's included in the mask, invoke the block.
449453
if ((mask & thisEvent) == thisEvent)
450454
block(thisEvent);

AsyncDisplayKit/ASRunLoopQueue.mm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ - (instancetype)initWithRunLoop:(CFRunLoopRef)runloop andHandler:(void(^)(id deq
5959
// It is not guaranteed that the runloop will turn if it has no scheduled work, and this causes processing of
6060
// the queue to stop. Attaching a custom loop source to the run loop and signal it if new work needs to be done
6161
CFRunLoopSourceContext *runLoopSourceContext = (CFRunLoopSourceContext *)calloc(1, sizeof(CFRunLoopSourceContext));
62-
runLoopSourceContext->perform = runLoopSourceCallback;
62+
if (runLoopSourceContext) {
63+
runLoopSourceContext->perform = runLoopSourceCallback;
6364
#if ASRunLoopQueueLoggingEnabled
64-
runLoopSourceContext->info = (__bridge void *)self;
65+
runLoopSourceContext->info = (__bridge void *)self;
6566
#endif
66-
_runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext);
67-
CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes);
68-
free(runLoopSourceContext);
67+
_runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext);
68+
CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes);
69+
free(runLoopSourceContext);
70+
}
6971

7072
#if ASRunLoopQueueLoggingEnabled
7173
_runloopQueueLoggingTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(checkRunLoop) userInfo:nil repeats:YES];

AsyncDisplayKit/ASTableView.mm

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,16 +606,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
606606
cell.delegate = self;
607607

608608
ASCellNode *node = [_dataController nodeAtIndexPath:indexPath];
609-
[_rangeController configureContentView:cell.contentView forCellNode:node];
609+
if (node) {
610+
[_rangeController configureContentView:cell.contentView forCellNode:node];
610611

611-
cell.node = node;
612-
cell.backgroundColor = node.backgroundColor;
613-
cell.selectionStyle = node.selectionStyle;
612+
cell.node = node;
613+
cell.backgroundColor = node.backgroundColor;
614+
cell.selectionStyle = node.selectionStyle;
614615

615-
// the following ensures that we clip the entire cell to it's bounds if node.clipsToBounds is set (the default)
616-
// This is actually a workaround for a bug we are seeing in some rare cases (selected background view
617-
// overlaps other cells if size of ASCellNode has changed.)
618-
cell.clipsToBounds = node.clipsToBounds;
616+
// the following ensures that we clip the entire cell to it's bounds if node.clipsToBounds is set (the default)
617+
// This is actually a workaround for a bug we are seeing in some rare cases (selected background view
618+
// overlaps other cells if size of ASCellNode has changed.)
619+
cell.clipsToBounds = node.clipsToBounds;
620+
}
619621

620622
return cell;
621623
}

AsyncDisplayKit/ASVideoPlayerNode.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,19 @@ - (void)createScrubber
379379
slider.maximumValue = 1.0;
380380

381381
if (_delegateFlags.delegateScrubberMinimumTrackTintColor) {
382-
slider.minimumTrackTintColor = [_delegate videoPlayerNodeScrubberMinimumTrackTint:strongSelf];
382+
slider.minimumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMinimumTrackTint:strongSelf];
383383
}
384384

385385
if (_delegateFlags.delegateScrubberMaximumTrackTintColor) {
386-
slider.maximumTrackTintColor = [_delegate videoPlayerNodeScrubberMaximumTrackTint:strongSelf];
386+
slider.maximumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMaximumTrackTint:strongSelf];
387387
}
388388

389389
if (_delegateFlags.delegateScrubberThumbTintColor) {
390-
slider.thumbTintColor = [_delegate videoPlayerNodeScrubberThumbTint:strongSelf];
390+
slider.thumbTintColor = [strongSelf.delegate videoPlayerNodeScrubberThumbTint:strongSelf];
391391
}
392392

393393
if (_delegateFlags.delegateScrubberThumbImage) {
394-
UIImage *thumbImage = [_delegate videoPlayerNodeScrubberThumbImage:strongSelf];
394+
UIImage *thumbImage = [strongSelf.delegate videoPlayerNodeScrubberThumbImage:strongSelf];
395395
[slider setThumbImage:thumbImage forState:UIControlStateNormal];
396396
}
397397

AsyncDisplayKit/Details/ASDataController.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ - (void)performEditCommandWithBlock:(void (^)(void))block
560560
return;
561561
}
562562

563+
if (block == nil) {
564+
return;
565+
}
566+
563567
// If we have never performed a reload, there is no value in executing edit operations as the initial
564568
// reload will directly re-query the latest state of the datasource - so completely skip the block in this case.
565569
if (_batchUpdateCounter == 0) {

AsyncDisplayKit/Details/NSIndexSet+ASHelpers.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ - (NSString *)as_smallDescription
6868
NSMutableString *result = [NSMutableString stringWithString:@"{ "];
6969
[self enumerateRangesUsingBlock:^(NSRange range, BOOL * _Nonnull stop) {
7070
if (range.length == 1) {
71-
[result appendFormat:@"%zu ", range.location];
71+
[result appendFormat:@"%zu ", (unsigned long)range.location];
7272
} else {
73-
[result appendFormat:@"%zu-%zu ", range.location, NSMaxRange(range) - 1];
73+
[result appendFormat:@"%zu-%lu ", (unsigned long)range.location, NSMaxRange(range) - 1];
7474
}
7575
}];
7676
[result appendString:@"}"];

AsyncDisplayKit/Private/ASInternalHelpers.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL sele
3434

3535
void ASPerformBlockOnMainThread(void (^block)())
3636
{
37+
if (block == nil){
38+
return;
39+
}
3740
if (ASDisplayNodeThreadIsMain()) {
3841
block();
3942
} else {
@@ -43,6 +46,9 @@ void ASPerformBlockOnMainThread(void (^block)())
4346

4447
void ASPerformBlockOnBackgroundThread(void (^block)())
4548
{
49+
if (block == nil){
50+
return;
51+
}
4652
if (ASDisplayNodeThreadIsMain()) {
4753
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
4854
} else {

AsyncDisplayKit/Private/ASMultidimensionalArrayUtils.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ static void ASRecursivelyUpdateMultidimensionalArrayAtIndexPaths(NSMutableArray
4343
curIdx++;
4444
}
4545

46-
updateBlock(mutableArray, indexSet, curIdx);
46+
if (updateBlock){
47+
updateBlock(mutableArray, indexSet, curIdx);
48+
}
4749
}
4850
}
4951

AsyncDisplayKit/TextKit/ASTextKitContext.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ - (void)performBlockWithLockedTextKitComponents:(void (^)(NSLayoutManager *,
7575
NSTextContainer *))block
7676
{
7777
std::lock_guard<std::mutex> l(_textKitMutex);
78-
block(_layoutManager, _textStorage, _textContainer);
78+
if (block) {
79+
block(_layoutManager, _textStorage, _textContainer);
80+
}
7981
}
8082

8183
@end

inferScript.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
if ! [ -x "$(command -v infer)" ]; then
4+
echo "infer not found"
5+
echo "Install infer with homebrew: brew install infer"
6+
else
7+
infer --continue --reactive -- xcodebuild build -workspace AsyncDisplayKit.xcworkspace -scheme "AsyncDisplayKit-iOS" -configuration Debug -sdk iphonesimulator9.3
8+
fi

0 commit comments

Comments
 (0)