mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
1
Commits
main
...
export-D81699159
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a3cc7d1c5 |
@@ -32,7 +32,7 @@ std::unique_ptr<IWebSocket> RCTCxxInspectorPackagerConnectionDelegate::connectWe
|
||||
std::weak_ptr<IWebSocketDelegate> delegate)
|
||||
{
|
||||
auto *adapter = [[RCTCxxInspectorWebSocketAdapter alloc] initWithURL:url delegate:delegate];
|
||||
if (!adapter) {
|
||||
if (adapter == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<WebSocket>(adapter);
|
||||
|
||||
@@ -34,7 +34,7 @@ NSString *NSStringFromUTF8StringView(std::string_view view)
|
||||
@implementation RCTCxxInspectorWebSocketAdapter
|
||||
- (instancetype)initWithURL:(const std::string &)url delegate:(std::weak_ptr<IWebSocketDelegate>)delegate
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
if ((self = [super init]) != nullptr) {
|
||||
_delegate = delegate;
|
||||
_webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:NSStringFromUTF8StringView(url)]];
|
||||
_webSocket.delegate = self;
|
||||
@@ -49,7 +49,7 @@ NSString *NSStringFromUTF8StringView(std::string_view view)
|
||||
NSString *messageStr = NSStringFromUTF8StringView(message);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
RCTCxxInspectorWebSocketAdapter *strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
if (strongSelf != nullptr) {
|
||||
[strongSelf->_webSocket sendString:messageStr error:NULL];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ static SEL selectorForType(NSString *type)
|
||||
bridge:(RCTBridge *)bridge
|
||||
eventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
if ((self = [super init]) != nullptr) {
|
||||
_bridge = bridge;
|
||||
_eventDispatcher = eventDispatcher;
|
||||
_managerClass = managerClass;
|
||||
@@ -71,12 +71,12 @@ static SEL selectorForType(NSString *type)
|
||||
|
||||
- (RCTViewManager *)manager
|
||||
{
|
||||
if (!_manager && [self isBridgeMode]) {
|
||||
if ((_manager == nullptr) && [self isBridgeMode]) {
|
||||
_manager = [_bridge moduleForClass:_managerClass];
|
||||
} else if (!_manager && !_bridgelessViewManager) {
|
||||
} else if ((_manager == nullptr) && (_bridgelessViewManager == nullptr)) {
|
||||
_bridgelessViewManager = [_bridge moduleForClass:_managerClass];
|
||||
}
|
||||
return _manager ? _manager : _bridgelessViewManager;
|
||||
return (_manager != nullptr) ? _manager : _bridgelessViewManager;
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
@@ -106,7 +106,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
{
|
||||
json = RCTNilIfNull(json);
|
||||
if (!isShadowView) {
|
||||
if (!json && !_defaultView) {
|
||||
if ((json == nullptr) && (_defaultView == nullptr)) {
|
||||
// Only create default view if json is null
|
||||
_defaultView = [self createViewWithTag:nil rootTag:nil];
|
||||
}
|
||||
@@ -130,11 +130,11 @@ static RCTPropBlock createEventSetter(
|
||||
eventHandler = ^(NSDictionary *event) {
|
||||
// The component no longer exists, we shouldn't send the event
|
||||
id<RCTComponent> strongTarget = weakTarget;
|
||||
if (!strongTarget) {
|
||||
if (strongTarget == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInterceptor) {
|
||||
if (eventInterceptor != nullptr) {
|
||||
eventInterceptor(propName, event, strongTarget.reactTag);
|
||||
} else {
|
||||
RCTComponentEvent *componentEvent = [[RCTComponentEvent alloc] initWithName:propName
|
||||
@@ -158,13 +158,13 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
__block NSMutableData *defaultValue = nil;
|
||||
|
||||
return ^(id target, id json) {
|
||||
if (!target) {
|
||||
if (target == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get default value
|
||||
if (!defaultValue) {
|
||||
if (!json) {
|
||||
if (defaultValue == nullptr) {
|
||||
if (json == nullptr) {
|
||||
// We only set the defaultValue when we first pass a non-null
|
||||
// value, so if the first value sent for a prop is null, it's
|
||||
// a no-op (we'd be resetting it to its default when its
|
||||
@@ -186,10 +186,10 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
// Get value
|
||||
BOOL freeValueOnCompletion = NO;
|
||||
void *value = defaultValue.mutableBytes;
|
||||
if (json) {
|
||||
if (json != nullptr) {
|
||||
freeValueOnCompletion = YES;
|
||||
value = malloc(typeSignature.methodReturnLength);
|
||||
if (!value) {
|
||||
if (value == nullptr) {
|
||||
// CWE - 391 : Unchecked error condition
|
||||
// https://www.cvedetails.com/cwe-details/391/Unchecked-Error-Condition.html
|
||||
// https://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c
|
||||
@@ -201,7 +201,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
}
|
||||
|
||||
// Set value
|
||||
if (!targetInvocation) {
|
||||
if (targetInvocation == nullptr) {
|
||||
NSMethodSignature *signature = [target methodSignatureForSelector:setter];
|
||||
targetInvocation = [NSInvocation invocationWithMethodSignature:signature];
|
||||
targetInvocation.selector = setter;
|
||||
@@ -252,7 +252,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
// Disect keypath
|
||||
NSString *key = name;
|
||||
NSArray<NSString *> *parts = [keyPath componentsSeparatedByString:@"."];
|
||||
if (parts) {
|
||||
if (parts != nullptr) {
|
||||
key = parts.lastObject;
|
||||
parts = [parts subarrayWithRange:(NSRange){0, parts.count - 1}];
|
||||
}
|
||||
@@ -275,7 +275,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
} else {
|
||||
// Ordinary property handlers
|
||||
NSMethodSignature *typeSignature = [[RCTConvert class] methodSignatureForSelector:type];
|
||||
if (!typeSignature) {
|
||||
if (typeSignature == nullptr) {
|
||||
RCTLogError(@"No +[RCTConvert %@] function found.", NSStringFromSelector(type));
|
||||
return ^(__unused id<RCTComponent> view, __unused id json) {
|
||||
};
|
||||
@@ -347,7 +347,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
{
|
||||
RCTPropBlockDictionary *propBlocks = isShadowView ? _shadowPropBlocks : _viewPropBlocks;
|
||||
RCTPropBlock propBlock = propBlocks[name];
|
||||
if (!propBlock) {
|
||||
if (propBlock == nullptr) {
|
||||
propBlock = [self createPropBlock:name isShadowView:isShadowView];
|
||||
|
||||
#if RCT_DEBUG
|
||||
@@ -381,7 +381,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forView:(id<RCTComponent>)view isShadowView:(BOOL)isShadowView
|
||||
{
|
||||
if (!view) {
|
||||
if (view == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -467,13 +467,13 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
|
||||
// We need to handle both propConfig_* and propConfigShadow_* methods
|
||||
const char *underscorePos = strchr(selectorName + strlen("propConfig"), '_');
|
||||
if (!underscorePos) {
|
||||
if (underscorePos == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *name = @(underscorePos + 1);
|
||||
NSString *type = ((NSArray<NSString *> * (*)(id, SEL)) objc_msgSend)(managerClass, selector)[0];
|
||||
if (RCT_DEBUG && propTypes[name] && ![propTypes[name] isEqualToString:type]) {
|
||||
if (RCT_DEBUG && (propTypes[name] != nullptr) && ![propTypes[name] isEqualToString:type]) {
|
||||
RCTLogError(
|
||||
@"Property '%@' of component '%@' redefined from '%@' "
|
||||
"to '%@'",
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ lastResort(const char* tag, const char* msg, const char* arg = nullptr) {
|
||||
}
|
||||
#else
|
||||
std::cerr << msg;
|
||||
if (arg) {
|
||||
if (arg != nullptr) {
|
||||
std::cerr << ": " << arg;
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
|
||||
+3
-2
@@ -60,7 +60,8 @@ static std::unordered_map<int, std::string> responseBuffers;
|
||||
|
||||
/* static */ jboolean JInspectorNetworkReporter::isDebuggingEnabled(
|
||||
jni::alias_ref<jclass> /*unused*/) {
|
||||
return NetworkReporter::getInstance().isDebuggingEnabled();
|
||||
return static_cast<jboolean>(
|
||||
NetworkReporter::getInstance().isDebuggingEnabled());
|
||||
}
|
||||
|
||||
/* static */ void JInspectorNetworkReporter::reportRequestStart(
|
||||
@@ -138,7 +139,7 @@ static std::unordered_map<int, std::string> responseBuffers;
|
||||
jint requestId,
|
||||
jboolean cancelled) {
|
||||
NetworkReporter::getInstance().reportRequestFailed(
|
||||
std::to_string(requestId), cancelled);
|
||||
std::to_string(requestId), cancelled != 0u);
|
||||
}
|
||||
|
||||
/* static */ void JInspectorNetworkReporter::maybeStoreResponseBodyImpl(
|
||||
|
||||
@@ -320,7 +320,7 @@ std::string JSStringToSTLString(JSStringRef str) {
|
||||
buffer = heapBuffer.get();
|
||||
}
|
||||
size_t actualBytes = JSStringGetUTF8CString(str, buffer, maxBytes);
|
||||
if (!actualBytes) {
|
||||
if (actualBytes == 0u) {
|
||||
// Happens if maxBytes == 0 (never the case here) or if str contains
|
||||
// invalid UTF-16 data, since JSStringGetUTF8CString attempts a strict
|
||||
// conversion.
|
||||
@@ -437,7 +437,7 @@ jsi::Value JSCRuntime::evaluateJavaScript(
|
||||
JSValueRef res =
|
||||
JSEvaluateScript(ctx_, sourceRef, nullptr, sourceURLRef, 0, &exc);
|
||||
JSStringRelease(sourceRef);
|
||||
if (sourceURLRef) {
|
||||
if (sourceURLRef != nullptr) {
|
||||
JSStringRelease(sourceURLRef);
|
||||
}
|
||||
checkException(res, exc);
|
||||
@@ -597,7 +597,7 @@ void JSCRuntime::JSCObjectValue::invalidate() noexcept {
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::cloneSymbol(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCSymbolValue* symbol = static_cast<const JSCSymbolValue*>(pv);
|
||||
@@ -611,7 +611,7 @@ jsi::Runtime::PointerValue* JSCRuntime::cloneBigInt(
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::cloneString(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCStringValue* string = static_cast<const JSCStringValue*>(pv);
|
||||
@@ -620,7 +620,7 @@ jsi::Runtime::PointerValue* JSCRuntime::cloneString(
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::cloneObject(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCObjectValue* object = static_cast<const JSCObjectValue*>(pv);
|
||||
@@ -632,7 +632,7 @@ jsi::Runtime::PointerValue* JSCRuntime::cloneObject(
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::clonePropNameID(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCStringValue* string = static_cast<const JSCStringValue*>(pv);
|
||||
@@ -914,7 +914,7 @@ JSClassRef getNativeStateClass() {
|
||||
} // namespace
|
||||
|
||||
JSValueRef JSCRuntime::getNativeStateSymbol() {
|
||||
if (!nativeStateSymbol_) {
|
||||
if (nativeStateSymbol_ == nullptr) {
|
||||
JSStringRef symbolName =
|
||||
JSStringCreateWithUTF8CString("__internal_nativeState");
|
||||
JSValueRef symbol = JSValueMakeSymbol(ctx_, symbolName);
|
||||
@@ -1182,7 +1182,7 @@ jsi::Function JSCRuntime::createFunctionFromHostFunction(
|
||||
kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum |
|
||||
kJSPropertyAttributeDontDelete,
|
||||
&exc);
|
||||
if (exc) {
|
||||
if (exc != nullptr) {
|
||||
// Silently fail to set length
|
||||
exc = nullptr;
|
||||
}
|
||||
@@ -1198,7 +1198,7 @@ jsi::Function JSCRuntime::createFunctionFromHostFunction(
|
||||
kJSPropertyAttributeDontDelete,
|
||||
&exc);
|
||||
JSStringRelease(name);
|
||||
if (exc) {
|
||||
if (exc != nullptr) {
|
||||
// Silently fail to set name
|
||||
exc = nullptr;
|
||||
}
|
||||
@@ -1211,7 +1211,7 @@ jsi::Function JSCRuntime::createFunctionFromHostFunction(
|
||||
abort();
|
||||
}
|
||||
JSObjectRef funcCtor = JSValueToObject(ctx, value, &exc);
|
||||
if (!funcCtor) {
|
||||
if (funcCtor == nullptr) {
|
||||
// We can't do anything if Function is not an object
|
||||
return;
|
||||
}
|
||||
@@ -1439,7 +1439,7 @@ JSStringRef getEmptyString() {
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::makeStringValue(
|
||||
JSStringRef stringRef) const {
|
||||
if (!stringRef) {
|
||||
if (stringRef == nullptr) {
|
||||
stringRef = getEmptyString();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
@@ -1463,7 +1463,7 @@ jsi::PropNameID JSCRuntime::createPropNameID(JSStringRef str) {
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::makeObjectValue(
|
||||
JSObjectRef objectRef) const {
|
||||
if (!objectRef) {
|
||||
if (objectRef == nullptr) {
|
||||
objectRef = JSObjectMake(ctx_, nullptr, nullptr);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ class InspectorPackagerConnectionTestBase : public testing::Test {
|
||||
auto pages = getInspectorInstance().getPages();
|
||||
int liveConnectionCount = 0;
|
||||
for (size_t i = 0; i != localConnections_.objectsVended(); ++i) {
|
||||
if (localConnections_[i]) {
|
||||
if (localConnections_[i] != nullptr) {
|
||||
liveConnectionCount++;
|
||||
// localConnections_[i] is a strict mock and will complain when we
|
||||
// removePage if the call is unexpected.
|
||||
@@ -69,7 +69,7 @@ class InspectorPackagerConnectionTestBase : public testing::Test {
|
||||
for (auto& page : pages) {
|
||||
getInspectorInstance().removePage(page.id);
|
||||
}
|
||||
if (!pages.empty() && liveConnectionCount) {
|
||||
if (!pages.empty() && (liveConnectionCount != 0)) {
|
||||
if (!::testing::Test::HasFailure()) {
|
||||
FAIL()
|
||||
<< "Test case ended with " << liveConnectionCount
|
||||
|
||||
@@ -65,12 +65,12 @@ class JsiIntegrationPortableTestBase : public ::testing::Test,
|
||||
|
||||
~JsiIntegrationPortableTestBase() override {
|
||||
toPage_.reset();
|
||||
if (runtimeTarget_) {
|
||||
if (runtimeTarget_ != nullptr) {
|
||||
EXPECT_TRUE(instance_);
|
||||
instance_->unregisterRuntime(*runtimeTarget_);
|
||||
runtimeTarget_ = nullptr;
|
||||
}
|
||||
if (instance_) {
|
||||
if (instance_ != nullptr) {
|
||||
page_->unregisterInstance(*instance_);
|
||||
instance_ = nullptr;
|
||||
}
|
||||
@@ -108,12 +108,12 @@ class JsiIntegrationPortableTestBase : public ::testing::Test,
|
||||
}
|
||||
|
||||
void reload() {
|
||||
if (runtimeTarget_) {
|
||||
if (runtimeTarget_ != nullptr) {
|
||||
ASSERT_TRUE(instance_);
|
||||
instance_->unregisterRuntime(*runtimeTarget_);
|
||||
runtimeTarget_ = nullptr;
|
||||
}
|
||||
if (instance_) {
|
||||
if (instance_ != nullptr) {
|
||||
page_->unregisterInstance(*instance_);
|
||||
instance_ = nullptr;
|
||||
}
|
||||
|
||||
+2
-1
@@ -395,7 +395,8 @@ JNIArgs convertJSIArgsToJNIArgs(
|
||||
"boolean", argIndex, methodName, arg, &rt);
|
||||
}
|
||||
jarg->l = makeGlobalIfNecessary(
|
||||
jni::JBoolean::valueOf(arg->getBool()).release());
|
||||
jni::JBoolean::valueOf(static_cast<unsigned char>(arg->getBool()))
|
||||
.release());
|
||||
} else if (type == "Ljava/lang/String;") {
|
||||
if (!arg->isString()) {
|
||||
throw JavaTurboModuleArgumentConversionException(
|
||||
|
||||
Reference in New Issue
Block a user