mirror of https://github.com/encounter/SDL.git
Fixed more compiler warnings.
This commit is contained in:
parent
52827361ae
commit
40c2a6fb55
120
src/SDL_error.c
120
src/SDL_error.c
|
@ -116,8 +116,68 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *SDL_GetErrorMsg(char *errstr, int maxlen);
|
||||||
|
|
||||||
|
/* Available for backwards compatibility */
|
||||||
|
const char *
|
||||||
|
SDL_GetError(void)
|
||||||
|
{
|
||||||
|
static char errmsg[SDL_ERRBUFIZE];
|
||||||
|
|
||||||
|
return SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SDL_ClearError(void)
|
||||||
|
{
|
||||||
|
SDL_error *error;
|
||||||
|
|
||||||
|
error = SDL_GetErrBuf();
|
||||||
|
error->error = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Very common errors go here */
|
||||||
|
int
|
||||||
|
SDL_Error(SDL_errorcode code)
|
||||||
|
{
|
||||||
|
switch (code) {
|
||||||
|
case SDL_ENOMEM:
|
||||||
|
return SDL_SetError("Out of memory");
|
||||||
|
case SDL_EFREAD:
|
||||||
|
return SDL_SetError("Error reading from datastream");
|
||||||
|
case SDL_EFWRITE:
|
||||||
|
return SDL_SetError("Error writing to datastream");
|
||||||
|
case SDL_EFSEEK:
|
||||||
|
return SDL_SetError("Error seeking in datastream");
|
||||||
|
case SDL_UNSUPPORTED:
|
||||||
|
return SDL_SetError("That operation is not supported");
|
||||||
|
default:
|
||||||
|
return SDL_SetError("Unknown SDL error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TEST_ERROR
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char buffer[BUFSIZ + 1];
|
||||||
|
|
||||||
|
SDL_SetError("Hi there!");
|
||||||
|
printf("Error 1: %s\n", SDL_GetError());
|
||||||
|
SDL_ClearError();
|
||||||
|
SDL_memset(buffer, '1', BUFSIZ);
|
||||||
|
buffer[BUFSIZ] = 0;
|
||||||
|
SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
|
||||||
|
printf("Error 2: %s\n", SDL_GetError());
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* keep this at the end of the file so it works with GCC builds that don't
|
||||||
|
support "#pragma GCC diagnostic push" ... we'll just leave the warning
|
||||||
|
disabled after this. */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||||
#endif
|
#endif
|
||||||
/* This function has a bit more overhead than most error functions
|
/* This function has a bit more overhead than most error functions
|
||||||
|
@ -220,63 +280,5 @@ SDL_GetErrorMsg(char *errstr, int maxlen)
|
||||||
}
|
}
|
||||||
return (errstr);
|
return (errstr);
|
||||||
}
|
}
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Available for backwards compatibility */
|
|
||||||
const char *
|
|
||||||
SDL_GetError(void)
|
|
||||||
{
|
|
||||||
static char errmsg[SDL_ERRBUFIZE];
|
|
||||||
|
|
||||||
return SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SDL_ClearError(void)
|
|
||||||
{
|
|
||||||
SDL_error *error;
|
|
||||||
|
|
||||||
error = SDL_GetErrBuf();
|
|
||||||
error->error = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Very common errors go here */
|
|
||||||
int
|
|
||||||
SDL_Error(SDL_errorcode code)
|
|
||||||
{
|
|
||||||
switch (code) {
|
|
||||||
case SDL_ENOMEM:
|
|
||||||
return SDL_SetError("Out of memory");
|
|
||||||
case SDL_EFREAD:
|
|
||||||
return SDL_SetError("Error reading from datastream");
|
|
||||||
case SDL_EFWRITE:
|
|
||||||
return SDL_SetError("Error writing to datastream");
|
|
||||||
case SDL_EFSEEK:
|
|
||||||
return SDL_SetError("Error seeking in datastream");
|
|
||||||
case SDL_UNSUPPORTED:
|
|
||||||
return SDL_SetError("That operation is not supported");
|
|
||||||
default:
|
|
||||||
return SDL_SetError("Unknown SDL error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TEST_ERROR
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
char buffer[BUFSIZ + 1];
|
|
||||||
|
|
||||||
SDL_SetError("Hi there!");
|
|
||||||
printf("Error 1: %s\n", SDL_GetError());
|
|
||||||
SDL_ClearError();
|
|
||||||
SDL_memset(buffer, '1', BUFSIZ);
|
|
||||||
buffer[BUFSIZ] = 0;
|
|
||||||
SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
|
|
||||||
printf("Error 2: %s\n", SDL_GetError());
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -53,7 +53,11 @@ SDL_PROC(void, glPixelStorei, (GLenum, GLint))
|
||||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
||||||
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
||||||
SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
|
SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
|
||||||
|
#if __NACL__ || __ANDROID__
|
||||||
|
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *))
|
||||||
|
#else
|
||||||
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
|
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
|
||||||
|
#endif
|
||||||
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
|
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
|
||||||
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
|
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
|
||||||
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
|
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
|
||||||
|
|
|
@ -1210,10 +1210,10 @@ SDLTest_PrintEvent(SDL_Event * event)
|
||||||
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure);
|
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure);
|
||||||
break;
|
break;
|
||||||
case SDL_DOLLARGESTURE:
|
case SDL_DOLLARGESTURE:
|
||||||
SDL_Log("SDL_EVENT: Dollar gesture detect: %"SDL_PRIs64, (Sint64) event->dgesture.gestureId);
|
SDL_Log("SDL_EVENT: Dollar gesture detect: %lld", (long long) event->dgesture.gestureId);
|
||||||
break;
|
break;
|
||||||
case SDL_DOLLARRECORD:
|
case SDL_DOLLARRECORD:
|
||||||
SDL_Log("SDL_EVENT: Dollar gesture record: %"SDL_PRIs64, (Sint64) event->dgesture.gestureId);
|
SDL_Log("SDL_EVENT: Dollar gesture record: %lld", (long long) event->dgesture.gestureId);
|
||||||
break;
|
break;
|
||||||
case SDL_MULTIGESTURE:
|
case SDL_MULTIGESTURE:
|
||||||
SDL_Log("SDL_EVENT: Multi gesture fingers: %d", event->mgesture.numFingers);
|
SDL_Log("SDL_EVENT: Multi gesture fingers: %d", event->mgesture.numFingers);
|
||||||
|
|
|
@ -485,7 +485,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||||
if (suiteFilter == 0 && testFilter == 0) {
|
if (suiteFilter == 0 && testFilter == 0) {
|
||||||
SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter);
|
SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter);
|
||||||
SDLTest_Log("Exit code: 2");
|
SDLTest_Log("Exit code: 2");
|
||||||
SDL_free(failedTests);
|
SDL_free((void *) failedTests);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +671,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||||
SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name);
|
SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_free(failedTests);
|
SDL_free((void *) failedTests);
|
||||||
|
|
||||||
SDLTest_Log("Exit code: %d", runResult);
|
SDLTest_Log("Exit code: %d", runResult);
|
||||||
return runResult;
|
return runResult;
|
||||||
|
|
|
@ -41,6 +41,19 @@
|
||||||
|
|
||||||
#include "SDL_test.h"
|
#include "SDL_test.h"
|
||||||
|
|
||||||
|
/* work around compiler warning on older GCCs. */
|
||||||
|
#if (defined(__GNUC__) && (__GNUC__ <= 2))
|
||||||
|
static size_t
|
||||||
|
strftime_gcc2_workaround(char *s, size_t max, const char *fmt, const struct tm *tm)
|
||||||
|
{
|
||||||
|
return strftime(s, max, fmt, tm);
|
||||||
|
}
|
||||||
|
#ifdef strftime
|
||||||
|
#undef strftime
|
||||||
|
#endif
|
||||||
|
#define strftime strftime_gcc2_workaround
|
||||||
|
#endif
|
||||||
|
|
||||||
/* !
|
/* !
|
||||||
* Converts unix timestamp to its ascii representation in localtime
|
* Converts unix timestamp to its ascii representation in localtime
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue