From 9b2e7dc2e29943222de4e3dfbd614a7793cccd49 Mon Sep 17 00:00:00 2001 From: Johnny D Date: Fri, 18 Sep 2026 17:43:14 -0400 Subject: [PATCH] Keep SDL event capacity at the C ABI's uint32_t width Fix MSVC C4267/C2220 in Dolphin's /W4 /WX build. Define the capacity once with non-narrowing uint32_t list initialization and use it for both the stack array extent and s2k_read. No warning suppression, buffer-size change, or controller behavior change. A compile-only exact-width overload regression against the real adapter fails before and passes after this change with both Clang and GCC. Dolphin PR #5 carries that regression and the full native application checks. --- Integrations/SDL3/Switch2KitSDL3.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Integrations/SDL3/Switch2KitSDL3.cpp b/Integrations/SDL3/Switch2KitSDL3.cpp index a732030..0d855ab 100644 --- a/Integrations/SDL3/Switch2KitSDL3.cpp +++ b/Integrations/SDL3/Switch2KitSDL3.cpp @@ -465,9 +465,11 @@ struct SDL3Adapter::Impl { lastPump = now; wasActive = active; // SDL first expires finished effects; renewal below must not resurrect one. SDL_UpdateJoysticks(); - std::array events{}; + // Match the C ABI width and the backing array without implicit narrowing. + constexpr uint32_t eventCapacity{S2K_EVENT_CAPACITY}; + std::array events{}; uint32_t count{}, flags{}; - const auto result = s2k_read(context, events.data(), events.size(), sizeof(S2KEvent), &count, + const auto result = s2k_read(context, events.data(), eventCapacity, sizeof(S2KEvent), &count, &snapshot, sizeof(snapshot), &flags); if (result != S2K_OK) { clear(); return error = result; } const auto clock = ClockPair::sample();