mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-14 07:38:24 +02:00
Cleanup add brace (#6545)
* Add braces after if conditions
* More add braces after if conditions
* Add braces after while() conditions
* Fix compilation because of macro being modified
* Add braces to for loop
* Add braces after if/goto
* Move comments up
* Remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements after merge
* Fix inconsistent patterns are xxx == NULL vs !xxx
* More "{}" for "if() break;" and "if() continue;"
* More "{}" after if() short statement
* More "{}" after "if () return;" statement
* More fix inconsistent patterns are xxx == NULL vs !xxx
* Revert some modificaion on SDL_RLEaccel.c
* SDL_RLEaccel: no short statement
* Cleanup 'if' where the bracket is in a new line
* Cleanup 'while' where the bracket is in a new line
* Cleanup 'for' where the bracket is in a new line
* Cleanup 'else' where the bracket is in a new line
(cherry picked from commit 6a2200823c to reduce conflicts merging between SDL2 and SDL3)
This commit is contained in:
committed by
Sam Lantinga
parent
0739d237ad
commit
fb0ce375f0
@@ -74,13 +74,10 @@ int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char
|
||||
va_end(list);
|
||||
|
||||
/* Log pass or fail message */
|
||||
if (assertCondition == ASSERT_FAIL)
|
||||
{
|
||||
if (assertCondition == ASSERT_FAIL) {
|
||||
SDLTest_AssertsFailed++;
|
||||
SDLTest_LogError(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
SDLTest_AssertsPassed++;
|
||||
SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Passed");
|
||||
}
|
||||
@@ -123,12 +120,9 @@ void SDLTest_ResetAssertSummary()
|
||||
void SDLTest_LogAssertSummary()
|
||||
{
|
||||
int totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
|
||||
if (SDLTest_AssertsFailed == 0)
|
||||
{
|
||||
if (SDLTest_AssertsFailed == 0) {
|
||||
SDLTest_Log(SDLTEST_ASSERT_SUMMARY_FORMAT, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
SDLTest_LogError(SDLTEST_ASSERT_SUMMARY_FORMAT, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags)
|
||||
}
|
||||
|
||||
state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state));
|
||||
if (!state) {
|
||||
if (state == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -116,6 +116,16 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags)
|
||||
return state;
|
||||
}
|
||||
|
||||
#define SEARCHARG(dim) \
|
||||
while (*dim && *dim != ',') { \
|
||||
++dim; \
|
||||
} \
|
||||
if (!*dim) { \
|
||||
return -1; \
|
||||
} \
|
||||
*dim++ = '\0';
|
||||
|
||||
|
||||
int
|
||||
SDLTest_CommonArg(SDLTest_CommonState * state, int index)
|
||||
{
|
||||
@@ -309,20 +319,11 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
|
||||
}
|
||||
x = argv[index];
|
||||
y = argv[index];
|
||||
#define SEARCHARG(dim) \
|
||||
while (*dim && *dim != ',') { \
|
||||
++dim; \
|
||||
} \
|
||||
if (!*dim) { \
|
||||
return -1; \
|
||||
} \
|
||||
*dim++ = '\0';
|
||||
SEARCHARG(y)
|
||||
w = y;
|
||||
SEARCHARG(w)
|
||||
h = w;
|
||||
SEARCHARG(h)
|
||||
#undef SEARCHARG
|
||||
state->confine.x = SDL_atoi(x);
|
||||
state->confine.y = SDL_atoi(y);
|
||||
state->confine.w = SDL_atoi(w);
|
||||
@@ -596,7 +597,7 @@ static const char *
|
||||
BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2)
|
||||
{
|
||||
char *str = *pstr;
|
||||
if (!str) {
|
||||
if (str == NULL) {
|
||||
size_t len = SDL_strlen("[--trackmem]") + 2;
|
||||
int i;
|
||||
for (i = 0; i < numitems; i++) {
|
||||
@@ -608,7 +609,7 @@ BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, co
|
||||
}
|
||||
}
|
||||
str = (char *) SDL_calloc(1, len);
|
||||
if (!str) {
|
||||
if (str == NULL) {
|
||||
return ""; /* oh well. */
|
||||
}
|
||||
SDL_strlcat(str, "[--trackmem] ", len);
|
||||
@@ -1009,7 +1010,7 @@ SDLTest_LoadIcon(const char *file)
|
||||
icon = SDL_LoadBMP(file);
|
||||
if (icon == NULL) {
|
||||
SDL_Log("Couldn't load %s: %s\n", file, SDL_GetError());
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (icon->format->palette) {
|
||||
@@ -1017,7 +1018,7 @@ SDLTest_LoadIcon(const char *file)
|
||||
SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels));
|
||||
}
|
||||
|
||||
return (icon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
static SDL_HitTestResult SDLCALL
|
||||
@@ -1169,8 +1170,9 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
|
||||
SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32 "\n", Rmask);
|
||||
SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32 "\n", Gmask);
|
||||
SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32 "\n", Bmask);
|
||||
if (Amask)
|
||||
if (Amask) {
|
||||
SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask);
|
||||
}
|
||||
}
|
||||
|
||||
/* Print available fullscreen video modes */
|
||||
@@ -1193,9 +1195,9 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
|
||||
Gmask);
|
||||
SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32 "\n",
|
||||
Bmask);
|
||||
if (Amask)
|
||||
SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32 "\n",
|
||||
Amask);
|
||||
if (Amask) {
|
||||
SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1763,7 +1765,7 @@ SDLTest_ScreenShot(SDL_Renderer *renderer)
|
||||
SDL_Rect viewport;
|
||||
SDL_Surface *surface;
|
||||
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1775,7 +1777,7 @@ SDLTest_ScreenShot(SDL_Renderer *renderer)
|
||||
0x000000FF, 0x0000FF00, 0x00FF0000,
|
||||
#endif
|
||||
0x00000000);
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
SDL_Log("Couldn't create surface: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
@@ -1800,7 +1802,7 @@ FullscreenTo(int index, int windowId)
|
||||
Uint32 flags;
|
||||
struct SDL_Rect rect = { 0, 0, 0, 0 };
|
||||
SDL_Window *window = SDL_GetWindowFromID(windowId);
|
||||
if (!window) {
|
||||
if (window == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1940,10 +1942,18 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
|
||||
int x, y;
|
||||
SDL_GetWindowPosition(window, &x, &y);
|
||||
|
||||
if (event->key.keysym.sym == SDLK_UP) y -= delta;
|
||||
if (event->key.keysym.sym == SDLK_DOWN) y += delta;
|
||||
if (event->key.keysym.sym == SDLK_LEFT) x -= delta;
|
||||
if (event->key.keysym.sym == SDLK_RIGHT) x += delta;
|
||||
if (event->key.keysym.sym == SDLK_UP) {
|
||||
y -= delta;
|
||||
}
|
||||
if (event->key.keysym.sym == SDLK_DOWN) {
|
||||
y += delta;
|
||||
}
|
||||
if (event->key.keysym.sym == SDLK_LEFT) {
|
||||
x -= delta;
|
||||
}
|
||||
if (event->key.keysym.sym == SDLK_RIGHT) {
|
||||
x += delta;
|
||||
}
|
||||
|
||||
SDL_Log("Setting position to (%d, %d)\n", x, y);
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
|
||||
@@ -3191,7 +3191,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c)
|
||||
charWidth, charHeight, 32,
|
||||
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
||||
if (character == NULL) {
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
charpos = SDLTest_FontData + ci * charSize;
|
||||
@@ -3224,7 +3224,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c)
|
||||
* Check pointer
|
||||
*/
|
||||
if (cache->charTextureCache[ci] == NULL) {
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3241,7 +3241,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c)
|
||||
*/
|
||||
result |= SDL_RenderCopy(renderer, cache->charTextureCache[ci], &srect, &drect);
|
||||
|
||||
return (result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Gets a unicode value from a UTF-8 encoded string
|
||||
@@ -3352,14 +3352,14 @@ int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s)
|
||||
len -= advance;
|
||||
}
|
||||
|
||||
return (result);
|
||||
return result;
|
||||
}
|
||||
|
||||
SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h)
|
||||
{
|
||||
SDLTest_TextWindow *textwin = (SDLTest_TextWindow *)SDL_malloc(sizeof(*textwin));
|
||||
|
||||
if ( !textwin ) {
|
||||
if (textwin == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3453,8 +3453,7 @@ void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin)
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < textwin->numlines; ++i )
|
||||
{
|
||||
for ( i = 0; i < textwin->numlines; ++i ) {
|
||||
if ( textwin->lines[i] ) {
|
||||
SDL_free(textwin->lines[i]);
|
||||
textwin->lines[i] = NULL;
|
||||
|
||||
@@ -167,11 +167,11 @@ SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
|
||||
Sint64 temp;
|
||||
Sint64 number;
|
||||
|
||||
if(pMin > pMax) {
|
||||
if (pMin > pMax) {
|
||||
temp = min;
|
||||
min = max;
|
||||
max = temp;
|
||||
} else if(pMin == pMax) {
|
||||
} else if (pMin == pMax) {
|
||||
return (Sint32)min;
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ SDLTest_RandomAsciiStringWithMaximumLength(int maxLength)
|
||||
{
|
||||
int size;
|
||||
|
||||
if(maxLength < 1) {
|
||||
if (maxLength < 1) {
|
||||
SDL_InvalidParamError("maxLength");
|
||||
return NULL;
|
||||
}
|
||||
@@ -510,7 +510,7 @@ SDLTest_RandomAsciiStringOfSize(int size)
|
||||
int counter;
|
||||
|
||||
|
||||
if(size < 1) {
|
||||
if (size < 1) {
|
||||
SDL_InvalidParamError("size");
|
||||
return NULL;
|
||||
}
|
||||
@@ -520,7 +520,7 @@ SDLTest_RandomAsciiStringOfSize(int size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(counter = 0; counter < size; ++counter) {
|
||||
for (counter = 0; counter < size; ++counter) {
|
||||
string[counter] = (char)SDLTest_RandomIntegerInRange(32, 126);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,14 +234,12 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseRef
|
||||
int testResult = 0;
|
||||
int fuzzerCount;
|
||||
|
||||
if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL)
|
||||
{
|
||||
if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL) {
|
||||
SDLTest_LogError("Setup failure: testSuite or testCase references NULL");
|
||||
return TEST_RESULT_SETUP_FAILURE;
|
||||
}
|
||||
|
||||
if (!testCase->enabled && forceTestRun == SDL_FALSE)
|
||||
{
|
||||
if (!testCase->enabled && forceTestRun == SDL_FALSE) {
|
||||
SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Skipped (Disabled)");
|
||||
return TEST_RESULT_SKIPPED;
|
||||
}
|
||||
@@ -326,7 +324,7 @@ static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
|
||||
|
||||
/* Loop over all suites */
|
||||
suiteCounter = 0;
|
||||
while(&testSuites[suiteCounter]) {
|
||||
while (&testSuites[suiteCounter]) {
|
||||
testSuite=&testSuites[suiteCounter];
|
||||
suiteCounter++;
|
||||
SDLTest_Log("Test Suite %i - %s\n", suiteCounter,
|
||||
@@ -334,8 +332,7 @@ static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
|
||||
|
||||
/* Loop over all test cases */
|
||||
testCounter = 0;
|
||||
while(testSuite->testCases[testCounter])
|
||||
{
|
||||
while (testSuite->testCases[testCounter]) {
|
||||
testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
|
||||
testCounter++;
|
||||
SDLTest_Log(" Test Case %i - %s: %s", testCounter,
|
||||
@@ -436,8 +433,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
testSuite = testSuites[suiteCounter];
|
||||
suiteCounter++;
|
||||
testCounter = 0;
|
||||
while (testSuite->testCases[testCounter])
|
||||
{
|
||||
while (testSuite->testCases[testCounter]) {
|
||||
testCounter++;
|
||||
totalNumberOfTests++;
|
||||
}
|
||||
@@ -510,7 +506,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
|
||||
/* Loop over all suites */
|
||||
suiteCounter = 0;
|
||||
while(testSuites[suiteCounter]) {
|
||||
while (testSuites[suiteCounter]) {
|
||||
testSuite = testSuites[suiteCounter];
|
||||
currentSuiteName = (testSuite->name ? testSuite->name : SDLTEST_INVALID_NAME_FORMAT);
|
||||
suiteCounter++;
|
||||
@@ -539,8 +535,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
|
||||
/* Loop over all test cases */
|
||||
testCounter = 0;
|
||||
while(testSuite->testCases[testCounter])
|
||||
{
|
||||
while (testSuite->testCases[testCounter]) {
|
||||
testCase = testSuite->testCases[testCounter];
|
||||
currentTestName = (testCase->name ? testCase->name : SDLTEST_INVALID_NAME_FORMAT);
|
||||
testCounter++;
|
||||
@@ -575,8 +570,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
|
||||
/* Loop over all iterations */
|
||||
iterationCounter = 0;
|
||||
while(iterationCounter < testIterations)
|
||||
{
|
||||
while (iterationCounter < testIterations) {
|
||||
iterationCounter++;
|
||||
|
||||
if (userExecKey != 0) {
|
||||
@@ -603,7 +597,9 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
/* Take time - test end */
|
||||
testEndSeconds = GetClock();
|
||||
runtime = testEndSeconds - testStartSeconds;
|
||||
if (runtime < 0.0f) runtime = 0.0f;
|
||||
if (runtime < 0.0f) {
|
||||
runtime = 0.0f;
|
||||
}
|
||||
|
||||
if (testIterations > 1) {
|
||||
/* Log test runtime */
|
||||
@@ -638,20 +634,19 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
/* Take time - suite end */
|
||||
suiteEndSeconds = GetClock();
|
||||
runtime = suiteEndSeconds - suiteStartSeconds;
|
||||
if (runtime < 0.0f) runtime = 0.0f;
|
||||
if (runtime < 0.0f) {
|
||||
runtime = 0.0f;
|
||||
}
|
||||
|
||||
/* Log suite runtime */
|
||||
SDLTest_Log("Total Suite runtime: %.1f sec", runtime);
|
||||
|
||||
/* Log summary and final Suite result */
|
||||
countSum = testPassedCount + testFailedCount + testSkippedCount;
|
||||
if (testFailedCount == 0)
|
||||
{
|
||||
if (testFailedCount == 0) {
|
||||
SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
|
||||
SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Passed");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
|
||||
SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Failed");
|
||||
}
|
||||
@@ -662,21 +657,20 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
/* Take time - run end */
|
||||
runEndSeconds = GetClock();
|
||||
runtime = runEndSeconds - runStartSeconds;
|
||||
if (runtime < 0.0f) runtime = 0.0f;
|
||||
if (runtime < 0.0f) {
|
||||
runtime = 0.0f;
|
||||
}
|
||||
|
||||
/* Log total runtime */
|
||||
SDLTest_Log("Total Run runtime: %.1f sec", runtime);
|
||||
|
||||
/* Log summary and final run result */
|
||||
countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount;
|
||||
if (totalTestFailedCount == 0)
|
||||
{
|
||||
if (totalTestFailedCount == 0) {
|
||||
runResult = 0;
|
||||
SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
|
||||
SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Passed");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
runResult = 1;
|
||||
SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
|
||||
SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Failed");
|
||||
|
||||
@@ -109,7 +109,9 @@ static unsigned char MD5PADDING[64] = {
|
||||
|
||||
void SDLTest_Md5Init(SDLTest_Md5Context * mdContext)
|
||||
{
|
||||
if (mdContext==NULL) return;
|
||||
if (mdContext == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
mdContext->i[0] = mdContext->i[1] = (MD5UINT4) 0;
|
||||
|
||||
@@ -135,8 +137,12 @@ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
|
||||
int mdi;
|
||||
unsigned int i, ii;
|
||||
|
||||
if (mdContext == NULL) return;
|
||||
if (inBuf == NULL || inLen < 1) return;
|
||||
if (mdContext == NULL) {
|
||||
return;
|
||||
}
|
||||
if (inBuf == NULL || inLen < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute number of bytes mod 64
|
||||
@@ -146,8 +152,9 @@ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
|
||||
/*
|
||||
* update number of bits
|
||||
*/
|
||||
if ((mdContext->i[0] + ((MD5UINT4) inLen << 3)) < mdContext->i[0])
|
||||
if ((mdContext->i[0] + ((MD5UINT4)inLen << 3)) < mdContext->i[0]) {
|
||||
mdContext->i[1]++;
|
||||
}
|
||||
mdContext->i[0] += ((MD5UINT4) inLen << 3);
|
||||
mdContext->i[1] += ((MD5UINT4) inLen >> 29);
|
||||
|
||||
@@ -161,11 +168,9 @@ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
|
||||
* transform if necessary
|
||||
*/
|
||||
if (mdi == 0x40) {
|
||||
for (i = 0, ii = 0; i < 16; i++, ii += 4)
|
||||
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
|
||||
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
|
||||
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
|
||||
((MD5UINT4) mdContext->in[ii]);
|
||||
for (i = 0, ii = 0; i < 16; i++, ii += 4) {
|
||||
in[i] = (((MD5UINT4)mdContext->in[ii + 3]) << 24) | (((MD5UINT4)mdContext->in[ii + 2]) << 16) | (((MD5UINT4)mdContext->in[ii + 1]) << 8) | ((MD5UINT4)mdContext->in[ii]);
|
||||
}
|
||||
SDLTest_Md5Transform(mdContext->buf, in);
|
||||
mdi = 0;
|
||||
}
|
||||
@@ -184,7 +189,9 @@ void SDLTest_Md5Final(SDLTest_Md5Context * mdContext)
|
||||
unsigned int i, ii;
|
||||
unsigned int padLen;
|
||||
|
||||
if (mdContext == NULL) return;
|
||||
if (mdContext == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* save number of bits
|
||||
@@ -206,11 +213,9 @@ void SDLTest_Md5Final(SDLTest_Md5Context * mdContext)
|
||||
/*
|
||||
* append length in bits and transform
|
||||
*/
|
||||
for (i = 0, ii = 0; i < 14; i++, ii += 4)
|
||||
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
|
||||
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
|
||||
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
|
||||
((MD5UINT4) mdContext->in[ii]);
|
||||
for (i = 0, ii = 0; i < 14; i++, ii += 4) {
|
||||
in[i] = (((MD5UINT4)mdContext->in[ii + 3]) << 24) | (((MD5UINT4)mdContext->in[ii + 2]) << 16) | (((MD5UINT4)mdContext->in[ii + 1]) << 8) | ((MD5UINT4)mdContext->in[ii]);
|
||||
}
|
||||
SDLTest_Md5Transform(mdContext->buf, in);
|
||||
|
||||
/*
|
||||
|
||||
@@ -84,7 +84,7 @@ static void SDL_TrackAllocation(void *mem, size_t size)
|
||||
return;
|
||||
}
|
||||
entry = (SDL_tracked_allocation *)SDL_malloc_orig(sizeof(*entry));
|
||||
if (!entry) {
|
||||
if (entry == NULL) {
|
||||
return;
|
||||
}
|
||||
entry->mem = mem;
|
||||
@@ -171,7 +171,7 @@ static void * SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
SDL_assert(!ptr || SDL_IsAllocationTracked(ptr));
|
||||
SDL_assert(ptr == NULL || SDL_IsAllocationTracked(ptr));
|
||||
mem = SDL_realloc_orig(ptr, size);
|
||||
if (mem && mem != ptr) {
|
||||
if (ptr) {
|
||||
@@ -184,7 +184,7 @@ static void * SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size)
|
||||
|
||||
static void SDLCALL SDLTest_TrackedFree(void *ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
if (ptr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
|
||||
void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, unsigned int ci)
|
||||
{
|
||||
if (rndContext==NULL) return;
|
||||
if (rndContext == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose a value for 'a' from this list
|
||||
@@ -66,7 +68,9 @@ void SDLTest_RandomInitTime(SDLTest_RandomContext * rndContext)
|
||||
{
|
||||
int a, b;
|
||||
|
||||
if (rndContext==NULL) return;
|
||||
if (rndContext == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
srand((unsigned int)time(NULL));
|
||||
a=rand();
|
||||
@@ -81,7 +85,9 @@ unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext)
|
||||
{
|
||||
unsigned int xh, xl;
|
||||
|
||||
if (rndContext==NULL) return -1;
|
||||
if (rndContext == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
xh = rndContext->x >> 16;
|
||||
xl = rndContext->x & 65535;
|
||||
@@ -89,9 +95,10 @@ unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext)
|
||||
rndContext->c =
|
||||
xh * rndContext->ah + ((xh * rndContext->al) >> 16) +
|
||||
((xl * rndContext->ah) >> 16);
|
||||
if (xl * rndContext->al >= (~rndContext->c + 1))
|
||||
if (xl * rndContext->al >= (~rndContext->c + 1)) {
|
||||
rndContext->c++;
|
||||
return (rndContext->x);
|
||||
}
|
||||
return rndContext->x;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user