From 8c06f57860278cd4ff4a03bf182d22a27fcd0779 Mon Sep 17 00:00:00 2001 From: Yajur Grover Date: Fri, 17 Jan 2025 05:14:55 -0800 Subject: [PATCH] Add default case to `facebook::react::displayModeToInt()` (#48711) 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: [General] [Fixed] - Add default case to `displayModeToInt()` function Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- .../ReactCommon/react/renderer/uimanager/primitives.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h b/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h index b88b288c99b..ec9ff8cf7ef 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h @@ -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; } }