Fix compiler warnings in Native Client and Linux builds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
diff --git a/include/begin_code.h b/include/begin_code.h
index f37ee36..b058bf3 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 5487f2d..afa1df1 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 c314bf6..5b9c202 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 7f4c39e..b4ad596 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 36bf394..8303c61 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 <pthread.h>
#include <errno.h>
diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c
index d8902c6..6eaf20e 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 0f4c757..be899e2 100644
--- a/src/timer/unix/SDL_systimer.c
+++ b/src/timer/unix/SDL_systimer.c
@@ -28,6 +28,7 @@
#include <errno.h>
#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 31bd040..d3a9e81 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 aa5b2cf..2a6de10 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 9b1de56..046331e 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"