Fixed more compiler warnings.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 23 Nov 2016 11:49:26 -0500
changeset 10643930938c7ca82
parent 10642 8a420b80310a
child 10644 594c17c446f6
Fixed more compiler warnings.
src/SDL_error.c
src/render/opengles2/SDL_gles2funcs.h
src/test/SDL_test_common.c
src/test/SDL_test_harness.c
src/test/SDL_test_log.c
     1.1 --- a/src/SDL_error.c	Wed Nov 23 10:51:44 2016 -0500
     1.2 +++ b/src/SDL_error.c	Wed Nov 23 11:49:26 2016 -0500
     1.3 @@ -116,8 +116,68 @@
     1.4      return -1;
     1.5  }
     1.6  
     1.7 +static char *SDL_GetErrorMsg(char *errstr, int maxlen);
     1.8 +
     1.9 +/* Available for backwards compatibility */
    1.10 +const char *
    1.11 +SDL_GetError(void)
    1.12 +{
    1.13 +    static char errmsg[SDL_ERRBUFIZE];
    1.14 +
    1.15 +    return SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE);
    1.16 +}
    1.17 +
    1.18 +void
    1.19 +SDL_ClearError(void)
    1.20 +{
    1.21 +    SDL_error *error;
    1.22 +
    1.23 +    error = SDL_GetErrBuf();
    1.24 +    error->error = 0;
    1.25 +}
    1.26 +
    1.27 +/* Very common errors go here */
    1.28 +int
    1.29 +SDL_Error(SDL_errorcode code)
    1.30 +{
    1.31 +    switch (code) {
    1.32 +    case SDL_ENOMEM:
    1.33 +        return SDL_SetError("Out of memory");
    1.34 +    case SDL_EFREAD:
    1.35 +        return SDL_SetError("Error reading from datastream");
    1.36 +    case SDL_EFWRITE:
    1.37 +        return SDL_SetError("Error writing to datastream");
    1.38 +    case SDL_EFSEEK:
    1.39 +        return SDL_SetError("Error seeking in datastream");
    1.40 +    case SDL_UNSUPPORTED:
    1.41 +        return SDL_SetError("That operation is not supported");
    1.42 +    default:
    1.43 +        return SDL_SetError("Unknown SDL error");
    1.44 +    }
    1.45 +}
    1.46 +
    1.47 +#ifdef TEST_ERROR
    1.48 +int
    1.49 +main(int argc, char *argv[])
    1.50 +{
    1.51 +    char buffer[BUFSIZ + 1];
    1.52 +
    1.53 +    SDL_SetError("Hi there!");
    1.54 +    printf("Error 1: %s\n", SDL_GetError());
    1.55 +    SDL_ClearError();
    1.56 +    SDL_memset(buffer, '1', BUFSIZ);
    1.57 +    buffer[BUFSIZ] = 0;
    1.58 +    SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
    1.59 +    printf("Error 2: %s\n", SDL_GetError());
    1.60 +    exit(0);
    1.61 +}
    1.62 +#endif
    1.63 +
    1.64 +
    1.65 +/* keep this at the end of the file so it works with GCC builds that don't
    1.66 +   support "#pragma GCC diagnostic push" ... we'll just leave the warning
    1.67 +   disabled after this. */
    1.68  #ifdef __GNUC__
    1.69 -#pragma GCC diagnostic push
    1.70  #pragma GCC diagnostic ignored "-Wformat-nonliteral"
    1.71  #endif
    1.72  /* This function has a bit more overhead than most error functions
    1.73 @@ -220,63 +280,5 @@
    1.74      }
    1.75      return (errstr);
    1.76  }
    1.77 -#ifdef __GNUC__
    1.78 -#pragma GCC diagnostic pop
    1.79 -#endif
    1.80 -
    1.81 -/* Available for backwards compatibility */
    1.82 -const char *
    1.83 -SDL_GetError(void)
    1.84 -{
    1.85 -    static char errmsg[SDL_ERRBUFIZE];
    1.86 -
    1.87 -    return SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE);
    1.88 -}
    1.89 -
    1.90 -void
    1.91 -SDL_ClearError(void)
    1.92 -{
    1.93 -    SDL_error *error;
    1.94 -
    1.95 -    error = SDL_GetErrBuf();
    1.96 -    error->error = 0;
    1.97 -}
    1.98 -
    1.99 -/* Very common errors go here */
   1.100 -int
   1.101 -SDL_Error(SDL_errorcode code)
   1.102 -{
   1.103 -    switch (code) {
   1.104 -    case SDL_ENOMEM:
   1.105 -        return SDL_SetError("Out of memory");
   1.106 -    case SDL_EFREAD:
   1.107 -        return SDL_SetError("Error reading from datastream");
   1.108 -    case SDL_EFWRITE:
   1.109 -        return SDL_SetError("Error writing to datastream");
   1.110 -    case SDL_EFSEEK:
   1.111 -        return SDL_SetError("Error seeking in datastream");
   1.112 -    case SDL_UNSUPPORTED:
   1.113 -        return SDL_SetError("That operation is not supported");
   1.114 -    default:
   1.115 -        return SDL_SetError("Unknown SDL error");
   1.116 -    }
   1.117 -}
   1.118 -
   1.119 -#ifdef TEST_ERROR
   1.120 -int
   1.121 -main(int argc, char *argv[])
   1.122 -{
   1.123 -    char buffer[BUFSIZ + 1];
   1.124 -
   1.125 -    SDL_SetError("Hi there!");
   1.126 -    printf("Error 1: %s\n", SDL_GetError());
   1.127 -    SDL_ClearError();
   1.128 -    SDL_memset(buffer, '1', BUFSIZ);
   1.129 -    buffer[BUFSIZ] = 0;
   1.130 -    SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
   1.131 -    printf("Error 2: %s\n", SDL_GetError());
   1.132 -    exit(0);
   1.133 -}
   1.134 -#endif
   1.135  
   1.136  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/render/opengles2/SDL_gles2funcs.h	Wed Nov 23 10:51:44 2016 -0500
     2.2 +++ b/src/render/opengles2/SDL_gles2funcs.h	Wed Nov 23 11:49:26 2016 -0500
     2.3 @@ -53,7 +53,11 @@
     2.4  SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
     2.5  SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
     2.6  SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
     2.7 +#if __NACL__ || __ANDROID__
     2.8 +SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *))
     2.9 +#else
    2.10  SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
    2.11 +#endif
    2.12  SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
    2.13  SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
    2.14  SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
     3.1 --- a/src/test/SDL_test_common.c	Wed Nov 23 10:51:44 2016 -0500
     3.2 +++ b/src/test/SDL_test_common.c	Wed Nov 23 11:49:26 2016 -0500
     3.3 @@ -1210,10 +1210,10 @@
     3.4                  event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure);
     3.5          break;
     3.6      case SDL_DOLLARGESTURE:
     3.7 -        SDL_Log("SDL_EVENT: Dollar gesture detect: %"SDL_PRIs64, (Sint64) event->dgesture.gestureId);
     3.8 +        SDL_Log("SDL_EVENT: Dollar gesture detect: %lld", (long long) event->dgesture.gestureId);
     3.9          break;
    3.10      case SDL_DOLLARRECORD:
    3.11 -        SDL_Log("SDL_EVENT: Dollar gesture record: %"SDL_PRIs64, (Sint64) event->dgesture.gestureId);
    3.12 +        SDL_Log("SDL_EVENT: Dollar gesture record: %lld", (long long) event->dgesture.gestureId);
    3.13          break;
    3.14      case SDL_MULTIGESTURE:
    3.15          SDL_Log("SDL_EVENT: Multi gesture fingers: %d", event->mgesture.numFingers);
     4.1 --- a/src/test/SDL_test_harness.c	Wed Nov 23 10:51:44 2016 -0500
     4.2 +++ b/src/test/SDL_test_harness.c	Wed Nov 23 11:49:26 2016 -0500
     4.3 @@ -485,7 +485,7 @@
     4.4          if (suiteFilter == 0 && testFilter == 0) {
     4.5              SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter);
     4.6              SDLTest_Log("Exit code: 2");
     4.7 -            SDL_free(failedTests);
     4.8 +            SDL_free((void *) failedTests);
     4.9              return 2;
    4.10          }
    4.11      }
    4.12 @@ -671,7 +671,7 @@
    4.13            SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name);
    4.14          }
    4.15      }
    4.16 -    SDL_free(failedTests);
    4.17 +    SDL_free((void *) failedTests);
    4.18  
    4.19      SDLTest_Log("Exit code: %d", runResult);
    4.20      return runResult;
     5.1 --- a/src/test/SDL_test_log.c	Wed Nov 23 10:51:44 2016 -0500
     5.2 +++ b/src/test/SDL_test_log.c	Wed Nov 23 11:49:26 2016 -0500
     5.3 @@ -41,6 +41,19 @@
     5.4  
     5.5  #include "SDL_test.h"
     5.6  
     5.7 +/* work around compiler warning on older GCCs. */
     5.8 +#if (defined(__GNUC__) && (__GNUC__ <= 2))
     5.9 +static size_t
    5.10 +strftime_gcc2_workaround(char *s, size_t max, const char *fmt, const struct tm *tm)
    5.11 +{
    5.12 +    return strftime(s, max, fmt, tm);
    5.13 +}
    5.14 +#ifdef strftime
    5.15 +#undef strftime
    5.16 +#endif
    5.17 +#define strftime strftime_gcc2_workaround
    5.18 +#endif
    5.19 +
    5.20  /* !
    5.21   * Converts unix timestamp to its ascii representation in localtime
    5.22   *