Fix compiler warnings in Native Client and Linux builds.
authorSam Clegg <sbc@chromium.org>
Fri, 20 Jun 2014 11:10:16 -0300
changeset 8879f6e4f24df1ac
parent 8878 f7ba2119fd91
child 8880 ee5117b56b93
Fix compiler warnings in Native Client and Linux builds.
include/begin_code.h
src/audio/SDL_wave.c
src/stdlib/SDL_iconv.c
src/test/SDL_test_harness.c
src/thread/pthread/SDL_sysmutex.c
src/thread/pthread/SDL_systhread.c
src/timer/unix/SDL_systimer.c
src/video/SDL_blit_A.c
src/video/SDL_video.c
src/video/nacl/SDL_naclwindow.c
     1.1 --- a/include/begin_code.h	Fri Jun 20 11:01:05 2014 -0300
     1.2 +++ b/include/begin_code.h	Fri Jun 20 11:10:16 2014 -0300
     1.3 @@ -41,6 +41,14 @@
     1.4  #  endif
     1.5  #endif
     1.6  
     1.7 +#ifndef SDL_UNUSED
     1.8 +#  ifdef __GNUC__
     1.9 +#    define SDL_UNUSED __attribute__((unused))
    1.10 +#  else
    1.11 +#    define SDL_UNUSED
    1.12 +#  endif
    1.13 +#endif
    1.14 +
    1.15  /* Some compilers use a special export keyword */
    1.16  #ifndef DECLSPEC
    1.17  # if defined(__WIN32__) || defined(__WINRT__)
     2.1 --- a/src/audio/SDL_wave.c	Fri Jun 20 11:01:05 2014 -0300
     2.2 +++ b/src/audio/SDL_wave.c	Fri Jun 20 11:10:16 2014 -0300
     2.3 @@ -121,7 +121,8 @@
     2.4      struct MS_ADPCM_decodestate *state[2];
     2.5      Uint8 *freeable, *encoded, *decoded;
     2.6      Sint32 encoded_len, samplesleft;
     2.7 -    Sint8 nybble, stereo;
     2.8 +    Sint8 nybble;
     2.9 +    Uint8 stereo;
    2.10      Sint16 *coeff[2];
    2.11      Sint32 new_sample;
    2.12  
    2.13 @@ -278,7 +279,8 @@
    2.14      } else if (state->index < 0) {
    2.15          state->index = 0;
    2.16      }
    2.17 -    step = step_table[state->index];
    2.18 +    /* explicit cast to avoid gcc warning about using 'char' as array index */
    2.19 +    step = step_table[(int)state->index];
    2.20      delta = step >> 3;
    2.21      if (nybble & 0x04)
    2.22          delta += step;
     3.1 --- a/src/stdlib/SDL_iconv.c	Fri Jun 20 11:01:05 2014 -0300
     3.2 +++ b/src/stdlib/SDL_iconv.c	Fri Jun 20 11:10:16 2014 -0300
     3.3 @@ -32,7 +32,8 @@
     3.4     If we get this wrong, it's just a warning, so no big deal.
     3.5  */
     3.6  #if defined(_XGP6) || defined(__APPLE__) || \
     3.7 -    (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)))
     3.8 +    (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
     3.9 +    (defined(_NEWLIB_VERSION)))
    3.10  #define ICONV_INBUF_NONCONST
    3.11  #endif
    3.12  
     4.1 --- a/src/test/SDL_test_harness.c	Fri Jun 20 11:01:05 2014 -0300
     4.2 +++ b/src/test/SDL_test_harness.c	Fri Jun 20 11:10:16 2014 -0300
     4.3 @@ -564,7 +564,7 @@
     4.4                              execKey = SDLTest_GenerateExecKey((char *)runSeed, testSuite->name, testCase->name, iterationCounter);
     4.5                          }
     4.6  
     4.7 -                        SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, (long long unsigned)execKey);
     4.8 +                        SDLTest_Log("Test Iteration %i: execKey %" PRIu64, iterationCounter, execKey);
     4.9                          testResult = SDLTest_RunTest(testSuite, testCase, execKey);
    4.10  
    4.11                          if (testResult == TEST_RESULT_PASSED) {
     5.1 --- a/src/thread/pthread/SDL_sysmutex.c	Fri Jun 20 11:01:05 2014 -0300
     5.2 +++ b/src/thread/pthread/SDL_sysmutex.c	Fri Jun 20 11:10:16 2014 -0300
     5.3 @@ -20,7 +20,9 @@
     5.4  */
     5.5  #include "../../SDL_internal.h"
     5.6  
     5.7 +#ifndef _GNU_SOURCE
     5.8  #define _GNU_SOURCE
     5.9 +#endif
    5.10  #include <pthread.h>
    5.11  #include <errno.h>
    5.12  
     6.1 --- a/src/thread/pthread/SDL_systhread.c	Fri Jun 20 11:01:05 2014 -0300
     6.2 +++ b/src/thread/pthread/SDL_systhread.c	Fri Jun 20 11:10:16 2014 -0300
     6.3 @@ -57,11 +57,13 @@
     6.4  
     6.5  #include "SDL_assert.h"
     6.6  
     6.7 +#ifndef __NACL__
     6.8  /* List of signals to mask in the subthreads */
     6.9  static const int sig_list[] = {
    6.10      SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
    6.11      SIGVTALRM, SIGPROF, 0
    6.12  };
    6.13 +#endif
    6.14  
    6.15  static void *
    6.16  RunThread(void *data)
    6.17 @@ -115,8 +117,10 @@
    6.18  void
    6.19  SDL_SYS_SetupThread(const char *name)
    6.20  {
    6.21 +#ifndef __NACL__
    6.22      int i;
    6.23      sigset_t mask;
    6.24 +#endif
    6.25  
    6.26      if (name != NULL) {
    6.27          #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
     7.1 --- a/src/timer/unix/SDL_systimer.c	Fri Jun 20 11:01:05 2014 -0300
     7.2 +++ b/src/timer/unix/SDL_systimer.c	Fri Jun 20 11:10:16 2014 -0300
     7.3 @@ -28,6 +28,7 @@
     7.4  #include <errno.h>
     7.5  
     7.6  #include "SDL_timer.h"
     7.7 +#include "SDL_assert.h"
     7.8  
     7.9  /* The clock_gettime provides monotonous time, so we should use it if
    7.10     it's available. The clock_gettime function is behind ifdef
    7.11 @@ -106,6 +107,9 @@
    7.12  #elif defined(__APPLE__)
    7.13          uint64_t now = mach_absolute_time();
    7.14          ticks = (((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000;
    7.15 +#else
    7.16 +        SDL_assert(SDL_FALSE);
    7.17 +        ticks = 0;
    7.18  #endif
    7.19      } else {
    7.20          struct timeval now;
    7.21 @@ -136,6 +140,9 @@
    7.22          ticks += now.tv_nsec;
    7.23  #elif defined(__APPLE__)
    7.24          ticks = mach_absolute_time();
    7.25 +#else
    7.26 +        SDL_assert(SDL_FALSE);
    7.27 +        ticks = 0;
    7.28  #endif
    7.29      } else {
    7.30          struct timeval now;
     8.1 --- a/src/video/SDL_blit_A.c	Fri Jun 20 11:01:05 2014 -0300
     8.2 +++ b/src/video/SDL_blit_A.c	Fri Jun 20 11:10:16 2014 -0300
     8.3 @@ -343,7 +343,7 @@
     8.4      mm_zero = _mm_setzero_si64();       /* 0 -> mm_zero */
     8.5      multmask = 0x00FF;
     8.6  	multmask <<= (ashift * 2);
     8.7 -	multmask2 = 0x00FF00FF00FF00FF;
     8.8 +	multmask2 = 0x00FF00FF00FF00FFULL;
     8.9  
    8.10      while (height--) {
    8.11  		/* *INDENT-OFF* */
    8.12 @@ -530,7 +530,7 @@
    8.13      mm_zero = _mm_setzero_si64();       /* 0 -> mm_zero */
    8.14      multmask = 0x00FF;
    8.15      multmask <<= (ashift * 2);
    8.16 -    multmask2 = 0x00FF00FF00FF00FF;
    8.17 +    multmask2 = 0x00FF00FF00FF00FFULL;
    8.18  
    8.19      while (height--) {
    8.20  	    /* *INDENT-OFF* */
     9.1 --- a/src/video/SDL_video.c	Fri Jun 20 11:01:05 2014 -0300
     9.2 +++ b/src/video/SDL_video.c	Fri Jun 20 11:10:16 2014 -0300
     9.3 @@ -3259,7 +3259,8 @@
     9.4  #include "x11/SDL_x11messagebox.h"
     9.5  #endif
     9.6  
     9.7 -static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
     9.8 +// This function will be unused if none of the above video drivers are present.
     9.9 +SDL_UNUSED static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
    9.10  {
    9.11      SDL_SysWMinfo info;
    9.12      SDL_Window *window = messageboxdata->window;
    10.1 --- a/src/video/nacl/SDL_naclwindow.c	Fri Jun 20 11:01:05 2014 -0300
    10.2 +++ b/src/video/nacl/SDL_naclwindow.c	Fri Jun 20 11:10:16 2014 -0300
    10.3 @@ -24,6 +24,8 @@
    10.4  
    10.5  #include "../SDL_sysvideo.h"
    10.6  
    10.7 +#include "../../events/SDL_mouse_c.h"
    10.8 +#include "../../events/SDL_keyboard_c.h"
    10.9  #include "SDL_naclvideo.h"
   10.10  #include "SDL_naclwindow.h"
   10.11