Skip to content

Commit

Permalink
Fix Type Casting Warnings in ReactCommon (#39818)
Browse files Browse the repository at this point in the history
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: #39818

Reviewed By: rshest

Differential Revision: D49940422

Pulled By: NickGerleman

fbshipit-source-id: e4d44326806a2b1974c7e50770e61807a007e39f
  • Loading branch information
chiaramooney authored and facebook-github-bot committed Oct 9, 2023
1 parent 476a323 commit 570655d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void YogaLayoutableShadowNode::replaceChild(
}

bool suggestedIndexAccurate = suggestedIndex >= 0 &&
suggestedIndex < yogaLayoutableChildren_.size() &&
suggestedIndex < static_cast<int32_t>(yogaLayoutableChildren_.size()) &&
yogaLayoutableChildren_[suggestedIndex].get() == layoutableOldChild;

auto oldChildIter = suggestedIndexAccurate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(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<int>(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<int>(layout_.padding.size()),
"Edge must be top/left/bottom/right");
layout_.padding[edge] = padding;
}

Expand All @@ -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<int>(layout_.position.size()),
"Edge must be top/left/bottom/right");
layout_.position[edge] = position;
}

Expand Down

0 comments on commit 570655d

Please sign in to comment.