[Infer] Fix Infer errors/warnings (#1938)

* [Infer] Fix 11 Infer errors/warnings

* fix build error
This commit is contained in:
Hannah Troisi 2016-07-16 15:29:24 -07:00 committed by appleguy
parent abf8d5b9aa
commit 4baf9bdbfe
10 changed files with 54 additions and 24 deletions

View File

@ -286,7 +286,9 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v
{ {
// Create the dispatch table for this event. // Create the dispatch table for this event.
eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable]; eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable];
_controlEventDispatchTable[eventKey] = eventDispatchTable; if (eventKey) {
[_controlEventDispatchTable setObject:eventDispatchTable forKey:eventKey];
}
} }
// Have we seen this target before for this event? // Have we seen this target before for this event?
@ -442,9 +444,11 @@ id<NSCopying> _ASControlNodeEventKeyForControlEvent(ASControlNodeEvent controlEv
void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, void (^block)(ASControlNodeEvent anEvent)) void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, void (^block)(ASControlNodeEvent anEvent))
{ {
if (block == nil) {
return;
}
// Start with our first event (touch down) and work our way up to the last event (touch cancel) // Start with our first event (touch down) and work our way up to the last event (touch cancel)
for (ASControlNodeEvent thisEvent = ASControlNodeEventTouchDown; thisEvent <= ASControlNodeEventTouchCancel; thisEvent <<= 1) for (ASControlNodeEvent thisEvent = ASControlNodeEventTouchDown; thisEvent <= ASControlNodeEventTouchCancel; thisEvent <<= 1){
{
// If it's included in the mask, invoke the block. // If it's included in the mask, invoke the block.
if ((mask & thisEvent) == thisEvent) if ((mask & thisEvent) == thisEvent)
block(thisEvent); block(thisEvent);

View File

@ -59,6 +59,7 @@ static void runLoopSourceCallback(void *info) {
// It is not guaranteed that the runloop will turn if it has no scheduled work, and this causes processing of // It is not guaranteed that the runloop will turn if it has no scheduled work, and this causes processing of
// the queue to stop. Attaching a custom loop source to the run loop and signal it if new work needs to be done // the queue to stop. Attaching a custom loop source to the run loop and signal it if new work needs to be done
CFRunLoopSourceContext *runLoopSourceContext = (CFRunLoopSourceContext *)calloc(1, sizeof(CFRunLoopSourceContext)); CFRunLoopSourceContext *runLoopSourceContext = (CFRunLoopSourceContext *)calloc(1, sizeof(CFRunLoopSourceContext));
if (runLoopSourceContext) {
runLoopSourceContext->perform = runLoopSourceCallback; runLoopSourceContext->perform = runLoopSourceCallback;
#if ASRunLoopQueueLoggingEnabled #if ASRunLoopQueueLoggingEnabled
runLoopSourceContext->info = (__bridge void *)self; runLoopSourceContext->info = (__bridge void *)self;
@ -66,6 +67,7 @@ static void runLoopSourceCallback(void *info) {
_runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext); _runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext);
CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes); CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes);
free(runLoopSourceContext); free(runLoopSourceContext);
}
#if ASRunLoopQueueLoggingEnabled #if ASRunLoopQueueLoggingEnabled
_runloopQueueLoggingTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(checkRunLoop) userInfo:nil repeats:YES]; _runloopQueueLoggingTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(checkRunLoop) userInfo:nil repeats:YES];

View File

@ -606,6 +606,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
cell.delegate = self; cell.delegate = self;
ASCellNode *node = [_dataController nodeAtIndexPath:indexPath]; ASCellNode *node = [_dataController nodeAtIndexPath:indexPath];
if (node) {
[_rangeController configureContentView:cell.contentView forCellNode:node]; [_rangeController configureContentView:cell.contentView forCellNode:node];
cell.node = node; cell.node = node;
@ -616,6 +617,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
// This is actually a workaround for a bug we are seeing in some rare cases (selected background view // This is actually a workaround for a bug we are seeing in some rare cases (selected background view
// overlaps other cells if size of ASCellNode has changed.) // overlaps other cells if size of ASCellNode has changed.)
cell.clipsToBounds = node.clipsToBounds; cell.clipsToBounds = node.clipsToBounds;
}
return cell; return cell;
} }

View File

