From a9b87ee2015c4d67484648b45dcea303064d44bc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 4 Dec 2023 20:22:23 -0800 Subject: [PATCH] Fixed warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem --- src/video/windows/SDL_windowsevents.c | 7 +++++++ src/video/windows/SDL_windowsmouse.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 620ab332bd..1c45f711a7 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -1643,7 +1643,14 @@ void WIN_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window) void WIN_PumpEvents(SDL_VideoDevice *_this) { MSG msg; +#ifdef _MSC_VER /* We explicitly want to use GetTickCount(), not GetTickCount64() */ +#pragma warning(push) +#pragma warning(disable : 28159) +#endif DWORD end_ticks = GetTickCount() + 1; +#ifdef _MSC_VER +#pragma warning(pop) +#endif int new_messages = 0; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) const Uint8 *keystate; diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index 21e19685b1..95d2e01cfd 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -316,10 +316,17 @@ void WIN_SetCursorPos(int x, int y) SetCursorPos(x, y); /* Flush any mouse motion prior to or associated with this warp */ +#ifdef _MSC_VER /* We explicitly want to use GetTickCount(), not GetTickCount64() */ +#pragma warning(push) +#pragma warning(disable : 28159) +#endif SDL_last_warp_time = GetTickCount(); if (!SDL_last_warp_time) { SDL_last_warp_time = 1; } +#ifdef _MSC_VER +#pragma warning(pop) +#endif } static int WIN_WarpMouse(SDL_Window *window, float x, float y)