From 37a86f24f0aed0aea81c87a0c655ade64fce7394 Mon Sep 17 00:00:00 2001 From: ben1 Date: Mon, 25 May 2020 15:22:25 +1000 Subject: [PATCH] Win32: Fix VS /W4 compile warnings These are harmless errors but the code was worth fixing just to reduce confusion and be more explicit. E.g. using a different variable name for a new variable of a different type in win32_joystick.c. Closes #1700. (cherry picked from commit a84a30ab6399eedd4606da226fe4f02eab3c2d2e) --- src/egl_context.c | 16 +++++++--------- src/win32_joystick.c | 10 +++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index e458bfb8..6288fb7c 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -588,18 +588,16 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, } // Set up attributes for surface creation + index = 0; + + if (fbconfig->sRGB) { - int index = 0; - - if (fbconfig->sRGB) - { - if (_glfw.egl.KHR_gl_colorspace) - setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); - } - - setAttrib(EGL_NONE, EGL_NONE); + if (_glfw.egl.KHR_gl_colorspace) + setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); } + setAttrib(EGL_NONE, EGL_NONE); + window->context.egl.surface = eglCreateWindowSurface(_glfw.egl.display, config, diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 4ffc9fbf..62ad7a53 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -356,7 +356,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { - _GLFWjoystick* js = _glfw.joysticks + jid; + js = _glfw.joysticks + jid; if (js->present) { if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0) @@ -672,11 +672,11 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) }; // Screams of horror are appropriate at this point - int state = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES); - if (state < 0 || state > 8) - state = 8; + int stateIndex = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES); + if (stateIndex < 0 || stateIndex > 8) + stateIndex = 8; - _glfwInputJoystickHat(js, pi, states[state]); + _glfwInputJoystickHat(js, pi, states[stateIndex]); pi++; break; }