From 294584c608dd98796644a9a3ff69a076c1da460b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 4 Nov 2024 11:45:47 +0100 Subject: [PATCH 1/2] GCC/llvm: Enable a lot more warnings, error on missing return value --- CMakeLists.txt | 4 ++++ GPU/Common/PresentationCommon.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e538d4e2b7a8..a3553172dd85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -382,6 +382,10 @@ if(NOT MSVC) # NEON optimizations in libpng17 seem to cause PNG load errors, see #14485. add_definitions(-DPNG_ARM_NEON_OPT=0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type -Wno-unused-function -Wno-sign-compare -Wno-unused-but-set-variable -Wno-reorder -Wno-unknown-pragmas -Wno-unused-value -Wno-unused-variable") + # This one is very useful but has many false positives. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess") + if(ANDROID) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17") endif() diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 178b2b10ea10..f41686511b35 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -91,7 +91,7 @@ void CalculateDisplayOutputRect(FRect *rc, float origW, float origH, const FRect // Automatically set aspect ratio to match the display, IF the rotation matches the output display ratio! Otherwise, just // sets standard aspect ratio because actually stretching will just look silly. bool globalRotated = g_display.rotation == DisplayRotation::ROTATE_90 || g_display.rotation == DisplayRotation::ROTATE_270; - if (rotated == g_display.dp_yres > g_display.dp_xres) { + if (rotated == (g_display.dp_yres > g_display.dp_xres)) { origRatio = frameRatio; } else { origRatio *= aspectRatioAdjust; From cd6d4db7b8babec0e1a887252f83a2c68d26509d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 4 Nov 2024 12:05:42 +0100 Subject: [PATCH 2/2] Fix missing return value in another function --- ios/main.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ios/main.mm b/ios/main.mm index 6477c6b0c344..a2eb0f28ed8f 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -417,7 +417,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string dispatch_async(dispatch_get_main_queue(), ^{ [(AppDelegate *)[[UIApplication sharedApplication] delegate] restart:param1.c_str()]; }); - break; + return true; case SystemRequestType::EXIT_APP: // NOTE: on iOS, this is considered a crash and not a valid way to exit. @@ -508,8 +508,9 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string }); return true; default: - return false; + break; } + return false; } void System_Toast(std::string_view text) {}