Skip to content

Commit

Permalink
Fix some format specifier warnings
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jayschwa committed Mar 25, 2020
1 parent dad73b1 commit c760c02
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/test/SDL_test_assert.c
Expand Up @@ -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).
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/test/SDL_test_harness.c
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion test/testautomation.c
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/testautomation_sdltest.c
Expand Up @@ -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);
Expand All @@ -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()");
Expand Down Expand Up @@ -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);
Expand All @@ -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()");
Expand Down
2 changes: 1 addition & 1 deletion test/testtimer.c
Expand Up @@ -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);
Expand Down

0 comments on commit c760c02

Please sign in to comment.