From 570655d80fcb1f213de07af05798897e5dbe42b9 Mon Sep 17 00:00:00 2001 From: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:07:46 -0700 Subject: [PATCH] Fix Type Casting Warnings in ReactCommon (#39818) Summary: Casting warnings are treated as errors in React Native Windows. Adjusting casting to fix warnings. ## Changelog: [GENERAL] [FIXED] - Fixes type casting warnings that are treated as errors downstream in React Native Windows. Pull Request resolved: https://github.com/facebook/react-native/pull/39818 Reviewed By: rshest Differential Revision: D49940422 Pulled By: NickGerleman fbshipit-source-id: e4d44326806a2b1974c7e50770e61807a007e39f --- .../components/view/YogaLayoutableShadowNode.cpp | 2 +- .../react/renderer/components/view/conversions.h | 2 +- .../react-native/ReactCommon/yoga/yoga/node/Node.cpp | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 3ba845ff638d19..cb94ab0bed19c9 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -276,7 +276,7 @@ void YogaLayoutableShadowNode::replaceChild( } bool suggestedIndexAccurate = suggestedIndex >= 0 && - suggestedIndex < yogaLayoutableChildren_.size() && + suggestedIndex < static_cast(yogaLayoutableChildren_.size()) && yogaLayoutableChildren_[suggestedIndex].get() == layoutableOldChild; auto oldChildIter = suggestedIndexAccurate diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h index ca969ed54dd2b3..e38ab6b7b51805 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h @@ -866,7 +866,7 @@ inline std::string toString(const yoga::Style::Edges& value) { auto result = std::string{}; auto separator = std::string{", "}; - for (auto i = 0; i < names.size(); i++) { + for (size_t i = 0; i < names.size(); i++) { YGValue v = value[i]; if (v.unit == YGUnitUndefined) { continue; diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp index 1a610baeae1802..d84aac542fc5fb 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp @@ -277,19 +277,22 @@ void Node::setLayoutDirection(Direction direction) { void Node::setLayoutMargin(float margin, YGEdge edge) { assertFatal( - edge < layout_.margin.size(), "Edge must be top/left/bottom/right"); + edge < static_cast(layout_.margin.size()), + "Edge must be top/left/bottom/right"); layout_.margin[edge] = margin; } void Node::setLayoutBorder(float border, YGEdge edge) { assertFatal( - edge < layout_.border.size(), "Edge must be top/left/bottom/right"); + edge < static_cast(layout_.border.size()), + "Edge must be top/left/bottom/right"); layout_.border[edge] = border; } void Node::setLayoutPadding(float padding, YGEdge edge) { assertFatal( - edge < layout_.padding.size(), "Edge must be top/left/bottom/right"); + edge < static_cast(layout_.padding.size()), + "Edge must be top/left/bottom/right"); layout_.padding[edge] = padding; } @@ -303,7 +306,8 @@ void Node::setLayoutComputedFlexBasis(const FloatOptional computedFlexBasis) { void Node::setLayoutPosition(float position, YGEdge edge) { assertFatal( - edge < layout_.position.size(), "Edge must be top/left/bottom/right"); + edge < static_cast(layout_.position.size()), + "Edge must be top/left/bottom/right"); layout_.position[edge] = position; }