From 85ee1498a5c2bd9af75a4a393ac3b2066e52238b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 30 Mar 2023 14:02:06 -0700 Subject: [PATCH] Fixed Visual Studio warning 4245 --- src/joystick/hidapi/SDL_hidapijoystick.c | 4 ++-- src/joystick/virtual/SDL_virtualjoystick.c | 2 +- src/timer/SDL_timer.c | 2 +- src/video/SDL_pixels.c | 2 +- src/video/windows/SDL_windowsevents.c | 2 +- src/video/windows/SDL_windowsvideo.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 5a7c59ba94..35ba2d3f9b 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -1380,14 +1380,14 @@ static SDL_JoystickGUID HIDAPI_JoystickGetDeviceGUID(int device_index) static SDL_JoystickID HIDAPI_JoystickGetDeviceInstanceID(int device_index) { - SDL_JoystickID joystickID = -1; + SDL_JoystickID joystickID = 0; HIDAPI_GetDeviceByIndex(device_index, &joystickID); return joystickID; } static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) { - SDL_JoystickID joystickID = -1; + SDL_JoystickID joystickID = 0; SDL_HIDAPI_Device *device = HIDAPI_GetDeviceByIndex(device_index, &joystickID); struct joystick_hwdata *hwdata; diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index c1d9d0d7ae..b221b29edc 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -396,7 +396,7 @@ static SDL_JoystickID VIRTUAL_JoystickGetDeviceInstanceID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); if (hwdata == NULL) { - return -1; + return 0; } return hwdata->instance_id; } diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 15840c3898..11d780a3b2 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -141,7 +141,7 @@ static int SDLCALL SDL_TimerThread(void *_data) } /* Initial delay if there are no timers */ - delay = SDL_MUTEX_MAXWAIT; + delay = (Uint64)SDL_MUTEX_MAXWAIT; tick = SDL_GetTicksNS(); diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 6919af4bca..6b9f85ffbd 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -796,7 +796,7 @@ Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) int i; Uint8 pixel = 0; - smallest = ~0; + smallest = ~0U; for (i = 0; i < pal->ncolors; ++i) { rd = pal->colors[i].r - r; gd = pal->colors[i].g - g; diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index a619810dc5..8133ed93ca 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -587,7 +587,7 @@ static BOOL WIN_ConvertUTF32toUTF8(UINT32 codepoint, char *text) static BOOL WIN_ConvertUTF16toUTF8(UINT32 high_surrogate, UINT32 low_surrogate, char *text) { - const UINT32 SURROGATE_OFFSET = 0x10000 - (0xD800 << 10) - 0xDC00; + const UINT32 SURROGATE_OFFSET = 0x10000U - (0xD800 << 10) - 0xDC00; const UINT32 codepoint = (high_surrogate << 10) + low_surrogate + SURROGATE_OFFSET; return WIN_ConvertUTF32toUTF8(codepoint, text); } diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 8a9085986c..65f364ec56 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -684,7 +684,7 @@ SDL_SystemTheme WIN_GetSystemTheme(void) SDL_SystemTheme theme = SDL_SYSTEM_THEME_LIGHT; HKEY hKey; DWORD dwType = REG_DWORD; - DWORD value = ~0; + DWORD value = ~0U; DWORD length = sizeof(value); /* Technically this isn't the system theme, but it's the preference for applications */