From c760c02c6cd2305abfb88500e834aa0b116b1646 Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Wed, 25 Mar 2020 01:34:15 -0400 Subject: [PATCH] Fix some format specifier warnings The warnings were produced by GCC 9.2.x for x86_64-linux-gnu or i386-pc-msdosdjgpp targets. Most of the fixes involve changing the type of a variable rather than the format specifier. For many of the affected test conuter variables, a basic int seems sufficient. Some format specifier warnings still remain for cases where changing type or casting seemed inappropriate. Those warnings will probably require some new format specifier macros (e.g. SDL_PRIu32). --- src/test/SDL_test_assert.c | 6 +++--- src/test/SDL_test_harness.c | 14 +++++++------- test/testautomation.c | 2 +- test/testautomation_sdltest.c | 8 ++++---- test/testtimer.c | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c index 7414349f1..d8aca4eed 100644 --- a/src/test/SDL_test_assert.c +++ b/src/test/SDL_test_assert.c @@ -36,10 +36,10 @@ #define SDLTEST_ASSERT_SUMMARY_FORMAT "Assert Summary: Total=%d Passed=%d Failed=%d" /* ! \brief counts the failed asserts */ -static Uint32 SDLTest_AssertsFailed = 0; +static int SDLTest_AssertsFailed = 0; /* ! \brief counts the passed asserts */ -static Uint32 SDLTest_AssertsPassed = 0; +static int SDLTest_AssertsPassed = 0; /* * Assert that logs and break execution flow on failures (i.e. for harness errors). @@ -122,7 +122,7 @@ void SDLTest_ResetAssertSummary() */ void SDLTest_LogAssertSummary() { - Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed; + int totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed; if (SDLTest_AssertsFailed == 0) { SDLTest_Log(SDLTEST_ASSERT_SUMMARY_FORMAT, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed); diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index 942ed38ed..7b27a5e28 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -394,13 +394,13 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDL_bool forceTestRun = SDL_FALSE; int testResult = 0; int runResult = 0; - Uint32 totalTestFailedCount = 0; - Uint32 totalTestPassedCount = 0; - Uint32 totalTestSkippedCount = 0; - Uint32 testFailedCount = 0; - Uint32 testPassedCount = 0; - Uint32 testSkippedCount = 0; - Uint32 countSum = 0; + int totalTestFailedCount = 0; + int totalTestPassedCount = 0; + int totalTestSkippedCount = 0; + int testFailedCount = 0; + int testPassedCount = 0; + int testSkippedCount = 0; + int countSum = 0; const SDLTest_TestCaseReference **failedTests; /* Sanitize test iterations */ diff --git a/test/testautomation.c b/test/testautomation.c index bc7fa528c..ef600178c 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -62,7 +62,7 @@ main(int argc, char *argv[]) } else if (SDL_strcasecmp(argv[i], "--execKey") == 0) { if (argv[i + 1]) { - SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, (long long unsigned int *)&userExecKey); + SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, &userExecKey); consumed = 2; } } diff --git a/test/testautomation_sdltest.c b/test/testautomation_sdltest.c index 979756adc..339b7c168 100644 --- a/test/testautomation_sdltest.c +++ b/test/testautomation_sdltest.c @@ -1163,7 +1163,7 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg) targetLen = 16 + SDLTest_RandomUint8(); result = SDLTest_RandomAsciiStringWithMaximumLength((int) targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen); + SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", (int) targetLen); SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); if (result != NULL) { len = SDL_strlen(result); @@ -1184,7 +1184,7 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg) /* Negative test */ targetLen = 0; result = SDLTest_RandomAsciiStringWithMaximumLength((int) targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen); + SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", (int) targetLen); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); @@ -1217,7 +1217,7 @@ sdltest_randomAsciiStringOfSize(void *arg) /* Positive test */ targetLen = 16 + SDLTest_RandomUint8(); result = SDLTest_RandomAsciiStringOfSize((int) targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen); + SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", (int) targetLen); SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); if (result != NULL) { len = SDL_strlen(result); @@ -1238,7 +1238,7 @@ sdltest_randomAsciiStringOfSize(void *arg) /* Negative test */ targetLen = 0; result = SDLTest_RandomAsciiStringOfSize((int) targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen); + SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", (int) targetLen); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); diff --git a/test/testtimer.c b/test/testtimer.c index 2e995e3be..7e49d7508 100644 --- a/test/testtimer.c +++ b/test/testtimer.c @@ -107,7 +107,7 @@ main(int argc, char *argv[]) now = SDL_GetPerformanceCounter(); SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); - SDL_Log("Performance counter frequency: %"SDL_PRIu64"\n", (unsigned long long) SDL_GetPerformanceFrequency()); + SDL_Log("Performance counter frequency: %"SDL_PRIu64"\n", SDL_GetPerformanceFrequency()); start32 = SDL_GetTicks(); start = SDL_GetPerformanceCounter(); SDL_Delay(1000);