Skip to content

Commit

Permalink
Fix compiler warnings in Native Client and Linux builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Jun 20, 2014
1 parent 6c5cb54 commit 7e52722
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 7 deletions.
8 changes: 8 additions & 0 deletions include/begin_code.h
Expand Up @@ -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__)
Expand Down
6 changes: 4 additions & 2 deletions src/audio/SDL_wave.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/stdlib/SDL_iconv.c
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/SDL_test_harness.c
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/thread/pthread/SDL_sysmutex.c
Expand Up @@ -20,7 +20,9 @@
*/
#include "../../SDL_internal.h"

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <pthread.h>
#include <errno.h>

Expand Down
4 changes: 4 additions & 0 deletions src/thread/pthread/SDL_systhread.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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__)
Expand Down
7 changes: 7 additions & 0 deletions src/timer/unix/SDL_systimer.c
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/video/SDL_blit_A.c
Expand Up @@ -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* */
Expand Down Expand Up @@ -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* */
Expand Down
3 changes: 2 additions & 1 deletion src/video/SDL_video.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/video/nacl/SDL_naclwindow.c
Expand Up @@ -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"

Expand Down

0 comments on commit 7e52722

Please sign in to comment.