From a2404c42a16e808952471e219cf25d4b1bedb05d Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 6 Jan 2018 12:53:53 +0100 Subject: [PATCH 1/2] Treat invalid aspect ratio setting values as Auto --- Source/Core/VideoCommon/RenderBase.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 0644984017..e9b0c3dff1 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -307,9 +307,6 @@ void Renderer::DrawDebugText() const char* ar_text = ""; switch (g_ActiveConfig.aspect_mode) { - case AspectMode::Auto: - ar_text = "Auto"; - break; case AspectMode::Stretch: ar_text = "Stretch"; break; @@ -319,6 +316,10 @@ void Renderer::DrawDebugText() case AspectMode::AnalogWide: ar_text = "Force 16:9"; break; + case AspectMode::Auto: + default: + ar_text = "Auto"; + break; } const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM"; @@ -441,6 +442,7 @@ void Renderer::UpdateDrawRectangle() target_aspect = AspectToWidescreen(VideoInterface::GetAspectRatio()); break; case AspectMode::Auto: + default: target_aspect = source_aspect; break; } From 1557e6ab05294c65253ca60774c332cfe9659191 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 8 Jan 2018 12:04:12 +0100 Subject: [PATCH 2/2] Specify underlying types for enums that get casted from integers Otherwise we might get UB if the value we cast is larger than the max value of the underlying type that the compiled picked for the enum. I haven't done any extensive check through Dolphin to find cases of this, I'm just fixing the cases I already know of. --- Source/Core/VideoCommon/VideoConfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index b472a2ab57..103b63b423 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -24,7 +24,7 @@ constexpr int EFB_SCALE_AUTO_INTEGRAL = 0; -enum class AspectMode +enum class AspectMode : int { Auto, AnalogWide, @@ -32,7 +32,7 @@ enum class AspectMode Stretch, }; -enum class StereoMode +enum class StereoMode : int { Off, SBS,