Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some more compiler warnings on armcc.
  • Loading branch information
icculus committed Mar 3, 2017
1 parent d526b8a commit ca0bf15
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
7 changes: 7 additions & 0 deletions include/SDL_stdinc.h
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions src/audio/SDL_audiocvt.c
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/cpuinfo/SDL_cpuinfo.c
Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions src/events/SDL_keyboard.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -834,7 +834,7 @@ SDL_GetModState(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;

return keyboard->modstate;
return (SDL_Keymod) keyboard->modstate;
}

void
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 "";
}
Expand Down
6 changes: 4 additions & 2 deletions src/joystick/SDL_gamecontroller.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/SDL_render.c
Expand Up @@ -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. */
}
Expand Down
4 changes: 2 additions & 2 deletions src/video/SDL_blit_A.c
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/video/SDL_bmp.c
Expand Up @@ -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;
Expand Down

0 comments on commit ca0bf15

Please sign in to comment.