Fix warnings detected on Android build
authorSylvain Becker <sylvain.becker@gmail.com>
Thu, 06 Dec 2018 09:22:00 +0100
changeset 12462b57435750c5b
parent 12461 14205d7f7715
child 12463 fb8dac9fbc5e
Fix warnings detected on Android build
src/events/SDL_mouse.c
src/events/SDL_touch.c
src/haptic/SDL_haptic.c
src/render/SDL_render.c
src/test/SDL_test_common.c
src/thread/pthread/SDL_systhread.c
src/video/SDL_RLEaccel.c
src/video/android/SDL_androidmouse.c
src/video/android/SDL_androidvideo.c
src/video/android/SDL_androidvideo.h
     1.1 --- a/src/events/SDL_mouse.c	Wed Dec 05 19:03:15 2018 -0500
     1.2 +++ b/src/events/SDL_mouse.c	Thu Dec 06 09:22:00 2018 +0100
     1.3 @@ -545,7 +545,7 @@
     1.4          SDL_SetMouseFocus(window);
     1.5      }
     1.6  
     1.7 -    if (!x && !y) {
     1.8 +    if (x == 0. && y == 0.) {
     1.9          return 0;
    1.10      }
    1.11  
     2.1 --- a/src/events/SDL_touch.c	Wed Dec 05 19:03:15 2018 -0500
     2.2 +++ b/src/events/SDL_touch.c	Thu Dec 06 09:22:00 2018 +0100
     2.3 @@ -315,7 +315,7 @@
     2.4      prel = pressure - finger->pressure;
     2.5  
     2.6      /* Drop events that don't change state */
     2.7 -    if (!xrel && !yrel && !prel) {
     2.8 +    if (xrel == 0. && yrel == 0. && prel == 0.) {
     2.9  #if 0
    2.10          printf("Touch event didn't change state - dropped!\n");
    2.11  #endif
     3.1 --- a/src/haptic/SDL_haptic.c	Wed Dec 05 19:03:15 2018 -0500
     3.2 +++ b/src/haptic/SDL_haptic.c	Thu Dec 06 09:22:00 2018 +0100
     3.3 @@ -26,7 +26,11 @@
     3.4  #include "SDL_assert.h"
     3.5  
     3.6  /* Global for SDL_windowshaptic.c */
     3.7 +#if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT)
     3.8  SDL_Haptic *SDL_haptics = NULL;
     3.9 +#else 
    3.10 +static SDL_Haptic *SDL_haptics = NULL;
    3.11 +#endif
    3.12  
    3.13  /*
    3.14   * Initializes the Haptic devices.
     4.1 --- a/src/render/SDL_render.c	Wed Dec 05 19:03:15 2018 -0500
     4.2 +++ b/src/render/SDL_render.c	Thu Dec 06 09:22:00 2018 +0100
     4.3 @@ -2415,8 +2415,8 @@
     4.4  
     4.5      for (i = 0; i < count-1; ++i) {
     4.6          if (points[i].x == points[i+1].x) {
     4.7 -            const int minY = SDL_min(points[i].y, points[i+1].y);
     4.8 -            const int maxY = SDL_max(points[i].y, points[i+1].y);
     4.9 +            const int minY = (int)SDL_min(points[i].y, points[i+1].y);
    4.10 +            const int maxY = (int)SDL_max(points[i].y, points[i+1].y);
    4.11  
    4.12              frect = &frects[nrects++];
    4.13              frect->x = points[i].x * renderer->scale.x;
    4.14 @@ -2424,8 +2424,8 @@
    4.15              frect->w = renderer->scale.x;
    4.16              frect->h = (maxY - minY + 1) * renderer->scale.y;
    4.17          } else if (points[i].y == points[i+1].y) {
    4.18 -            const int minX = SDL_min(points[i].x, points[i+1].x);
    4.19 -            const int maxX = SDL_max(points[i].x, points[i+1].x);
    4.20 +            const int minX = (int)SDL_min(points[i].x, points[i+1].x);
    4.21 +            const int maxX = (int)SDL_max(points[i].x, points[i+1].x);
    4.22  
    4.23              frect = &frects[nrects++];
    4.24              frect->x = minX * renderer->scale.x;
     5.1 --- a/src/test/SDL_test_common.c	Wed Dec 05 19:03:15 2018 -0500
     5.2 +++ b/src/test/SDL_test_common.c	Thu Dec 06 09:22:00 2018 +0100
     5.3 @@ -999,7 +999,7 @@
     5.4                  }
     5.5                  if (state->logical_w && state->logical_h) {
     5.6                      SDL_RenderSetLogicalSize(state->renderers[i], state->logical_w, state->logical_h);
     5.7 -                } else if (state->scale) {
     5.8 +                } else if (state->scale != 0.) {
     5.9                      SDL_RenderSetScale(state->renderers[i], state->scale, state->scale);
    5.10                  }
    5.11                  if (state->verbose & VERBOSE_RENDER) {
     6.1 --- a/src/thread/pthread/SDL_systhread.c	Wed Dec 05 19:03:15 2018 -0500
     6.2 +++ b/src/thread/pthread/SDL_systhread.c	Thu Dec 06 09:22:00 2018 +0100
     6.3 @@ -50,7 +50,6 @@
     6.4  #include "SDL_log.h"
     6.5  #include "SDL_platform.h"
     6.6  #include "SDL_thread.h"
     6.7 -#include "SDL_system.h"
     6.8  #include "../SDL_thread_c.h"
     6.9  #include "../SDL_systhread.h"
    6.10  #ifdef __ANDROID__
     7.1 --- a/src/video/SDL_RLEaccel.c	Wed Dec 05 19:03:15 2018 -0500
     7.2 +++ b/src/video/SDL_RLEaccel.c	Thu Dec 06 09:22:00 2018 +0100
     7.3 @@ -1510,8 +1510,9 @@
     7.4              if (run) {
     7.5                  srcbuf += uncopy_opaque(dst + ofs, srcbuf, run, df, sf);
     7.6                  ofs += run;
     7.7 -            } else if (!ofs)
     7.8 -                return (SDL_TRUE);
     7.9 +            } else if (!ofs) {
    7.10 +                goto end_function;
    7.11 +            }
    7.12          } while (ofs < w);
    7.13  
    7.14          /* skip padding if needed */
    7.15 @@ -1532,7 +1533,8 @@
    7.16          } while (ofs < w);
    7.17          dst += surface->pitch >> 2;
    7.18      }
    7.19 -    /* Make the compiler happy */
    7.20 +
    7.21 +end_function:
    7.22      return (SDL_TRUE);
    7.23  }
    7.24  
     8.1 --- a/src/video/android/SDL_androidmouse.c	Wed Dec 05 19:03:15 2018 -0500
     8.2 +++ b/src/video/android/SDL_androidmouse.c	Thu Dec 06 09:22:00 2018 +0100
     8.3 @@ -234,7 +234,7 @@
     8.4              changes = state & ~last_state;
     8.5              button = TranslateButton(changes);
     8.6              last_state = state;
     8.7 -            SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
     8.8 +            SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y);
     8.9              SDL_SendMouseButton(Android_Window, 0, SDL_PRESSED, button);
    8.10              break;
    8.11  
    8.12 @@ -242,13 +242,13 @@
    8.13              changes = last_state & ~state;
    8.14              button = TranslateButton(changes);
    8.15              last_state = state;
    8.16 -            SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
    8.17 +            SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y);
    8.18              SDL_SendMouseButton(Android_Window, 0, SDL_RELEASED, button);
    8.19              break;
    8.20  
    8.21          case ACTION_MOVE:
    8.22          case ACTION_HOVER_MOVE:
    8.23 -            SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
    8.24 +            SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y);
    8.25              break;
    8.26  
    8.27          case ACTION_SCROLL:
     9.1 --- a/src/video/android/SDL_androidvideo.c	Wed Dec 05 19:03:15 2018 -0500
     9.2 +++ b/src/video/android/SDL_androidvideo.c	Thu Dec 06 09:22:00 2018 +0100
     9.3 @@ -64,7 +64,7 @@
     9.4  int Android_SurfaceHeight = 0;
     9.5  int Android_DeviceWidth = 0;
     9.6  int Android_DeviceHeight = 0;
     9.7 -Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
     9.8 +static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
     9.9  static int Android_ScreenRate = 0;
    9.10  
    9.11  SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
    9.12 @@ -221,7 +221,7 @@
    9.13      Android_DeviceWidth = deviceWidth;
    9.14      Android_DeviceHeight = deviceHeight;
    9.15      Android_ScreenFormat = format;
    9.16 -    Android_ScreenRate = rate;
    9.17 +    Android_ScreenRate = (int)rate;
    9.18  
    9.19      /*
    9.20        Update the resolution of the desktop mode, so that the window
    9.21 @@ -247,7 +247,7 @@
    9.22          display->display_modes[0].format = format;
    9.23          display->display_modes[0].w = Android_DeviceWidth;
    9.24          display->display_modes[0].h = Android_DeviceHeight;
    9.25 -        display->display_modes[0].refresh_rate = rate;
    9.26 +        display->display_modes[0].refresh_rate = (int)rate;
    9.27          display->current_mode = display->display_modes[0];
    9.28  
    9.29          SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, surfaceWidth, surfaceHeight);
    10.1 --- a/src/video/android/SDL_androidvideo.h	Wed Dec 05 19:03:15 2018 -0500
    10.2 +++ b/src/video/android/SDL_androidvideo.h	Thu Dec 06 09:22:00 2018 +0100
    10.3 @@ -41,7 +41,6 @@
    10.4  extern int Android_SurfaceHeight;
    10.5  extern int Android_DeviceWidth;
    10.6  extern int Android_DeviceHeight;
    10.7 -extern Uint32 Android_ScreenFormat;
    10.8  extern SDL_sem *Android_PauseSem, *Android_ResumeSem;
    10.9  extern SDL_Window *Android_Window;
   10.10