From 7e52722dfd03ab3fb706c983fb0d7ea1e3984e66 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 20 Jun 2014 11:10:16 -0300 Subject: [PATCH] Fix compiler warnings in Native Client and Linux builds. --- include/begin_code.h | 8 ++++++++ src/audio/SDL_wave.c | 6 ++++-- src/stdlib/SDL_iconv.c | 3 ++- src/test/SDL_test_harness.c | 2 +- src/thread/pthread/SDL_sysmutex.c | 2 ++ src/thread/pthread/SDL_systhread.c | 4 ++++ src/timer/unix/SDL_systimer.c | 7 +++++++ src/video/SDL_blit_A.c | 4 ++-- src/video/SDL_video.c | 3 ++- src/video/nacl/SDL_naclwindow.c | 2 ++ 10 files changed, 34 insertions(+), 7 deletions(-) diff --git a/include/begin_code.h b/include/begin_code.h index f37ee3696ebfe..b058bf369ec06 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -41,6 +41,14 @@ # endif #endif +#ifndef SDL_UNUSED +# ifdef __GNUC__ +# define SDL_UNUSED __attribute__((unused)) +# else +# define SDL_UNUSED +# endif +#endif + /* Some compilers use a special export keyword */ #ifndef DECLSPEC # if defined(__WIN32__) || defined(__WINRT__) diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 5487f2d72cb61..afa1df13a4d0f 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -121,7 +121,8 @@ MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len) struct MS_ADPCM_decodestate *state[2]; Uint8 *freeable, *encoded, *decoded; Sint32 encoded_len, samplesleft; - Sint8 nybble, stereo; + Sint8 nybble; + Uint8 stereo; Sint16 *coeff[2]; Sint32 new_sample; @@ -278,7 +279,8 @@ IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble) } else if (state->index < 0) { state->index = 0; } - step = step_table[state->index]; + /* explicit cast to avoid gcc warning about using 'char' as array index */ + step = step_table[(int)state->index]; delta = step >> 3; if (nybble & 0x04) delta += step; diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index c314bf6821f36..5b9c20233a07a 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -32,7 +32,8 @@ If we get this wrong, it's just a warning, so no big deal. */ #if defined(_XGP6) || defined(__APPLE__) || \ - (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))) + (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \ + (defined(_NEWLIB_VERSION))) #define ICONV_INBUF_NONCONST #endif diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index 7f4c39e38c33f..b4ad59634d2cb 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -564,7 +564,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user execKey = SDLTest_GenerateExecKey((char *)runSeed, testSuite->name, testCase->name, iterationCounter); } - SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, (long long unsigned)execKey); + SDLTest_Log("Test Iteration %i: execKey %" PRIu64, iterationCounter, execKey); testResult = SDLTest_RunTest(testSuite, testCase, execKey); if (testResult == TEST_RESULT_PASSED) { diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c index 36bf394cb7130..8303c61924070 100644 --- a/src/thread/pthread/SDL_sysmutex.c +++ b/src/thread/pthread/SDL_sysmutex.c @@ -20,7 +20,9 @@ */ #include "../../SDL_internal.h" +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index d8902c682c242..6eaf20ead6fd2 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -57,11 +57,13 @@ #include "SDL_assert.h" +#ifndef __NACL__ /* List of signals to mask in the subthreads */ static const int sig_list[] = { SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, SIGVTALRM, SIGPROF, 0 }; +#endif static void * RunThread(void *data) @@ -115,8 +117,10 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) void SDL_SYS_SetupThread(const char *name) { +#ifndef __NACL__ int i; sigset_t mask; +#endif if (name != NULL) { #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__) diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 0f4c7571e1a05..be899e2a4425c 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -28,6 +28,7 @@ #include #include "SDL_timer.h" +#include "SDL_assert.h" /* The clock_gettime provides monotonous time, so we should use it if it's available. The clock_gettime function is behind ifdef @@ -106,6 +107,9 @@ SDL_GetTicks(void) #elif defined(__APPLE__) uint64_t now = mach_absolute_time(); ticks = (((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000; +#else + SDL_assert(SDL_FALSE); + ticks = 0; #endif } else { struct timeval now; @@ -136,6 +140,9 @@ SDL_GetPerformanceCounter(void) ticks += now.tv_nsec; #elif defined(__APPLE__) ticks = mach_absolute_time(); +#else + SDL_assert(SDL_FALSE); + ticks = 0; #endif } else { struct timeval now; diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 31bd0401e0143..d3a9e81481929 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -343,7 +343,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ multmask = 0x00FF; multmask <<= (ashift * 2); - multmask2 = 0x00FF00FF00FF00FF; + multmask2 = 0x00FF00FF00FF00FFULL; while (height--) { /* *INDENT-OFF* */ @@ -530,7 +530,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ multmask = 0x00FF; multmask <<= (ashift * 2); - multmask2 = 0x00FF00FF00FF00FF; + multmask2 = 0x00FF00FF00FF00FFULL; while (height--) { /* *INDENT-OFF* */ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index aa5b2cf454b5d..2a6de10d67a58 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -3259,7 +3259,8 @@ SDL_IsScreenKeyboardShown(SDL_Window *window) #include "x11/SDL_x11messagebox.h" #endif -static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype) +// This function will be unused if none of the above video drivers are present. +SDL_UNUSED static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype) { SDL_SysWMinfo info; SDL_Window *window = messageboxdata->window; diff --git a/src/video/nacl/SDL_naclwindow.c b/src/video/nacl/SDL_naclwindow.c index 9b1de565401d5..046331e033704 100644 --- a/src/video/nacl/SDL_naclwindow.c +++ b/src/video/nacl/SDL_naclwindow.c @@ -24,6 +24,8 @@ #include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" #include "SDL_naclvideo.h" #include "SDL_naclwindow.h"