Skip to content

Commit

Permalink
Fix windows 4018 and 4244 compiler warnings (#41254)
Browse files Browse the repository at this point in the history
Summary:
Windows had to remove some previously suppressed compiler warnings and fork `ShadowNode.cpp` and `RawPropsParser.cpp` (See: microsoft/react-native-windows#12300) to fix them. This PR adds the right data types and static casts to get rid of the compiler warnings.

## Changelog:

[GENERAL] [FIXED] - Fix windows 4018 and 4244 compiler warnings

Pull Request resolved: #41254

Test Plan: tested in RNW Repository

Reviewed By: rshest

Differential Revision: D50820705

Pulled By: rozele

fbshipit-source-id: fa61f7ca428d31fc6be56c80215246ee2bdfc67c
  • Loading branch information
TatianaKapos authored and facebook-github-bot committed Nov 1, 2023
1 parent f3a916f commit 695a30d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const RawValue* RawPropsParser::at(
// 4950 lookups and equality checks on initialization of the parser, which
// happens exactly once per component.
size_t size = keys_.size();
for (int i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
if (keys_[i] == key) {
return nullptr;
}
Expand Down Expand Up @@ -69,7 +69,8 @@ const RawValue* RawPropsParser::at(
do {
rawProps.keyIndexCursor_++;

if (UNLIKELY(rawProps.keyIndexCursor_ >= keys_.size())) {
if (UNLIKELY(
static_cast<size_t>(rawProps.keyIndexCursor_) >= keys_.size())) {
#ifdef REACT_NATIVE_DEBUG
if (resetLoop) {
LOG(ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void ShadowNode::replaceChild(
auto& children = const_cast<ShadowNode::ListOfShared&>(*children_);
auto size = children.size();

if (suggestedIndex != -1 && suggestedIndex < size) {
if (suggestedIndex != -1 && static_cast<size_t>(suggestedIndex) < size) {
// If provided `suggestedIndex` is accurate,
// replacing in place using the index.
if (children.at(suggestedIndex).get() == &oldChild) {
Expand Down

0 comments on commit 695a30d

Please sign in to comment.