From 10de0975f47aeace5a31ff99a5cceb5549a9be31 Mon Sep 17 00:00:00 2001 From: Kp Date: Mon, 6 May 2019 00:36:16 +0000 Subject: [PATCH] Fix gcc-9 build of joy.cpp gcc-9 fails to constrain `i`, then warns that very large `i` would be truncated. Add `cf_assert` and `xrange` to inform gcc that `i` is constrained. --- common/arch/sdl/joy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/arch/sdl/joy.cpp b/common/arch/sdl/joy.cpp index 8daabda2d..155962f53 100644 --- a/common/arch/sdl/joy.cpp +++ b/common/arch/sdl/joy.cpp @@ -295,8 +295,9 @@ void joy_init() #endif const auto n = check_warn_joy_support_limit(SDL_NumJoysticks(), "joystick", DXX_MAX_JOYSTICKS); + cf_assert(n <= DXX_MAX_JOYSTICKS); unsigned joystick_n_buttons = 0, joystick_n_axes = 0; - for (unsigned i = 0; i < n; i++) + range_for (const unsigned i, xrange(n)) { auto &joystick = SDL_Joysticks[num_joysticks]; const auto handle = SDL_JoystickOpen(i);