From 335132ad6341ed24c217c96181bc064e54acfd85 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 9 Aug 2016 03:53:59 -0700 Subject: [PATCH] Fix some analyzer warnings Reviewed By: majak Differential Revision: D3683672 fbshipit-source-id: 879578b050186bc779d01a17822d41bf7e473123 --- React/Base/RCTModuleData.m | 6 ++++++ React/Executors/RCTJSCExecutor.mm | 6 +++--- React/Profiler/RCTProfile.h | 6 +++--- React/Profiler/RCTProfile.m | 18 ++++++++---------- React/Views/RCTComponentData.m | 6 ++++++ React/Views/RCTShadowView.m | 2 +- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/React/Base/RCTModuleData.m b/React/Base/RCTModuleData.m index e1a113212..e56278473 100644 --- a/React/Base/RCTModuleData.m +++ b/React/Base/RCTModuleData.m @@ -220,9 +220,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); if (!RCTIsMainQueue()) { RCTLogWarn(@"RCTBridge required dispatch_sync to load %@. This may lead to deadlocks", _moduleClass); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" RCTExecuteOnMainThread(^{ [self setUpInstanceAndBridge]; }, YES); +#pragma clang diagnostic pop RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); } else { [self setUpInstanceAndBridge]; @@ -285,9 +288,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); if (!RCTIsMainQueue()) { RCTLogWarn(@"Required dispatch_sync to load constants for %@. This may lead to deadlocks", _moduleClass); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" RCTExecuteOnMainThread(^{ self->_constantsToExport = [self->_instance constantsToExport] ?: @{}; }, YES); +#pragma clang diagnostic pop } RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); } diff --git a/React/Executors/RCTJSCExecutor.mm b/React/Executors/RCTJSCExecutor.mm index 97794f62d..db31dd033 100644 --- a/React/Executors/RCTJSCExecutor.mm +++ b/React/Executors/RCTJSCExecutor.mm @@ -457,7 +457,7 @@ static NSThread *newJavaScriptThread(void) context[@"nativeTraceBeginAsyncFlow"] = ^(__unused uint64_t tag, __unused NSString *name, int64_t cookie) { if (RCTProfileIsProfiling()) { [weakBridge.flowIDMapLock lock]; - int64_t newCookie = [_RCTProfileBeginFlowEvent() longLongValue]; + NSUInteger newCookie = _RCTProfileBeginFlowEvent(); CFDictionarySetValue(weakBridge.flowIDMap, (const void *)cookie, (const void *)newCookie); [weakBridge.flowIDMapLock unlock]; } @@ -466,8 +466,8 @@ static NSThread *newJavaScriptThread(void) context[@"nativeTraceEndAsyncFlow"] = ^(__unused uint64_t tag, __unused NSString *name, int64_t cookie) { if (RCTProfileIsProfiling()) { [weakBridge.flowIDMapLock lock]; - int64_t newCookie = (int64_t)CFDictionaryGetValue(weakBridge.flowIDMap, (const void *)cookie); - _RCTProfileEndFlowEvent(@(newCookie)); + NSUInteger newCookie = (int64_t)CFDictionaryGetValue(weakBridge.flowIDMap, (const void *)cookie); + _RCTProfileEndFlowEvent(newCookie); CFDictionaryRemoveValue(weakBridge.flowIDMap, (const void *)cookie); [weakBridge.flowIDMapLock unlock]; } diff --git a/React/Profiler/RCTProfile.h b/React/Profiler/RCTProfile.h index 155f8070c..4a9aafaab 100644 --- a/React/Profiler/RCTProfile.h +++ b/React/Profiler/RCTProfile.h @@ -33,7 +33,7 @@ RCT_EXTERN const uint64_t RCTProfileTagAlways; #define RCTProfileBeginFlowEvent() \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wshadow\"") \ -NSNumber *__rct_profile_flow_id = _RCTProfileBeginFlowEvent(); \ +NSUInteger __rct_profile_flow_id = _RCTProfileBeginFlowEvent(); \ _Pragma("clang diagnostic pop") #define RCTProfileEndFlowEvent() \ @@ -41,8 +41,8 @@ _RCTProfileEndFlowEvent(__rct_profile_flow_id) RCT_EXTERN dispatch_queue_t RCTProfileGetQueue(void); -RCT_EXTERN NSNumber *_RCTProfileBeginFlowEvent(void); -RCT_EXTERN void _RCTProfileEndFlowEvent(NSNumber *); +RCT_EXTERN NSUInteger _RCTProfileBeginFlowEvent(void); +RCT_EXTERN void _RCTProfileEndFlowEvent(NSUInteger); /** * Returns YES if the profiling information is currently being collected diff --git a/React/Profiler/RCTProfile.m b/React/Profiler/RCTProfile.m index 01cf350a8..8a63d99d5 100644 --- a/React/Profiler/RCTProfile.m +++ b/React/Profiler/RCTProfile.m @@ -693,18 +693,16 @@ void RCTProfileImmediateEvent( }); } -NSNumber *_RCTProfileBeginFlowEvent(void) +NSUInteger _RCTProfileBeginFlowEvent(void) { static NSUInteger flowID = 0; CHECK(@0); - unsigned int cookie = ++flowID; - NSNumber *currentID = @(cookie); - + NSUInteger cookie = ++flowID; if (callbacks != NULL) { callbacks->begin_async_flow(1, "flow", cookie); - return currentID; + return @(cookie); } NSTimeInterval time = CACurrentMediaTime(); @@ -714,7 +712,7 @@ NSNumber *_RCTProfileBeginFlowEvent(void) RCTProfileAddEvent(RCTProfileTraceEvents, @"tid": threadName, @"name": @"flow", - @"id": currentID, + @"id": @(cookie), @"cat": @"flow", @"ph": @"s", @"ts": RCTProfileTimestamp(time), @@ -722,15 +720,15 @@ NSNumber *_RCTProfileBeginFlowEvent(void) }); - return currentID; + return cookie; } -void _RCTProfileEndFlowEvent(NSNumber *flowID) +void _RCTProfileEndFlowEvent(NSUInteger cookie) { CHECK(); if (callbacks != NULL) { - callbacks->end_async_flow(1, "flow", [flowID integerValue]); + callbacks->end_async_flow(1, "flow", cookie); return; } @@ -741,7 +739,7 @@ void _RCTProfileEndFlowEvent(NSNumber *flowID) RCTProfileAddEvent(RCTProfileTraceEvents, @"tid": threadName, @"name": @"flow", - @"id": flowID, + @"id": @(cookie), @"cat": @"flow", @"ph": @"f", @"ts": RCTProfileTimestamp(time), diff --git a/React/Views/RCTComponentData.m b/React/Views/RCTComponentData.m index 97da98cc7..1120661ab 100644 --- a/React/Views/RCTComponentData.m +++ b/React/Views/RCTComponentData.m @@ -368,9 +368,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) - (NSDictionary *)viewConfig { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSMutableArray *directEvents = [NSMutableArray new]; if (RCTClassOverridesInstanceMethod(_managerClass, @selector(customDirectEventTypes))) { NSArray *events = [self.manager customDirectEventTypes]; +#pragma clang diagnostic pop if (RCT_DEBUG) { RCTAssert(!events || [events isKindOfClass:[NSArray class]], @"customDirectEventTypes must return an array, but %@ returned %@", @@ -381,8 +384,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) } } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSMutableArray *bubblingEvents = [NSMutableArray new]; if (RCTClassOverridesInstanceMethod(_managerClass, @selector(customBubblingEventTypes))) { +#pragma clang diagnostic pop NSArray *events = [self.manager customBubblingEventTypes]; if (RCT_DEBUG) { RCTAssert(!events || [events isKindOfClass:[NSArray class]], diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index f592d5802..b3e51ad0b 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -365,7 +365,7 @@ DEFINE_PROCESS_META_PROPS(Border); { [_reactSubviews insertObject:subview atIndex:atIndex]; if (![self isCSSLeafNode]) { - CSSNodeInsertChild(_cssNode, subview.cssNode, atIndex); + CSSNodeInsertChild(_cssNode, subview.cssNode, (uint32_t)atIndex); } subview->_superview = self; _didUpdateSubviews = YES;