@ -379,19 +379,19 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
slider.maximumValue = 1.0; slider.maximumValue = 1.0;
if (_delegateFlags.delegateScrubberMinimumTrackTintColor) { if (_delegateFlags.delegateScrubberMinimumTrackTintColor) {
slider.minimumTrackTintColor = [_delegate videoPlayerNodeScrubberMinimumTrackTint:strongSelf]; slider.minimumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMinimumTrackTint:strongSelf];
} }
if (_delegateFlags.delegateScrubberMaximumTrackTintColor) { if (_delegateFlags.delegateScrubberMaximumTrackTintColor) {
slider.maximumTrackTintColor = [_delegate videoPlayerNodeScrubberMaximumTrackTint:strongSelf]; slider.maximumTrackTintColor = [strongSelf.delegate videoPlayerNodeScrubberMaximumTrackTint:strongSelf];
} }
if (_delegateFlags.delegateScrubberThumbTintColor) { if (_delegateFlags.delegateScrubberThumbTintColor) {
slider.thumbTintColor = [_delegate videoPlayerNodeScrubberThumbTint:strongSelf]; slider.thumbTintColor = [strongSelf.delegate videoPlayerNodeScrubberThumbTint:strongSelf];
} }
if (_delegateFlags.delegateScrubberThumbImage) { if (_delegateFlags.delegateScrubberThumbImage) {
UIImage *thumbImage = [_delegate videoPlayerNodeScrubberThumbImage:strongSelf]; UIImage *thumbImage = [strongSelf.delegate videoPlayerNodeScrubberThumbImage:strongSelf];
[slider setThumbImage:thumbImage forState:UIControlStateNormal]; [slider setThumbImage:thumbImage forState:UIControlStateNormal];
} }

View File

@ -560,6 +560,10 @@ NSString * const ASDataControllerRowNodeKind = @"_ASDataControllerRowNodeKind";
return; return;
} }
if (block == nil) {
return;
}
// If we have never performed a reload, there is no value in executing edit operations as the initial // If we have never performed a reload, there is no value in executing edit operations as the initial
// reload will directly re-query the latest state of the datasource - so completely skip the block in this case. // reload will directly re-query the latest state of the datasource - so completely skip the block in this case.
if (_batchUpdateCounter == 0) { if (_batchUpdateCounter == 0) {

View File

@ -68,9 +68,9 @@
NSMutableString *result = [NSMutableString stringWithString:@"{ "]; NSMutableString *result = [NSMutableString stringWithString:@"{ "];
[self enumerateRangesUsingBlock:^(NSRange range, BOOL * _Nonnull stop) { [self enumerateRangesUsingBlock:^(NSRange range, BOOL * _Nonnull stop) {
if (range.length == 1) { if (range.length == 1) {
[result appendFormat:@"%zu ", range.location]; [result appendFormat:@"%zu ", (unsigned long)range.location];
} else { } else {
[result appendFormat:@"%zu-%zu ", range.location, NSMaxRange(range) - 1]; [result appendFormat:@"%zu-%lu ", (unsigned long)range.location, NSMaxRange(range) - 1];
} }
}]; }];
[result appendString:@"}"]; [result appendString:@"}"];

View File

@ -34,6 +34,9 @@ BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL sele
void ASPerformBlockOnMainThread(void (^block)()) void ASPerformBlockOnMainThread(void (^block)())
{ {
if (block == nil){
return;
}
if (ASDisplayNodeThreadIsMain()) { if (ASDisplayNodeThreadIsMain()) {
block(); block();
} else { } else {
@ -43,6 +46,9 @@ void ASPerformBlockOnMainThread(void (^block)())
void ASPerformBlockOnBackgroundThread(void (^block)()) void ASPerformBlockOnBackgroundThread(void (^block)())
{ {
if (block == nil){
return;
}
if (ASDisplayNodeThreadIsMain()) { if (ASDisplayNodeThreadIsMain()) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
} else { } else {

View File

@ -43,9 +43,11 @@ static void ASRecursivelyUpdateMultidimensionalArrayAtIndexPaths(NSMutableArray
curIdx++; curIdx++;
} }
if (updateBlock){
updateBlock(mutableArray, indexSet, curIdx); updateBlock(mutableArray, indexSet, curIdx);
} }
} }
}
static void ASRecursivelyFindIndexPathsForMultidimensionalArray(NSObject *obj, NSIndexPath *curIndexPath, NSMutableArray <NSIndexPath *>*res) static void ASRecursivelyFindIndexPathsForMultidimensionalArray(NSObject *obj, NSIndexPath *curIndexPath, NSMutableArray <NSIndexPath *>*res)
{ {

View File

@ -75,7 +75,9 @@
NSTextContainer *))block NSTextContainer *))block
{ {
std::lock_guard<std::mutex> l(_textKitMutex); std::lock_guard<std::mutex> l(_textKitMutex);
if (block) {
block(_layoutManager, _textStorage, _textContainer); block(_layoutManager, _textStorage, _textContainer);
} }
}
@end @end

8
inferScript.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
if ! [ -x "$(command -v infer)" ]; then
echo "infer not found"
echo "Install infer with homebrew: brew install infer"
else
infer --continue --reactive -- xcodebuild build -workspace AsyncDisplayKit.xcworkspace -scheme "AsyncDisplayKit-iOS" -configuration Debug -sdk iphonesimulator9.3
fi