Fixed a bunch of compiler warnings.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 29 Aug 2017 15:52:49 -0400
changeset 114167e7d8a125d6a
parent 11415 41bc8b8e9758
child 11417 58a0bc85b216
Fixed a bunch of compiler warnings.
src/file/SDL_rwops.c
src/stdlib/SDL_qsort.c
src/test/SDL_test_harness.c
test/testatomic.c
test/testautomation_platform.c
test/testautomation_rwops.c
test/testautomation_sdltest.c
test/testrumble.c
     1.1 --- a/src/file/SDL_rwops.c	Tue Aug 29 09:02:04 2017 -0700
     1.2 +++ b/src/file/SDL_rwops.c	Tue Aug 29 15:52:49 2017 -0400
     1.3 @@ -686,7 +686,7 @@
     1.4  
     1.5      size_total = 0;
     1.6      for (;;) {
     1.7 -        if ((size_total + FILE_CHUNK_SIZE) > size) {
     1.8 +        if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) {
     1.9              size = (size_total + FILE_CHUNK_SIZE);
    1.10              newdata = SDL_realloc(data, (size_t)(size + 1));
    1.11              if (!newdata) {
     2.1 --- a/src/stdlib/SDL_qsort.c	Tue Aug 29 09:02:04 2017 -0700
     2.2 +++ b/src/stdlib/SDL_qsort.c	Tue Aug 29 15:52:49 2017 -0400
     2.3 @@ -362,7 +362,7 @@
     2.4  
     2.5  static char * pivot_big(char *first, char *mid, char *last, size_t size,
     2.6                          int compare(const void *, const void *)) {
     2.7 -  int d=(((last-first)/size)>>3)*size;
     2.8 +  size_t d=(((last-first)/size)>>3)*size;
     2.9  #ifdef DEBUG_QSORT
    2.10  fprintf(stderr, "pivot_big: first=%p last=%p size=%lu n=%lu\n", first, (unsigned long)last, size, (unsigned long)((last-first+1)/size));
    2.11  #endif
     3.1 --- a/src/test/SDL_test_harness.c	Tue Aug 29 09:02:04 2017 -0700
     3.2 +++ b/src/test/SDL_test_harness.c	Tue Aug 29 15:52:49 2017 -0400
     3.3 @@ -103,11 +103,11 @@
     3.4      SDLTest_Md5Context md5Context;
     3.5      Uint64 *keys;
     3.6      char iterationString[16];
     3.7 -    Uint32 runSeedLength;
     3.8 -    Uint32 suiteNameLength;
     3.9 -    Uint32 testNameLength;
    3.10 -    Uint32 iterationStringLength;
    3.11 -    Uint32 entireStringLength;
    3.12 +    size_t runSeedLength;
    3.13 +    size_t suiteNameLength;
    3.14 +    size_t testNameLength;
    3.15 +    size_t iterationStringLength;
    3.16 +    size_t entireStringLength;
    3.17      char *buffer;
    3.18  
    3.19      if (runSeed == NULL || runSeed[0] == '\0') {
    3.20 @@ -150,7 +150,7 @@
    3.21  
    3.22      /* Hash string and use half of the digest as 64bit exec key */
    3.23      SDLTest_Md5Init(&md5Context);
    3.24 -    SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, entireStringLength);
    3.25 +    SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, (unsigned int) entireStringLength);
    3.26      SDLTest_Md5Final(&md5Context);
    3.27      SDL_free(buffer);
    3.28      keys = (Uint64 *)md5Context.digest;
     4.1 --- a/test/testatomic.c	Tue Aug 29 09:02:04 2017 -0700
     4.2 +++ b/test/testatomic.c	Tue Aug 29 15:52:49 2017 -0400
     4.3 @@ -600,7 +600,7 @@
     4.4      int i, j;
     4.5      int grand_total;
     4.6      char textBuffer[1024];
     4.7 -    int len;
     4.8 +    size_t len;
     4.9  
    4.10      SDL_Log("\nFIFO test---------------------------------------\n\n");
    4.11      SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
     5.1 --- a/test/testautomation_platform.c	Tue Aug 29 09:02:04 2017 -0700
     5.2 +++ b/test/testautomation_platform.c	Tue Aug 29 15:52:49 2017 -0400
     5.3 @@ -112,7 +112,7 @@
     5.4     char *platform;
     5.5     char *revision;
     5.6     int ret;
     5.7 -   int len;
     5.8 +   size_t len;
     5.9  
    5.10     platform = (char *)SDL_GetPlatform();
    5.11     SDLTest_AssertPass("SDL_GetPlatform()");
    5.12 @@ -122,7 +122,7 @@
    5.13       SDLTest_AssertCheck(len > 0,
    5.14               "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
    5.15               platform,
    5.16 -             len);
    5.17 +             (int) len);
    5.18     }
    5.19  
    5.20     ret = SDL_GetCPUCount();
    5.21 @@ -282,7 +282,7 @@
    5.22     int result;
    5.23     const char *testError = "Testing";
    5.24     char *lastError;
    5.25 -   int len;
    5.26 +   size_t len;
    5.27  
    5.28     SDL_ClearError();
    5.29     SDLTest_AssertPass("SDL_ClearError()");
    5.30 @@ -295,7 +295,7 @@
    5.31     {
    5.32       len = SDL_strlen(lastError);
    5.33       SDLTest_AssertCheck(len == 0,
    5.34 -             "SDL_GetError(): no message expected, len: %i", len);
    5.35 +             "SDL_GetError(): no message expected, len: %i", (int) len);
    5.36     }
    5.37  
    5.38     result = SDL_SetError("%s", testError);
    5.39 @@ -310,7 +310,7 @@
    5.40       SDLTest_AssertCheck(len == SDL_strlen(testError),
    5.41               "SDL_GetError(): expected message len %i, was len: %i",
    5.42               (int) SDL_strlen(testError),
    5.43 -             len);
    5.44 +             (int) len);
    5.45       SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
    5.46               "SDL_GetError(): expected message %s, was message: %s",
    5.47               testError,
    5.48 @@ -334,7 +334,7 @@
    5.49     int result;
    5.50     const char *testError = "";
    5.51     char *lastError;
    5.52 -   int len;
    5.53 +   size_t len;
    5.54  
    5.55     result = SDL_SetError("%s", testError);
    5.56     SDLTest_AssertPass("SDL_SetError()");
    5.57 @@ -348,7 +348,7 @@
    5.58       SDLTest_AssertCheck(len == SDL_strlen(testError),
    5.59               "SDL_GetError(): expected message len %i, was len: %i",
    5.60               (int) SDL_strlen(testError),
    5.61 -             len);
    5.62 +             (int) len);
    5.63       SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
    5.64               "SDL_GetError(): expected message '%s', was message: '%s'",
    5.65               testError,
    5.66 @@ -373,7 +373,7 @@
    5.67     const char *invalidError = NULL;
    5.68     const char *probeError = "Testing";
    5.69     char *lastError;
    5.70 -   int len;
    5.71 +   size_t len;
    5.72  
    5.73     /* Reset */
    5.74     SDL_ClearError();
    5.75 @@ -391,7 +391,7 @@
    5.76       len = SDL_strlen(lastError);
    5.77       SDLTest_AssertCheck(len == 0,
    5.78               "SDL_GetError(): expected message len 0, was len: %i",
    5.79 -             len);
    5.80 +             (int) len);
    5.81     }
    5.82  
    5.83     /* Set */
    5.84 @@ -411,7 +411,7 @@
    5.85       len = SDL_strlen(lastError);
    5.86       SDLTest_AssertCheck(len == 0,
    5.87               "SDL_GetError(): expected message len 0, was len: %i",
    5.88 -             len);
    5.89 +             (int) len);
    5.90     }
    5.91  
    5.92     /* Reset */
    5.93 @@ -431,7 +431,7 @@
    5.94       SDLTest_AssertCheck(len == SDL_strlen(probeError),
    5.95               "SDL_GetError(): expected message len %i, was len: %i",
    5.96               (int) SDL_strlen(probeError),
    5.97 -             len);
    5.98 +             (int) len);
    5.99       SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0,
   5.100               "SDL_GetError(): expected message '%s', was message: '%s'",
   5.101               probeError,
     6.1 --- a/test/testautomation_rwops.c	Tue Aug 29 09:02:04 2017 -0700
     6.2 +++ b/test/testautomation_rwops.c	Tue Aug 29 15:52:49 2017 -0400
     6.3 @@ -32,9 +32,9 @@
     6.4  void
     6.5  RWopsSetUp(void *arg)
     6.6  {
     6.7 -    int fileLen;
     6.8 +    size_t fileLen;
     6.9      FILE *handle;
    6.10 -    int writtenLen;
    6.11 +    size_t writtenLen;
    6.12      int result;
    6.13  
    6.14      /* Clean up from previous runs (if any); ignore errors */
    6.15 @@ -49,8 +49,8 @@
    6.16  
    6.17      /* Write some known text into it */
    6.18      fileLen = SDL_strlen(RWopsHelloWorldTestString);
    6.19 -    writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
    6.20 -    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
    6.21 +    writtenLen = fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
    6.22 +    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen);
    6.23      result = fclose(handle);
    6.24      SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
    6.25  
    6.26 @@ -61,8 +61,8 @@
    6.27  
    6.28      /* Write alphabet text into it */
    6.29      fileLen = SDL_strlen(RWopsAlphabetString);
    6.30 -    writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle);
    6.31 -    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
    6.32 +    writtenLen = fwrite(RWopsAlphabetString, 1, fileLen, handle);
    6.33 +    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen);
    6.34      result = fclose(handle);
    6.35      SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
    6.36  
     7.1 --- a/test/testautomation_sdltest.c	Tue Aug 29 09:02:04 2017 -0700
     7.2 +++ b/test/testautomation_sdltest.c	Tue Aug 29 15:52:49 2017 -0400
     7.3 @@ -34,7 +34,7 @@
     7.4  sdltest_generateRunSeed(void *arg)
     7.5  {
     7.6    char* result;
     7.7 -  int i, l;
     7.8 +  size_t i, l;
     7.9    
    7.10    for (i = 1; i <= 10; i += 3) {   
    7.11       result = SDLTest_GenerateRunSeed((const int)i);
    7.12 @@ -42,7 +42,7 @@
    7.13       SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL");
    7.14       if (result != NULL) {
    7.15         l = SDL_strlen(result);
    7.16 -       SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", i, l);
    7.17 +       SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", (int) i, (int) l);
    7.18         SDL_free(result);
    7.19       }
    7.20    }
    7.21 @@ -1119,16 +1119,16 @@
    7.22  sdltest_randomAsciiString(void *arg)
    7.23  {
    7.24    char* result;
    7.25 -  int len;
    7.26 +  size_t len;
    7.27    int nonAsciiCharacters;
    7.28 -  int i;
    7.29 +  size_t i;
    7.30  
    7.31    result = SDLTest_RandomAsciiString();
    7.32    SDLTest_AssertPass("Call to SDLTest_RandomAsciiString()");
    7.33    SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
    7.34    if (result != NULL) {
    7.35       len = SDL_strlen(result);
    7.36 -     SDLTest_AssertCheck(len >= 0 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", len);
    7.37 +     SDLTest_AssertCheck(len >= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int) len);
    7.38       nonAsciiCharacters = 0;
    7.39       for (i=0; i<len; i++) {
    7.40         if (iscntrl(result[i])) {
    7.41 @@ -1155,10 +1155,10 @@
    7.42    const char* expectedError = "Parameter 'maxLength' is invalid";
    7.43    char* lastError;
    7.44    char* result;
    7.45 -  int targetLen;
    7.46 -  int len;
    7.47 +  size_t targetLen;
    7.48 +  size_t len;
    7.49    int nonAsciiCharacters;
    7.50 -  int i;
    7.51 +  size_t i;
    7.52  
    7.53    targetLen = 16 + SDLTest_RandomUint8();
    7.54    result = SDLTest_RandomAsciiStringWithMaximumLength(targetLen);
    7.55 @@ -1166,7 +1166,7 @@
    7.56    SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
    7.57    if (result != NULL) {
    7.58       len = SDL_strlen(result);
    7.59 -     SDLTest_AssertCheck(len >= 0 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", targetLen, len);
    7.60 +     SDLTest_AssertCheck(len >= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len);
    7.61       nonAsciiCharacters = 0;
    7.62       for (i=0; i<len; i++) {
    7.63         if (iscntrl(result[i])) {
    7.64 @@ -1208,10 +1208,10 @@
    7.65    const char* expectedError = "Parameter 'size' is invalid";
    7.66    char* lastError;
    7.67    char* result;
    7.68 -  int targetLen;
    7.69 -  int len;
    7.70 +  size_t targetLen;
    7.71 +  size_t len;
    7.72    int nonAsciiCharacters;
    7.73 -  int i;
    7.74 +  size_t i;
    7.75  
    7.76    /* Positive test */
    7.77    targetLen = 16 + SDLTest_RandomUint8();
    7.78 @@ -1220,7 +1220,7 @@
    7.79    SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
    7.80    if (result != NULL) {
    7.81       len = SDL_strlen(result);
    7.82 -     SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", targetLen, len);
    7.83 +     SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", (int) targetLen, (int) len);
    7.84       nonAsciiCharacters = 0;
    7.85       for (i=0; i<len; i++) {
    7.86         if (iscntrl(result[i])) {
     8.1 --- a/test/testrumble.c	Tue Aug 29 09:02:04 2017 -0700
     8.2 +++ b/test/testrumble.c	Tue Aug 29 15:52:49 2017 -0400
     8.3 @@ -54,6 +54,7 @@
     8.4      name = NULL;
     8.5      index = -1;
     8.6      if (argc > 1) {
     8.7 +        size_t l;
     8.8          name = argv[1];
     8.9          if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
    8.10              SDL_Log("USAGE: %s [device]\n"
    8.11 @@ -63,9 +64,9 @@
    8.12              return 0;
    8.13          }
    8.14  
    8.15 -        i = strlen(name);
    8.16 -        if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) {
    8.17 -            index = atoi(name);
    8.18 +        l = SDL_strlen(name);
    8.19 +        if ((l < 3) && SDL_isdigit(name[0]) && ((l == 1) || SDL_isdigit(name[1]))) {
    8.20 +            index = SDL_atoi(name);
    8.21              name = NULL;
    8.22          }
    8.23      }