From ca0bf151d54d36b6282e22ff05f228c84aae98da Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 3 Mar 2017 16:38:17 -0500 Subject: [PATCH] Fix some more compiler warnings on armcc. --- include/SDL_stdinc.h | 7 +++++++ src/audio/SDL_audiocvt.c | 3 +-- src/cpuinfo/SDL_cpuinfo.c | 2 +- src/events/SDL_keyboard.c | 8 ++++---- src/joystick/SDL_gamecontroller.c | 6 ++++-- src/render/SDL_render.c | 2 +- src/video/SDL_blit_A.c | 4 ++-- src/video/SDL_bmp.c | 3 +++ 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index ff42cf7570272..0a2e06710ae65 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -127,11 +127,18 @@ */ /* @{ */ +#ifdef __CC_ARM +/* ARM's compiler throws warnings if we use an enum: like "SDL_bool x = a < b;" */ +#define SDL_FALSE 0 +#define SDL_TRUE 1 +typedef int SDL_bool; +#else typedef enum { SDL_FALSE = 0, SDL_TRUE = 1 } SDL_bool; +#endif /** * \brief A signed 8-bit integer type. diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 41ad345812c62..aa4501f680a5e 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -1038,9 +1038,8 @@ SDL_ResampleAudioStream_si16_c2(SDL_AudioStream *stream, const void *_inbuf, con const Sint16 *inbuf = (const Sint16 *) _inbuf; Sint16 *outbuf = (Sint16 *) _outbuf; SDL_AudioStreamResamplerState *state = (SDL_AudioStreamResamplerState*)stream->resampler_state; - const int chans = (int)stream->pre_resample_channels; - SDL_assert(chans <= SDL_arraysize(state->resampler_state.si16)); + SDL_assert(((int)stream->pre_resample_channels) <= SDL_arraysize(state->resampler_state.si16)); if (!state->resampler_seeded) { state->resampler_state.si16[0] = inbuf[0]; diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index f2e263f4f0977..5d1b13ff15445 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -229,7 +229,7 @@ CPU_haveCPUID(void) } #else #define cpuid(func, a, b, c, d) \ - a = b = c = d = 0 + do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0) #endif static int CPU_CPUIDFeatures[4]; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index f7e9ddfabde7d..3aaee13507849 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -569,7 +569,7 @@ SDL_ResetKeyboard(void) #ifdef DEBUG_KEYBOARD printf("Resetting keyboard\n"); #endif - for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { + for (scancode = (SDL_Scancode) 0; scancode < SDL_NUM_SCANCODES; ++scancode) { if (keyboard->keystate[scancode] == SDL_PRESSED) { SDL_SendKeyboardKey(SDL_RELEASED, scancode); } @@ -834,7 +834,7 @@ SDL_GetModState(void) { SDL_Keyboard *keyboard = &SDL_keyboard; - return keyboard->modstate; + return (SDL_Keymod) keyboard->modstate; } void @@ -863,7 +863,7 @@ SDL_GetKeyFromScancode(SDL_Scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; - if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { + if (((int)scancode) < ((int)SDL_SCANCODE_UNKNOWN) || scancode >= SDL_NUM_SCANCODES) { SDL_InvalidParamError("scancode"); return 0; } @@ -890,7 +890,7 @@ const char * SDL_GetScancodeName(SDL_Scancode scancode) { const char *name; - if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { + if (((int)scancode) < ((int)SDL_SCANCODE_UNKNOWN) || scancode >= SDL_NUM_SCANCODES) { SDL_InvalidParamError("scancode"); return ""; } diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 80baa05e9c6ca..172f3d0f62268 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -382,7 +382,7 @@ SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(const char *pchString for (entry = 0; map_StringForControllerAxis[entry]; ++entry) { if (!SDL_strcasecmp(pchString, map_StringForControllerAxis[entry])) - return entry; + return (SDL_GameControllerAxis) entry; } return SDL_CONTROLLER_AXIS_INVALID; } @@ -428,7 +428,7 @@ SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchSt for (entry = 0; map_StringForControllerButton[entry]; ++entry) { if (SDL_strcasecmp(pchString, map_StringForControllerButton[entry]) == 0) - return entry; + return (SDL_GameControllerButton) entry; } return SDL_CONTROLLER_BUTTON_INVALID; } @@ -804,6 +804,8 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index); ControllerMapping_t *mapping; + (void) s_pEmscriptenMapping; /* pacify ARMCC */ + mapping = SDL_PrivateGetControllerMappingForGUID(&jGUID); #if SDL_JOYSTICK_XINPUT if (!mapping && SDL_SYS_IsXInputGamepad_DeviceIndex(device_index)) { diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index d31f729775794..7cc1324e1fa84 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1938,7 +1938,7 @@ SDL_DestroyRenderer(SDL_Renderer * renderer) /* Free existing textures for this renderer */ while (renderer->textures) { - SDL_Texture *tex = renderer->textures; + SDL_Texture *tex = renderer->textures; (void) tex; SDL_DestroyTexture(renderer->textures); SDL_assert(tex != renderer->textures); /* satisfy static analysis. */ } diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 5e6f9305ffb4f..e90604e670216 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -1317,9 +1317,9 @@ SDL_CalculateBlitA(SDL_Surface * surface) case 3: default: - return BlitNtoNPixelAlpha; + break; } - break; + return BlitNtoNPixelAlpha; case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: if (sf->Amask == 0) { diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 14f57d3de744c..1e77b98350f7f 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -124,6 +124,9 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) Uint32 biClrUsed = 0; /* Uint32 biClrImportant = 0; */ + (void) haveRGBMasks; + (void) haveAlphaMask; + /* Make sure we are passed a valid data source */ surface = NULL; was_error = SDL_FALSE;