mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-10-26 12:27:44 +00:00 
			
		
		
		
	Fixed a bunch of compiler warnings.
This commit is contained in:
		| @@ -686,7 +686,7 @@ SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, int freesrc) | |||||||
|  |  | ||||||
|     size_total = 0; |     size_total = 0; | ||||||
|     for (;;) { |     for (;;) { | ||||||
|         if ((size_total + FILE_CHUNK_SIZE) > size) { |         if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) { | ||||||
|             size = (size_total + FILE_CHUNK_SIZE); |             size = (size_total + FILE_CHUNK_SIZE); | ||||||
|             newdata = SDL_realloc(data, (size_t)(size + 1)); |             newdata = SDL_realloc(data, (size_t)(size + 1)); | ||||||
|             if (!newdata) { |             if (!newdata) { | ||||||
|   | |||||||
| @@ -362,7 +362,7 @@ typedef struct { char * first; char * last; } stack_entry; | |||||||
|  |  | ||||||
| static char * pivot_big(char *first, char *mid, char *last, size_t size, | static char * pivot_big(char *first, char *mid, char *last, size_t size, | ||||||
|                         int compare(const void *, const void *)) { |                         int compare(const void *, const void *)) { | ||||||
|   int d=(((last-first)/size)>>3)*size; |   size_t d=(((last-first)/size)>>3)*size; | ||||||
| #ifdef DEBUG_QSORT | #ifdef DEBUG_QSORT | ||||||
| fprintf(stderr, "pivot_big: first=%p last=%p size=%lu n=%lu\n", first, (unsigned long)last, size, (unsigned long)((last-first+1)/size)); | fprintf(stderr, "pivot_big: first=%p last=%p size=%lu n=%lu\n", first, (unsigned long)last, size, (unsigned long)((last-first+1)/size)); | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -103,11 +103,11 @@ SDLTest_GenerateExecKey(const char *runSeed, char *suiteName, char *testName, in | |||||||
|     SDLTest_Md5Context md5Context; |     SDLTest_Md5Context md5Context; | ||||||
|     Uint64 *keys; |     Uint64 *keys; | ||||||
|     char iterationString[16]; |     char iterationString[16]; | ||||||
|     Uint32 runSeedLength; |     size_t runSeedLength; | ||||||
|     Uint32 suiteNameLength; |     size_t suiteNameLength; | ||||||
|     Uint32 testNameLength; |     size_t testNameLength; | ||||||
|     Uint32 iterationStringLength; |     size_t iterationStringLength; | ||||||
|     Uint32 entireStringLength; |     size_t entireStringLength; | ||||||
|     char *buffer; |     char *buffer; | ||||||
|  |  | ||||||
|     if (runSeed == NULL || runSeed[0] == '\0') { |     if (runSeed == NULL || runSeed[0] == '\0') { | ||||||
| @@ -150,7 +150,7 @@ SDLTest_GenerateExecKey(const char *runSeed, char *suiteName, char *testName, in | |||||||
|  |  | ||||||
|     /* Hash string and use half of the digest as 64bit exec key */ |     /* Hash string and use half of the digest as 64bit exec key */ | ||||||
|     SDLTest_Md5Init(&md5Context); |     SDLTest_Md5Init(&md5Context); | ||||||
|     SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, entireStringLength); |     SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, (unsigned int) entireStringLength); | ||||||
|     SDLTest_Md5Final(&md5Context); |     SDLTest_Md5Final(&md5Context); | ||||||
|     SDL_free(buffer); |     SDL_free(buffer); | ||||||
|     keys = (Uint64 *)md5Context.digest; |     keys = (Uint64 *)md5Context.digest; | ||||||
|   | |||||||
| @@ -600,7 +600,7 @@ static void RunFIFOTest(SDL_bool lock_free) | |||||||
|     int i, j; |     int i, j; | ||||||
|     int grand_total; |     int grand_total; | ||||||
|     char textBuffer[1024]; |     char textBuffer[1024]; | ||||||
|     int len; |     size_t len; | ||||||
|  |  | ||||||
|     SDL_Log("\nFIFO test---------------------------------------\n\n"); |     SDL_Log("\nFIFO test---------------------------------------\n\n"); | ||||||
|     SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); |     SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); | ||||||
|   | |||||||
| @@ -112,7 +112,7 @@ int platform_testGetFunctions (void *arg) | |||||||
|    char *platform; |    char *platform; | ||||||
|    char *revision; |    char *revision; | ||||||
|    int ret; |    int ret; | ||||||
|    int len; |    size_t len; | ||||||
|  |  | ||||||
|    platform = (char *)SDL_GetPlatform(); |    platform = (char *)SDL_GetPlatform(); | ||||||
|    SDLTest_AssertPass("SDL_GetPlatform()"); |    SDLTest_AssertPass("SDL_GetPlatform()"); | ||||||
| @@ -122,7 +122,7 @@ int platform_testGetFunctions (void *arg) | |||||||
|      SDLTest_AssertCheck(len > 0, |      SDLTest_AssertCheck(len > 0, | ||||||
|              "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", |              "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", | ||||||
|              platform, |              platform, | ||||||
|              len); |              (int) len); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    ret = SDL_GetCPUCount(); |    ret = SDL_GetCPUCount(); | ||||||
| @@ -282,7 +282,7 @@ int platform_testGetSetClearError(void *arg) | |||||||
|    int result; |    int result; | ||||||
|    const char *testError = "Testing"; |    const char *testError = "Testing"; | ||||||
|    char *lastError; |    char *lastError; | ||||||
|    int len; |    size_t len; | ||||||
|  |  | ||||||
|    SDL_ClearError(); |    SDL_ClearError(); | ||||||
|    SDLTest_AssertPass("SDL_ClearError()"); |    SDLTest_AssertPass("SDL_ClearError()"); | ||||||
| @@ -295,7 +295,7 @@ int platform_testGetSetClearError(void *arg) | |||||||
|    { |    { | ||||||
|      len = SDL_strlen(lastError); |      len = SDL_strlen(lastError); | ||||||
|      SDLTest_AssertCheck(len == 0, |      SDLTest_AssertCheck(len == 0, | ||||||
|              "SDL_GetError(): no message expected, len: %i", len); |              "SDL_GetError(): no message expected, len: %i", (int) len); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    result = SDL_SetError("%s", testError); |    result = SDL_SetError("%s", testError); | ||||||
| @@ -310,7 +310,7 @@ int platform_testGetSetClearError(void *arg) | |||||||
|      SDLTest_AssertCheck(len == SDL_strlen(testError), |      SDLTest_AssertCheck(len == SDL_strlen(testError), | ||||||
|              "SDL_GetError(): expected message len %i, was len: %i", |              "SDL_GetError(): expected message len %i, was len: %i", | ||||||
|              (int) SDL_strlen(testError), |              (int) SDL_strlen(testError), | ||||||
|              len); |              (int) len); | ||||||
|      SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, |      SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, | ||||||
|              "SDL_GetError(): expected message %s, was message: %s", |              "SDL_GetError(): expected message %s, was message: %s", | ||||||
|              testError, |              testError, | ||||||
| @@ -334,7 +334,7 @@ int platform_testSetErrorEmptyInput(void *arg) | |||||||
|    int result; |    int result; | ||||||
|    const char *testError = ""; |    const char *testError = ""; | ||||||
|    char *lastError; |    char *lastError; | ||||||
|    int len; |    size_t len; | ||||||
|  |  | ||||||
|    result = SDL_SetError("%s", testError); |    result = SDL_SetError("%s", testError); | ||||||
|    SDLTest_AssertPass("SDL_SetError()"); |    SDLTest_AssertPass("SDL_SetError()"); | ||||||
| @@ -348,7 +348,7 @@ int platform_testSetErrorEmptyInput(void *arg) | |||||||
|      SDLTest_AssertCheck(len == SDL_strlen(testError), |      SDLTest_AssertCheck(len == SDL_strlen(testError), | ||||||
|              "SDL_GetError(): expected message len %i, was len: %i", |              "SDL_GetError(): expected message len %i, was len: %i", | ||||||
|              (int) SDL_strlen(testError), |              (int) SDL_strlen(testError), | ||||||
|              len); |              (int) len); | ||||||
|      SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, |      SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, | ||||||
|              "SDL_GetError(): expected message '%s', was message: '%s'", |              "SDL_GetError(): expected message '%s', was message: '%s'", | ||||||
|              testError, |              testError, | ||||||
| @@ -373,7 +373,7 @@ int platform_testSetErrorInvalidInput(void *arg) | |||||||
|    const char *invalidError = NULL; |    const char *invalidError = NULL; | ||||||
|    const char *probeError = "Testing"; |    const char *probeError = "Testing"; | ||||||
|    char *lastError; |    char *lastError; | ||||||
|    int len; |    size_t len; | ||||||
|  |  | ||||||
|    /* Reset */ |    /* Reset */ | ||||||
|    SDL_ClearError(); |    SDL_ClearError(); | ||||||
| @@ -391,7 +391,7 @@ int platform_testSetErrorInvalidInput(void *arg) | |||||||
|      len = SDL_strlen(lastError); |      len = SDL_strlen(lastError); | ||||||
|      SDLTest_AssertCheck(len == 0, |      SDLTest_AssertCheck(len == 0, | ||||||
|              "SDL_GetError(): expected message len 0, was len: %i", |              "SDL_GetError(): expected message len 0, was len: %i", | ||||||
|              len); |              (int) len); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    /* Set */ |    /* Set */ | ||||||
| @@ -411,7 +411,7 @@ int platform_testSetErrorInvalidInput(void *arg) | |||||||
|      len = SDL_strlen(lastError); |      len = SDL_strlen(lastError); | ||||||
|      SDLTest_AssertCheck(len == 0, |      SDLTest_AssertCheck(len == 0, | ||||||
|              "SDL_GetError(): expected message len 0, was len: %i", |              "SDL_GetError(): expected message len 0, was len: %i", | ||||||
|              len); |              (int) len); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    /* Reset */ |    /* Reset */ | ||||||
| @@ -431,7 +431,7 @@ int platform_testSetErrorInvalidInput(void *arg) | |||||||
|      SDLTest_AssertCheck(len == SDL_strlen(probeError), |      SDLTest_AssertCheck(len == SDL_strlen(probeError), | ||||||
|              "SDL_GetError(): expected message len %i, was len: %i", |              "SDL_GetError(): expected message len %i, was len: %i", | ||||||
|              (int) SDL_strlen(probeError), |              (int) SDL_strlen(probeError), | ||||||
|              len); |              (int) len); | ||||||
|      SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0, |      SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0, | ||||||
|              "SDL_GetError(): expected message '%s', was message: '%s'", |              "SDL_GetError(): expected message '%s', was message: '%s'", | ||||||
|              probeError, |              probeError, | ||||||
|   | |||||||
| @@ -32,9 +32,9 @@ static const char RWopsAlphabetString[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |||||||
| void | void | ||||||
| RWopsSetUp(void *arg) | RWopsSetUp(void *arg) | ||||||
| { | { | ||||||
|     int fileLen; |     size_t fileLen; | ||||||
|     FILE *handle; |     FILE *handle; | ||||||
|     int writtenLen; |     size_t writtenLen; | ||||||
|     int result; |     int result; | ||||||
|  |  | ||||||
|     /* Clean up from previous runs (if any); ignore errors */ |     /* Clean up from previous runs (if any); ignore errors */ | ||||||
| @@ -49,8 +49,8 @@ RWopsSetUp(void *arg) | |||||||
|  |  | ||||||
|     /* Write some known text into it */ |     /* Write some known text into it */ | ||||||
|     fileLen = SDL_strlen(RWopsHelloWorldTestString); |     fileLen = SDL_strlen(RWopsHelloWorldTestString); | ||||||
|     writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle); |     writtenLen = fwrite(RWopsHelloWorldTestString, 1, fileLen, handle); | ||||||
|     SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); |     SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen); | ||||||
|     result = fclose(handle); |     result = fclose(handle); | ||||||
|     SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); |     SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); | ||||||
|  |  | ||||||
| @@ -61,8 +61,8 @@ RWopsSetUp(void *arg) | |||||||
|  |  | ||||||
|     /* Write alphabet text into it */ |     /* Write alphabet text into it */ | ||||||
|     fileLen = SDL_strlen(RWopsAlphabetString); |     fileLen = SDL_strlen(RWopsAlphabetString); | ||||||
|     writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle); |     writtenLen = fwrite(RWopsAlphabetString, 1, fileLen, handle); | ||||||
|     SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); |     SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen); | ||||||
|     result = fclose(handle); |     result = fclose(handle); | ||||||
|     SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); |     SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ int | |||||||
| sdltest_generateRunSeed(void *arg) | sdltest_generateRunSeed(void *arg) | ||||||
| { | { | ||||||
|   char* result; |   char* result; | ||||||
|   int i, l; |   size_t i, l; | ||||||
|    |    | ||||||
|   for (i = 1; i <= 10; i += 3) {    |   for (i = 1; i <= 10; i += 3) {    | ||||||
|      result = SDLTest_GenerateRunSeed((const int)i); |      result = SDLTest_GenerateRunSeed((const int)i); | ||||||
| @@ -42,7 +42,7 @@ sdltest_generateRunSeed(void *arg) | |||||||
|      SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL"); |      SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL"); | ||||||
|      if (result != NULL) { |      if (result != NULL) { | ||||||
|        l = SDL_strlen(result); |        l = SDL_strlen(result); | ||||||
|        SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", i, l); |        SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", (int) i, (int) l); | ||||||
|        SDL_free(result); |        SDL_free(result); | ||||||
|      } |      } | ||||||
|   } |   } | ||||||
| @@ -1119,16 +1119,16 @@ int | |||||||
| sdltest_randomAsciiString(void *arg) | sdltest_randomAsciiString(void *arg) | ||||||
| { | { | ||||||
|   char* result; |   char* result; | ||||||
|   int len; |   size_t len; | ||||||
|   int nonAsciiCharacters; |   int nonAsciiCharacters; | ||||||
|   int i; |   size_t i; | ||||||
|  |  | ||||||
|   result = SDLTest_RandomAsciiString(); |   result = SDLTest_RandomAsciiString(); | ||||||
|   SDLTest_AssertPass("Call to SDLTest_RandomAsciiString()"); |   SDLTest_AssertPass("Call to SDLTest_RandomAsciiString()"); | ||||||
|   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); |   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); | ||||||
|   if (result != NULL) { |   if (result != NULL) { | ||||||
|      len = SDL_strlen(result); |      len = SDL_strlen(result); | ||||||
|      SDLTest_AssertCheck(len >= 0 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", len); |      SDLTest_AssertCheck(len >= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int) len); | ||||||
|      nonAsciiCharacters = 0; |      nonAsciiCharacters = 0; | ||||||
|      for (i=0; i<len; i++) { |      for (i=0; i<len; i++) { | ||||||
|        if (iscntrl(result[i])) { |        if (iscntrl(result[i])) { | ||||||
| @@ -1155,10 +1155,10 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg) | |||||||
|   const char* expectedError = "Parameter 'maxLength' is invalid"; |   const char* expectedError = "Parameter 'maxLength' is invalid"; | ||||||
|   char* lastError; |   char* lastError; | ||||||
|   char* result; |   char* result; | ||||||
|   int targetLen; |   size_t targetLen; | ||||||
|   int len; |   size_t len; | ||||||
|   int nonAsciiCharacters; |   int nonAsciiCharacters; | ||||||
|   int i; |   size_t i; | ||||||
|  |  | ||||||
|   targetLen = 16 + SDLTest_RandomUint8(); |   targetLen = 16 + SDLTest_RandomUint8(); | ||||||
|   result = SDLTest_RandomAsciiStringWithMaximumLength(targetLen); |   result = SDLTest_RandomAsciiStringWithMaximumLength(targetLen); | ||||||
| @@ -1166,7 +1166,7 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg) | |||||||
|   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); |   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); | ||||||
|   if (result != NULL) { |   if (result != NULL) { | ||||||
|      len = SDL_strlen(result); |      len = SDL_strlen(result); | ||||||
|      SDLTest_AssertCheck(len >= 0 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", targetLen, len); |      SDLTest_AssertCheck(len >= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len); | ||||||
|      nonAsciiCharacters = 0; |      nonAsciiCharacters = 0; | ||||||
|      for (i=0; i<len; i++) { |      for (i=0; i<len; i++) { | ||||||
|        if (iscntrl(result[i])) { |        if (iscntrl(result[i])) { | ||||||
| @@ -1208,10 +1208,10 @@ sdltest_randomAsciiStringOfSize(void *arg) | |||||||
|   const char* expectedError = "Parameter 'size' is invalid"; |   const char* expectedError = "Parameter 'size' is invalid"; | ||||||
|   char* lastError; |   char* lastError; | ||||||
|   char* result; |   char* result; | ||||||
|   int targetLen; |   size_t targetLen; | ||||||
|   int len; |   size_t len; | ||||||
|   int nonAsciiCharacters; |   int nonAsciiCharacters; | ||||||
|   int i; |   size_t i; | ||||||
|  |  | ||||||
|   /* Positive test */ |   /* Positive test */ | ||||||
|   targetLen = 16 + SDLTest_RandomUint8(); |   targetLen = 16 + SDLTest_RandomUint8(); | ||||||
| @@ -1220,7 +1220,7 @@ sdltest_randomAsciiStringOfSize(void *arg) | |||||||
|   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); |   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); | ||||||
|   if (result != NULL) { |   if (result != NULL) { | ||||||
|      len = SDL_strlen(result); |      len = SDL_strlen(result); | ||||||
|      SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", targetLen, len); |      SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", (int) targetLen, (int) len); | ||||||
|      nonAsciiCharacters = 0; |      nonAsciiCharacters = 0; | ||||||
|      for (i=0; i<len; i++) { |      for (i=0; i<len; i++) { | ||||||
|        if (iscntrl(result[i])) { |        if (iscntrl(result[i])) { | ||||||
|   | |||||||
| @@ -54,6 +54,7 @@ main(int argc, char **argv) | |||||||
|     name = NULL; |     name = NULL; | ||||||
|     index = -1; |     index = -1; | ||||||
|     if (argc > 1) { |     if (argc > 1) { | ||||||
|  |         size_t l; | ||||||
|         name = argv[1]; |         name = argv[1]; | ||||||
|         if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { |         if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { | ||||||
|             SDL_Log("USAGE: %s [device]\n" |             SDL_Log("USAGE: %s [device]\n" | ||||||
| @@ -63,9 +64,9 @@ main(int argc, char **argv) | |||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         i = strlen(name); |         l = SDL_strlen(name); | ||||||
|         if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) { |         if ((l < 3) && SDL_isdigit(name[0]) && ((l == 1) || SDL_isdigit(name[1]))) { | ||||||
|             index = atoi(name); |             index = SDL_atoi(name); | ||||||
|             name = NULL; |             name = NULL; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ryan C. Gordon
					Ryan C. Gordon