Skip to content

Commit

Permalink
Add default case to facebook::react::displayModeToInt() (#48711)
Browse files Browse the repository at this point in the history
Summary:
In the `displayModeToInt()` function, there is no default case defined which is causing the following warning in React Native Windows when trying to build on the New Architecture:
```
##[error]node_modules\react-native\ReactCommon\react\renderer\uimanager\primitives.h(163,1): Error C2220: the following warning is treated as an error
D:\a\_work\1\s\node_modules\react-native\ReactCommon\react\renderer\uimanager\primitives.h(163,1): error C2220: the following warning is treated as an error [D:\a\_work\1\s\vnext\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
##[warning]node_modules\react-native\ReactCommon\react\renderer\uimanager\primitives.h(163,1): Warning C4715: 'facebook::react::displayModeToInt': not all control paths return a value
D:\a\_work\1\s\node_modules\react-native\ReactCommon\react\renderer\uimanager\primitives.h(163,1): warning C4715: 'facebook::react::displayModeToInt': not all control paths return a value [D:\a\_work\1\s\vnext\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
```

Adding the default case removes the warning and resolves the issue. Not sure if using the -1 value in this case is appropriate.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[General] [Fixed] - Add default case to `displayModeToInt()` function

Pull Request resolved: #48711

Test Plan: Tested on React Native Windows New Arch application and was able to build successfully.

Reviewed By: javache

Differential Revision: D68265335

Pulled By: rshest

fbshipit-source-id: 4724a4c7391b9bf651a122f5de227a0c5e0b6212
  • Loading branch information
Yajur-Grover authored and facebook-github-bot committed Jan 17, 2025
1 parent eced906 commit 8c06f57
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ inline static int displayModeToInt(const DisplayMode value) {
return 2;
case DisplayMode::Hidden:
return 3;
default:
react_native_assert(0 && "displayModeToInt: Invalid DisplayMode");
return -1;
}
}

Expand Down

0 comments on commit 8c06f57

Please sign in to comment.