From f2bb58e5024cb2eac1bab510fc7bc3e4ee6d6aa4 Mon Sep 17 00:00:00 2001 From: Lib Date: Fri, 8 May 2026 04:22:06 +0000 Subject: [PATCH] system: remove dead s_startup_cancelled atomic and its guards s_startup_cancelled is an atomic_bool static that has been a dead flag since the swanstation fork's first import. The codebase only ever: - Reads it (3 sites: 2 error-report guards, 1 mid-boot bail-out) - Stores false to it once, in System::Boot() It is never stored as true anywhere. The flag is therefore permanently false, every IsStartupCancelled() call always returns false, every '!IsStartupCancelled()' guard always evaluates true, and the one positive guard ('if (IsStartupCancelled()) Shutdown()') is unreachable. The comment at the unreachable bail-out gives away the origin: 'shading compilers took too long and the user closed the application'. That refers to upstream DuckStation's native UI, where a GUI thread could set the flag while shader compilation ran on the boot thread. swanstation is libretro-only - it has no equivalent UI thread, no way for a frontend to interrupt boot mid-flight, and no path that ever flips the flag to true. Drop the lot: - s_startup_cancelled static - IsStartupCancelled() function and its system.h declaration - s_startup_cancelled.store(false) in Boot() - The three '!IsStartupCancelled()' / 'IsStartupCancelled()' guards. The two error-reporting guards become unconditional - if Boot() or CreateGPU() fails, we always want to surface the error to the user, which is the behaviour we already had since the guard was never satisfied. The mid-boot bail-out branch was unreachable and is removed entirely. Linux x64 build still warning-clean. .so size drops from 8048544 to 8048432 bytes (-112) from removing the dead branches. 25 retro_* exports unchanged. Behaviour is identical. --- src/core/host_interface.cpp | 8 ++------ src/core/system.cpp | 18 +----------------- src/core/system.h | 2 -- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index b9c4208b..e8c351c3 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -62,12 +62,8 @@ bool HostInterface::BootSystem(std::shared_ptr parameters) if (!System::Boot(*parameters)) { - if (!System::IsStartupCancelled()) - { - ReportError( - g_host_interface->TranslateString("System", "System failed to boot. The log may contain more information.")); - } - + ReportError( + g_host_interface->TranslateString("System", "System failed to boot. The log may contain more information.")); m_audio_stream.reset(); ReleaseHostDisplay(); return false; diff --git a/src/core/system.cpp b/src/core/system.cpp index 2fa56b83..5879dd61 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -95,7 +95,6 @@ static void UpdateRunningGame(const char* path, CDImage* image); static bool CheckForSBIFile(CDImage* image); static State s_state = State::Shutdown; -static std::atomic_bool s_startup_cancelled{false}; static ConsoleRegion s_region = ConsoleRegion::NTSC_U; TickCount g_ticks_per_second = MASTER_CLOCK; @@ -140,11 +139,6 @@ bool IsValid() return s_state != State::Shutdown && s_state != State::Starting; } -bool IsStartupCancelled() -{ - return s_startup_cancelled.load(); -} - ConsoleRegion GetRegion() { return s_region; @@ -516,9 +510,7 @@ bool RecreateGPU(GPURenderer renderer, bool update_display /* = true*/) g_gpu.reset(); if (!CreateGPU(renderer)) { - if (!IsStartupCancelled()) - g_host_interface->ReportError("Failed to recreate GPU."); - + g_host_interface->ReportError("Failed to recreate GPU."); System::Shutdown(); return false; } @@ -591,7 +583,6 @@ bool ShouldCheckForImagePatches() bool Boot(const SystemBootParameters& params) { s_state = State::Starting; - s_startup_cancelled.store(false); s_region = g_settings.region; if (params.state_stream) @@ -765,13 +756,6 @@ bool Initialize(bool force_software_renderer) if (g_settings.gpu_pgxp_enable) PGXP::Initialize(); - // Was startup cancelled? (e.g. shading compilers took too long and the user closed the application) - if (IsStartupCancelled()) - { - Shutdown(); - return false; - } - // CPU code cache must happen after GPU, because it might steal our address space. CPU::CodeCache::Initialize(); diff --git a/src/core/system.h b/src/core/system.h index 27614f21..d8f85438 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -66,8 +66,6 @@ State GetState(); bool IsShutdown(); bool IsValid(); -bool IsStartupCancelled(); - ConsoleRegion GetRegion(); bool IsPALRegion();