Fix some more compiler warnings on armcc.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 03 Mar 2017 16:38:17 -0500
changeset 1092697c829825e0e
parent 10925 4de9d54bbc87
child 10927 4a024118a421
Fix some more compiler warnings on armcc.
include/SDL_stdinc.h
src/audio/SDL_audiocvt.c
src/cpuinfo/SDL_cpuinfo.c
src/events/SDL_keyboard.c
src/joystick/SDL_gamecontroller.c
src/render/SDL_render.c
src/video/SDL_blit_A.c
src/video/SDL_bmp.c
     1.1 --- a/include/SDL_stdinc.h	Thu Mar 02 13:33:04 2017 -0500
     1.2 +++ b/include/SDL_stdinc.h	Fri Mar 03 16:38:17 2017 -0500
     1.3 @@ -127,11 +127,18 @@
     1.4   */
     1.5  /* @{ */
     1.6  
     1.7 +#ifdef __CC_ARM
     1.8 +/* ARM's compiler throws warnings if we use an enum: like "SDL_bool x = a < b;" */
     1.9 +#define SDL_FALSE 0
    1.10 +#define SDL_TRUE 1
    1.11 +typedef int SDL_bool;
    1.12 +#else
    1.13  typedef enum
    1.14  {
    1.15      SDL_FALSE = 0,
    1.16      SDL_TRUE = 1
    1.17  } SDL_bool;
    1.18 +#endif
    1.19  
    1.20  /**
    1.21   * \brief A signed 8-bit integer type.
     2.1 --- a/src/audio/SDL_audiocvt.c	Thu Mar 02 13:33:04 2017 -0500
     2.2 +++ b/src/audio/SDL_audiocvt.c	Fri Mar 03 16:38:17 2017 -0500
     2.3 @@ -1038,9 +1038,8 @@
     2.4      const Sint16 *inbuf = (const Sint16 *) _inbuf;
     2.5      Sint16 *outbuf = (Sint16 *) _outbuf;
     2.6      SDL_AudioStreamResamplerState *state = (SDL_AudioStreamResamplerState*)stream->resampler_state;
     2.7 -    const int chans = (int)stream->pre_resample_channels;
     2.8  
     2.9 -    SDL_assert(chans <= SDL_arraysize(state->resampler_state.si16));
    2.10 +    SDL_assert(((int)stream->pre_resample_channels) <= SDL_arraysize(state->resampler_state.si16));
    2.11  
    2.12      if (!state->resampler_seeded) {
    2.13          state->resampler_state.si16[0] = inbuf[0];
     3.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Mar 02 13:33:04 2017 -0500
     3.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Fri Mar 03 16:38:17 2017 -0500
     3.3 @@ -229,7 +229,7 @@
     3.4  }
     3.5  #else
     3.6  #define cpuid(func, a, b, c, d) \
     3.7 -    a = b = c = d = 0
     3.8 +    do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0)
     3.9  #endif
    3.10  
    3.11  static int CPU_CPUIDFeatures[4];
     4.1 --- a/src/events/SDL_keyboard.c	Thu Mar 02 13:33:04 2017 -0500
     4.2 +++ b/src/events/SDL_keyboard.c	Fri Mar 03 16:38:17 2017 -0500
     4.3 @@ -569,7 +569,7 @@
     4.4  #ifdef DEBUG_KEYBOARD
     4.5      printf("Resetting keyboard\n");
     4.6  #endif
     4.7 -    for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
     4.8 +    for (scancode = (SDL_Scancode) 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
     4.9          if (keyboard->keystate[scancode] == SDL_PRESSED) {
    4.10              SDL_SendKeyboardKey(SDL_RELEASED, scancode);
    4.11          }
    4.12 @@ -834,7 +834,7 @@
    4.13  {
    4.14      SDL_Keyboard *keyboard = &SDL_keyboard;
    4.15  
    4.16 -    return keyboard->modstate;
    4.17 +    return (SDL_Keymod) keyboard->modstate;
    4.18  }
    4.19  
    4.20  void
    4.21 @@ -863,7 +863,7 @@
    4.22  {
    4.23      SDL_Keyboard *keyboard = &SDL_keyboard;
    4.24  
    4.25 -    if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
    4.26 +    if (((int)scancode) < ((int)SDL_SCANCODE_UNKNOWN) || scancode >= SDL_NUM_SCANCODES) {
    4.27            SDL_InvalidParamError("scancode");
    4.28            return 0;
    4.29      }
    4.30 @@ -890,7 +890,7 @@
    4.31  SDL_GetScancodeName(SDL_Scancode scancode)
    4.32  {
    4.33      const char *name;
    4.34 -    if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
    4.35 +    if (((int)scancode) < ((int)SDL_SCANCODE_UNKNOWN) || scancode >= SDL_NUM_SCANCODES) {
    4.36            SDL_InvalidParamError("scancode");
    4.37            return "";
    4.38      }
     5.1 --- a/src/joystick/SDL_gamecontroller.c	Thu Mar 02 13:33:04 2017 -0500
     5.2 +++ b/src/joystick/SDL_gamecontroller.c	Fri Mar 03 16:38:17 2017 -0500
     5.3 @@ -382,7 +382,7 @@
     5.4  
     5.5      for (entry = 0; map_StringForControllerAxis[entry]; ++entry) {
     5.6          if (!SDL_strcasecmp(pchString, map_StringForControllerAxis[entry]))
     5.7 -            return entry;
     5.8 +            return (SDL_GameControllerAxis) entry;
     5.9      }
    5.10      return SDL_CONTROLLER_AXIS_INVALID;
    5.11  }
    5.12 @@ -428,7 +428,7 @@
    5.13  
    5.14      for (entry = 0; map_StringForControllerButton[entry]; ++entry) {
    5.15          if (SDL_strcasecmp(pchString, map_StringForControllerButton[entry]) == 0)
    5.16 -            return entry;
    5.17 +            return (SDL_GameControllerButton) entry;
    5.18      }
    5.19      return SDL_CONTROLLER_BUTTON_INVALID;
    5.20  }
    5.21 @@ -804,6 +804,8 @@
    5.22      SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
    5.23      ControllerMapping_t *mapping;
    5.24  
    5.25 +    (void) s_pEmscriptenMapping;  /* pacify ARMCC */
    5.26 +
    5.27      mapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
    5.28  #if SDL_JOYSTICK_XINPUT
    5.29      if (!mapping && SDL_SYS_IsXInputGamepad_DeviceIndex(device_index)) {
     6.1 --- a/src/render/SDL_render.c	Thu Mar 02 13:33:04 2017 -0500
     6.2 +++ b/src/render/SDL_render.c	Fri Mar 03 16:38:17 2017 -0500
     6.3 @@ -1938,7 +1938,7 @@
     6.4  
     6.5      /* Free existing textures for this renderer */
     6.6      while (renderer->textures) {
     6.7 -        SDL_Texture *tex = renderer->textures;
     6.8 +        SDL_Texture *tex = renderer->textures; (void) tex;
     6.9          SDL_DestroyTexture(renderer->textures);
    6.10          SDL_assert(tex != renderer->textures);  /* satisfy static analysis. */
    6.11      }
     7.1 --- a/src/video/SDL_blit_A.c	Thu Mar 02 13:33:04 2017 -0500
     7.2 +++ b/src/video/SDL_blit_A.c	Fri Mar 03 16:38:17 2017 -0500
     7.3 @@ -1317,9 +1317,9 @@
     7.4  
     7.5          case 3:
     7.6          default:
     7.7 -            return BlitNtoNPixelAlpha;
     7.8 +            break;
     7.9          }
    7.10 -        break;
    7.11 +        return BlitNtoNPixelAlpha;
    7.12  
    7.13      case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
    7.14          if (sf->Amask == 0) {
     8.1 --- a/src/video/SDL_bmp.c	Thu Mar 02 13:33:04 2017 -0500
     8.2 +++ b/src/video/SDL_bmp.c	Fri Mar 03 16:38:17 2017 -0500
     8.3 @@ -124,6 +124,9 @@
     8.4      Uint32 biClrUsed = 0;
     8.5      /* Uint32 biClrImportant = 0; */
     8.6  
     8.7 +    (void) haveRGBMasks;
     8.8 +    (void) haveAlphaMask;
     8.9 +
    8.10      /* Make sure we are passed a valid data source */
    8.11      surface = NULL;
    8.12      was_error = SDL_FALSE;