From 32c077216c284c88639ad60b79f94017937d7e3e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 3 Jan 2023 15:59:35 -0800
Subject: [PATCH] Fixed warnings
---
src/events/SDL_mouse.c | 2 +-
src/file/SDL_rwops.c | 4 ++--
src/joystick/hidapi/SDL_hidapi_xboxone.c | 2 +-
src/timer/unix/SDL_systimer.c | 4 ++--
src/video/SDL_video.c | 6 +++---
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 247f577a51db..849ffe432607 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -508,7 +508,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
mouse->x = x;
mouse->y = y;
mouse->has_position = SDL_TRUE;
- } else if (!xrel && !yrel) { /* Drop events that don't change state */
+ } else if (xrel == 0.0f && yrel == 0.0f) { /* Drop events that don't change state */
#ifdef DEBUG_MOUSE
SDL_Log("Mouse event didn't change state - dropped!\n");
#endif
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index c714d90969a2..d1a2e8493fee 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -375,7 +375,7 @@ stdio_read(SDL_RWops *context, void *ptr, Sint64 size)
{
size_t nread;
- nread = fread(ptr, 1, size, (FILE *)context->hidden.stdio.fp);
+ nread = fread(ptr, 1, (size_t)size, (FILE *)context->hidden.stdio.fp);
if (nread == 0 && ferror((FILE *)context->hidden.stdio.fp)) {
return SDL_Error(SDL_EFREAD);
}
@@ -387,7 +387,7 @@ stdio_write(SDL_RWops *context, const void *ptr, Sint64 size)
{
size_t nwrote;
- nwrote = fwrite(ptr, 1, size, (FILE *)context->hidden.stdio.fp);
+ nwrote = fwrite(ptr, 1, (size_t)size, (FILE *)context->hidden.stdio.fp);
if (nwrote == 0 && ferror((FILE *)context->hidden.stdio.fp)) {
return SDL_Error(SDL_EFWRITE);
}
diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c
index 0b871adcbf03..68db961d5828 100644
--- a/src/joystick/hidapi/SDL_hidapi_xboxone.c
+++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c
@@ -700,7 +700,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
}
} else if (size == 64) {
if (ctx->last_state[46] != data[46]) {
- SDL_PrivateJoystickButton(joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[46] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_SendJoystickButton(joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[46] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
}
}
}
diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c
index 4ae259a56786..223d1700f1f0 100644
--- a/src/timer/unix/SDL_systimer.c
+++ b/src/timer/unix/SDL_systimer.c
@@ -158,8 +158,8 @@ void SDL_DelayNS(Uint64 ns)
/* Set the timeout interval */
#if HAVE_NANOSLEEP
- remaining.tv_sec = (ns / SDL_NS_PER_SECOND);
- remaining.tv_nsec = (ns % SDL_NS_PER_SECOND);
+ remaining.tv_sec = (time_t)(ns / SDL_NS_PER_SECOND);
+ remaining.tv_nsec = (long)(ns % SDL_NS_PER_SECOND);
#else
then = SDL_GetTicksNS();
#endif
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 99d6fdb69699..eaf139039cc3 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -922,7 +922,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di
}
/* Default to the desktop refresh rate */
- if (mode->refresh_rate) {
+ if (mode->refresh_rate > 0.0f) {
target_refresh_rate = mode->refresh_rate;
} else {
target_refresh_rate = display->desktop_mode.refresh_rate;
@@ -981,7 +981,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di
closest->w = mode->w;
closest->h = mode->h;
}
- if (match->refresh_rate) {
+ if (match->refresh_rate > 0.0f) {
closest->refresh_rate = match->refresh_rate;
} else {
closest->refresh_rate = mode->refresh_rate;
@@ -1043,7 +1043,7 @@ static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_Dis
if (!display_mode.h) {
display_mode.h = display->current_mode.h;
}
- if (!display_mode.refresh_rate) {
+ if (display_mode.refresh_rate == 0.0f) {
display_mode.refresh_rate = display->current_mode.refresh_rate;
}