Browse Source

Fixed Visual Studio warning 4245

Sam Lantinga 2 years ago
parent
commit
85ee1498a5

+ 2 - 2
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;
 

+ 1 - 1
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;
 }

+ 1 - 1
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();
 

+ 1 - 1
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;

+ 1 - 1
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);
 }

+ 1 - 1
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 */