From c30e35fb44affb179c9a208cf0a3e4575347e76f Mon Sep 17 00:00:00 2001 From: Jon Thysell Date: Mon, 12 Aug 2024 10:00:24 -0700 Subject: [PATCH] Fix "C4715 not all control paths return a value" warning in MSVC (#45827) Summary: When integrating react-native into react-native-windows, we got the following build warning (which we treat as an error) when building ReactCommon: `C4715 not all control paths return a value` This PR adds defaults to the switches to make sure every path returns a value. See https://github.com/microsoft/react-native-windows/issues/13516 ## Changelog: [GENERAL] [FIXED] Fix "C4715 not all control paths return a value" warning in MSVC when building ReactCommon Pull Request resolved: https://github.com/facebook/react-native/pull/45827 Test Plan: The switches are checking enums this code should never be hit unless new enum values are added. Reviewed By: robhogan Differential Revision: D61103286 Pulled By: NickGerleman fbshipit-source-id: 2028cb60e0b438b9ac17a828f5e1b690052a0bec --- .../ReactCommon/react/renderer/core/EventQueueProcessor.cpp | 1 + packages/react-native/ReactCommon/react/runtime/TimerManager.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp index d8f0a2748d5..ce1485b3ac1 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp @@ -59,6 +59,7 @@ void EventQueueProcessor::flushEvents( return hasContinuousEventStarted_ ? ReactEventPriority::Continuous : ReactEventPriority::Default; } + return ReactEventPriority::Default; }(); } else { if (event.category == RawEvent::Category::ContinuousEnd) { diff --git a/packages/react-native/ReactCommon/react/runtime/TimerManager.cpp b/packages/react-native/ReactCommon/react/runtime/TimerManager.cpp index 7da83c13825..bc205ce3181 100644 --- a/packages/react-native/ReactCommon/react/runtime/TimerManager.cpp +++ b/packages/react-native/ReactCommon/react/runtime/TimerManager.cpp @@ -48,6 +48,7 @@ inline const char* getTimerSourceName(TimerSource source) { case TimerSource::RequestAnimationFrame: return "requestAnimationFrame"; } + return "unknown"; } } // namespace