Pointer as bool (libsdl-org#7214)
This commit is contained in:
@@ -102,7 +102,7 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags)
|
||||
}
|
||||
|
||||
state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file)
|
||||
|
||||
/* Load the icon surface */
|
||||
icon = SDL_LoadBMP(file);
|
||||
if (icon == NULL) {
|
||||
if (!icon) {
|
||||
SDL_Log("Couldn't load %s: %s\n", file, SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
@@ -1919,7 +1919,7 @@ static void SDLTest_CopyScreenShot(SDL_Renderer *renderer)
|
||||
};
|
||||
SDLTest_ClipboardData *clipboard_data;
|
||||
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1927,7 +1927,7 @@ static void SDLTest_CopyScreenShot(SDL_Renderer *renderer)
|
||||
|
||||
surface = SDL_CreateSurface(viewport.w, viewport.h, SDL_PIXELFORMAT_BGR24);
|
||||
|
||||
if (surface == NULL) {
|
||||
if (!surface) {
|
||||
SDL_Log("Couldn't create surface: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,12 +66,12 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
|
||||
char referenceFilename[FILENAME_SIZE];
|
||||
|
||||
/* Validate input surfaces */
|
||||
if (surface == NULL) {
|
||||
if (!surface) {
|
||||
SDLTest_LogError("Cannot compare NULL surface");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (referenceSurface == NULL) {
|
||||
if (!referenceSurface) {
|
||||
SDLTest_LogError("Cannot compare NULL reference surface");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext)
|
||||
CrcUint32 c;
|
||||
|
||||
/* Sanity check context pointer */
|
||||
if (crcContext == NULL) {
|
||||
if (!crcContext) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ int SDLTest_Crc32Calc(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint
|
||||
int SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32)
|
||||
{
|
||||
/* Sanity check pointers */
|
||||
if (crcContext == NULL) {
|
||||
if (!crcContext) {
|
||||
*crc32 = 0;
|
||||
return -1;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ int SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32)
|
||||
int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32)
|
||||
{
|
||||
/* Sanity check pointers */
|
||||
if (crcContext == NULL) {
|
||||
if (!crcContext) {
|
||||
*crc32 = 0;
|
||||
return -1;
|
||||
}
|
||||
@@ -125,12 +125,12 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, C
|
||||
CrcUint8 *p;
|
||||
register CrcUint32 crc;
|
||||
|
||||
if (crcContext == NULL) {
|
||||
if (!crcContext) {
|
||||
*crc32 = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (inBuf == NULL) {
|
||||
if (!inBuf) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, C
|
||||
|
||||
int SDLTest_Crc32Done(SDLTest_Crc32Context *crcContext)
|
||||
{
|
||||
if (crcContext == NULL) {
|
||||
if (!crcContext) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -3165,14 +3165,14 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c)
|
||||
ci = c;
|
||||
|
||||
/* Search for this renderer's cache */
|
||||
for (cache = SDLTest_CharTextureCacheList; cache != NULL; cache = cache->next) {
|
||||
for (cache = SDLTest_CharTextureCacheList; cache; cache = cache->next) {
|
||||
if (cache->renderer == renderer) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate a new cache for this renderer if needed */
|
||||
if (cache == NULL) {
|
||||
if (!cache) {
|
||||
cache = (struct SDLTest_CharTextureCache *)SDL_calloc(1, sizeof(struct SDLTest_CharTextureCache));
|
||||
cache->renderer = renderer;
|
||||
cache->next = SDLTest_CharTextureCacheList;
|
||||
@@ -3187,7 +3187,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c)
|
||||
* Redraw character into surface
|
||||
*/
|
||||
character = SDL_CreateSurface(charWidth, charHeight, SDL_PIXELFORMAT_RGBA8888);
|
||||
if (character == NULL) {
|
||||
if (!character) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -3357,7 +3357,7 @@ SDLTest_TextWindow *SDLTest_TextWindowCreate(float x, float y, float w, float h)
|
||||
{
|
||||
SDLTest_TextWindow *textwin = (SDLTest_TextWindow *)SDL_malloc(sizeof(*textwin));
|
||||
|
||||
if (textwin == NULL) {
|
||||
if (!textwin) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ char *SDLTest_RandomAsciiStringOfSize(int size)
|
||||
}
|
||||
|
||||
string = (char *)SDL_malloc((size + 1) * sizeof(char));
|
||||
if (string == NULL) {
|
||||
if (!string) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ char *SDLTest_GenerateRunSeed(const int length)
|
||||
|
||||
/* Allocate output buffer */
|
||||
seed = (char *)SDL_malloc((length + 1) * sizeof(char));
|
||||
if (seed == NULL) {
|
||||
if (!seed) {
|
||||
SDLTest_LogError("SDL_malloc for run seed output buffer failed.");
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return NULL;
|
||||
@@ -118,17 +118,17 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName
|
||||
size_t entireStringLength;
|
||||
char *buffer;
|
||||
|
||||
if (runSeed == NULL || runSeed[0] == '\0') {
|
||||
if (!runSeed || runSeed[0] == '\0') {
|
||||
SDLTest_LogError("Invalid runSeed string.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (suiteName == NULL || suiteName[0] == '\0') {
|
||||
if (!suiteName || suiteName[0] == '\0') {
|
||||
SDLTest_LogError("Invalid suiteName string.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (testName == NULL || testName[0] == '\0') {
|
||||
if (!testName || testName[0] == '\0') {
|
||||
SDLTest_LogError("Invalid testName string.");
|
||||
return -1;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName
|
||||
iterationStringLength = SDL_strlen(iterationString);
|
||||
entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1;
|
||||
buffer = (char *)SDL_malloc(entireStringLength);
|
||||
if (buffer == NULL) {
|
||||
if (!buffer) {
|
||||
SDLTest_LogError("Failed to allocate buffer for execKey generation.");
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return 0;
|
||||
@@ -181,7 +181,7 @@ static SDL_TimerID SDLTest_SetTestTimeout(int timeout, void(SDLCALL *callback)(v
|
||||
Uint32 timeoutInMilliseconds;
|
||||
SDL_TimerID timerID;
|
||||
|
||||
if (callback == NULL) {
|
||||
if (!callback) {
|
||||
SDLTest_LogError("Timeout callback can't be NULL");
|
||||
return -1;
|
||||
}
|
||||
@@ -239,7 +239,7 @@ static int SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_
|
||||
int testResult = 0;
|
||||
int fuzzerCount;
|
||||
|
||||
if (testSuite == NULL || testCase == NULL || testSuite->name == NULL || testCase->name == NULL) {
|
||||
if (!testSuite || !testCase || !testSuite->name || !testCase->name) {
|
||||
SDLTest_LogError("Setup failure: testSuite or testCase references NULL");
|
||||
return TEST_RESULT_SETUP_FAILURE;
|
||||
}
|
||||
@@ -412,9 +412,9 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
}
|
||||
|
||||
/* Generate run see if we don't have one already */
|
||||
if (userRunSeed == NULL || userRunSeed[0] == '\0') {
|
||||
if (!userRunSeed || userRunSeed[0] == '\0') {
|
||||
char *tmp = SDLTest_GenerateRunSeed(16);
|
||||
if (tmp == NULL) {
|
||||
if (!tmp) {
|
||||
SDLTest_LogError("Generating a random seed failed");
|
||||
return 2;
|
||||
}
|
||||
@@ -455,20 +455,20 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
|
||||
/* Pre-allocate an array for tracking failed tests (potentially all test cases) */
|
||||
failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
|
||||
if (failedTests == NULL) {
|
||||
if (!failedTests) {
|
||||
SDLTest_LogError("Unable to allocate cache for failed tests");
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Initialize filtering */
|
||||
if (filter != NULL && filter[0] != '\0') {
|
||||
if (filter && filter[0] != '\0') {
|
||||
/* Loop over all suites to check if we have a filter match */
|
||||
suiteCounter = 0;
|
||||
while (testSuites[suiteCounter] && suiteFilter == 0) {
|
||||
testSuite = testSuites[suiteCounter];
|
||||
suiteCounter++;
|
||||
if (testSuite->name != NULL && SDL_strcasecmp(filter, testSuite->name) == 0) {
|
||||
if (testSuite->name && SDL_strcasecmp(filter, testSuite->name) == 0) {
|
||||
/* Matched a suite name */
|
||||
suiteFilter = 1;
|
||||
suiteFilterName = testSuite->name;
|
||||
@@ -481,7 +481,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
while (testSuite->testCases[testCounter] && testFilter == 0) {
|
||||
testCase = testSuite->testCases[testCounter];
|
||||
testCounter++;
|
||||
if (testCase->name != NULL && SDL_strcasecmp(filter, testCase->name) == 0) {
|
||||
if (testCase->name && SDL_strcasecmp(filter, testCase->name) == 0) {
|
||||
/* Matched a test name */
|
||||
suiteFilter = 1;
|
||||
suiteFilterName = testSuite->name;
|
||||
@@ -497,7 +497,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter);
|
||||
for (suiteCounter = 0; testSuites[suiteCounter]; ++suiteCounter) {
|
||||
testSuite = testSuites[suiteCounter];
|
||||
if (testSuite->name != NULL) {
|
||||
if (testSuite->name) {
|
||||
SDLTest_Log("Test suite: %s", testSuite->name);
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
suiteCounter++;
|
||||
|
||||
/* Filter suite if flag set and we have a name */
|
||||
if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL &&
|
||||
if (suiteFilter == 1 && suiteFilterName && testSuite->name &&
|
||||
SDL_strcasecmp(suiteFilterName, testSuite->name) != 0) {
|
||||
/* Skip suite */
|
||||
SDLTest_Log("===== Test Suite %i: '%s' " COLOR_BLUE "skipped" COLOR_END "\n",
|
||||
@@ -550,7 +550,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
testCounter++;
|
||||
|
||||
/* Filter tests if flag set and we have a name */
|
||||
if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL &&
|
||||
if (testFilter == 1 && testFilterName && testCase->name &&
|
||||
SDL_strcasecmp(testFilterName, testCase->name) != 0) {
|
||||
/* Skip test */
|
||||
SDLTest_Log("===== Test Case %i.%i: '%s' " COLOR_BLUE "skipped" COLOR_END "\n",
|
||||
@@ -572,7 +572,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||
suiteCounter,
|
||||
testCounter,
|
||||
currentTestName);
|
||||
if (testCase->description != NULL && testCase->description[0] != '\0') {
|
||||
if (testCase->description && testCase->description[0] != '\0') {
|
||||
SDLTest_Log("Test Description: '%s'",
|
||||
(testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ static unsigned char MD5PADDING[64] = {
|
||||
|
||||
void SDLTest_Md5Init(SDLTest_Md5Context *mdContext)
|
||||
{
|
||||
if (mdContext == NULL) {
|
||||
if (!mdContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,10 +138,10 @@ void SDLTest_Md5Update(SDLTest_Md5Context *mdContext, unsigned char *inBuf,
|
||||
int mdi;
|
||||
unsigned int i, ii;
|
||||
|
||||
if (mdContext == NULL) {
|
||||
if (!mdContext) {
|
||||
return;
|
||||
}
|
||||
if (inBuf == NULL || inLen < 1) {
|
||||
if (!inBuf || inLen < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ void SDLTest_Md5Final(SDLTest_Md5Context *mdContext)
|
||||
unsigned int i, ii;
|
||||
unsigned int padLen;
|
||||
|
||||
if (mdContext == NULL) {
|
||||
if (!mdContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ static void SDL_TrackAllocation(void *mem, size_t size)
|
||||
return;
|
||||
}
|
||||
entry = (SDL_tracked_allocation *)SDL_malloc_orig(sizeof(*entry));
|
||||
if (entry == NULL) {
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
entry->mem = mem;
|
||||
@@ -272,7 +272,7 @@ static void *SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size)
|
||||
|
||||
static void SDLCALL SDLTest_TrackedFree(void *ptr)
|
||||
{
|
||||
if (ptr == NULL) {
|
||||
if (!ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
void SDLTest_RandomInit(SDLTest_RandomContext *rndContext, unsigned int xi, unsigned int ci)
|
||||
{
|
||||
if (rndContext == NULL) {
|
||||
if (!rndContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext)
|
||||
{
|
||||
int a, b;
|
||||
|
||||
if (rndContext == NULL) {
|
||||
if (!rndContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext)
|
||||
{
|
||||
unsigned int xh, xl;
|
||||
|
||||
if (rndContext == NULL) {
|
||||
if (!rndContext) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user