From 252dc85e95892fe54e4991fb70f60c8f5a1389bb Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Thu, 6 Dec 2018 09:22:00 +0100 Subject: [PATCH] Fix warnings detected on Android build --- src/events/SDL_mouse.c | 2 +- src/events/SDL_touch.c | 2 +- src/haptic/SDL_haptic.c | 4 ++++ src/render/SDL_render.c | 8 ++++---- src/test/SDL_test_common.c | 2 +- src/thread/pthread/SDL_systhread.c | 1 - src/video/SDL_RLEaccel.c | 8 +++++--- src/video/android/SDL_androidmouse.c | 6 +++--- src/video/android/SDL_androidvideo.c | 6 +++--- src/video/android/SDL_androidvideo.h | 1 - 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index ff23c5ea46e1b..75980ff0d328b 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -545,7 +545,7 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S SDL_SetMouseFocus(window); } - if (!x && !y) { + if (x == 0. && y == 0.) { return 0; } diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index bed2c499a622b..2c175aba114cf 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -315,7 +315,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, prel = pressure - finger->pressure; /* Drop events that don't change state */ - if (!xrel && !yrel && !prel) { + if (xrel == 0. && yrel == 0. && prel == 0.) { #if 0 printf("Touch event didn't change state - dropped!\n"); #endif diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index f23ba18df2aa8..2f4c57b4352a0 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -26,7 +26,11 @@ #include "SDL_assert.h" /* Global for SDL_windowshaptic.c */ +#if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT) SDL_Haptic *SDL_haptics = NULL; +#else +static SDL_Haptic *SDL_haptics = NULL; +#endif /* * Initializes the Haptic devices. diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 2d087258e1b9a..1344453f3b379 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -2415,8 +2415,8 @@ RenderDrawLinesWithRectsF(SDL_Renderer * renderer, for (i = 0; i < count-1; ++i) { if (points[i].x == points[i+1].x) { - const int minY = SDL_min(points[i].y, points[i+1].y); - const int maxY = SDL_max(points[i].y, points[i+1].y); + const int minY = (int)SDL_min(points[i].y, points[i+1].y); + const int maxY = (int)SDL_max(points[i].y, points[i+1].y); frect = &frects[nrects++]; frect->x = points[i].x * renderer->scale.x; @@ -2424,8 +2424,8 @@ RenderDrawLinesWithRectsF(SDL_Renderer * renderer, frect->w = renderer->scale.x; frect->h = (maxY - minY + 1) * renderer->scale.y; } else if (points[i].y == points[i+1].y) { - const int minX = SDL_min(points[i].x, points[i+1].x); - const int maxX = SDL_max(points[i].x, points[i+1].x); + const int minX = (int)SDL_min(points[i].x, points[i+1].x); + const int maxX = (int)SDL_max(points[i].x, points[i+1].x); frect = &frects[nrects++]; frect->x = minX * renderer->scale.x; diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 81dd39eb146e4..81ec342cb81e5 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -999,7 +999,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state) } if (state->logical_w && state->logical_h) { SDL_RenderSetLogicalSize(state->renderers[i], state->logical_w, state->logical_h); - } else if (state->scale) { + } else if (state->scale != 0.) { SDL_RenderSetScale(state->renderers[i], state->scale, state->scale); } if (state->verbose & VERBOSE_RENDER) { diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index bf655ca51eab9..dba7df92b69af 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -50,7 +50,6 @@ #include "SDL_log.h" #include "SDL_platform.h" #include "SDL_thread.h" -#include "SDL_system.h" #include "../SDL_thread_c.h" #include "../SDL_systhread.h" #ifdef __ANDROID__ diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 661cb1f5344b8..3fe16b36fcb4b 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1510,8 +1510,9 @@ UnRLEAlpha(SDL_Surface * surface) if (run) { srcbuf += uncopy_opaque(dst + ofs, srcbuf, run, df, sf); ofs += run; - } else if (!ofs) - return (SDL_TRUE); + } else if (!ofs) { + goto end_function; + } } while (ofs < w); /* skip padding if needed */ @@ -1532,7 +1533,8 @@ UnRLEAlpha(SDL_Surface * surface) } while (ofs < w); dst += surface->pitch >> 2; } - /* Make the compiler happy */ + +end_function: return (SDL_TRUE); } diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index 037b4538cb6f0..a66672827bf9f 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -234,7 +234,7 @@ Android_OnMouse(int state, int action, float x, float y, SDL_bool relative) changes = state & ~last_state; button = TranslateButton(changes); last_state = state; - SDL_SendMouseMotion(Android_Window, 0, relative, x, y); + SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y); SDL_SendMouseButton(Android_Window, 0, SDL_PRESSED, button); break; @@ -242,13 +242,13 @@ Android_OnMouse(int state, int action, float x, float y, SDL_bool relative) changes = last_state & ~state; button = TranslateButton(changes); last_state = state; - SDL_SendMouseMotion(Android_Window, 0, relative, x, y); + SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y); SDL_SendMouseButton(Android_Window, 0, SDL_RELEASED, button); break; case ACTION_MOVE: case ACTION_HOVER_MOVE: - SDL_SendMouseMotion(Android_Window, 0, relative, x, y); + SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y); break; case ACTION_SCROLL: diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 589461afbe07c..852bb360fb5fd 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -64,7 +64,7 @@ int Android_SurfaceWidth = 0; int Android_SurfaceHeight = 0; int Android_DeviceWidth = 0; int Android_DeviceHeight = 0; -Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN; +static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN; static int Android_ScreenRate = 0; SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL; @@ -221,7 +221,7 @@ Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth Android_DeviceWidth = deviceWidth; Android_DeviceHeight = deviceHeight; Android_ScreenFormat = format; - Android_ScreenRate = rate; + Android_ScreenRate = (int)rate; /* Update the resolution of the desktop mode, so that the window @@ -247,7 +247,7 @@ Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth display->display_modes[0].format = format; display->display_modes[0].w = Android_DeviceWidth; display->display_modes[0].h = Android_DeviceHeight; - display->display_modes[0].refresh_rate = rate; + display->display_modes[0].refresh_rate = (int)rate; display->current_mode = display->display_modes[0]; SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, surfaceWidth, surfaceHeight); diff --git a/src/video/android/SDL_androidvideo.h b/src/video/android/SDL_androidvideo.h index 6dce7ed7dda34..ad07cd0c8dac3 100644 --- a/src/video/android/SDL_androidvideo.h +++ b/src/video/android/SDL_androidvideo.h @@ -41,7 +41,6 @@ extern int Android_SurfaceWidth; extern int Android_SurfaceHeight; extern int Android_DeviceWidth; extern int Android_DeviceHeight; -extern Uint32 Android_ScreenFormat; extern SDL_sem *Android_PauseSem, *Android_ResumeSem; extern SDL_Window *Android_Window;