From 7b139546d7cb6bfccad2036ad782c75b36b7598d Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 16 Nov 2023 21:22:10 +0300
Subject: [PATCH] sync tests, testlib and dynapi with latest SDL2
---
src/dynapi/SDL_dynapi.c | 6 +++---
src/test/SDL_test_common.c | 14 +++++++-------
src/test/SDL_test_compare.c | 2 +-
src/test/SDL_test_crc32.c | 12 ++++++------
src/test/SDL_test_font.c | 8 ++++----
src/test/SDL_test_fuzzer.c | 2 +-
src/test/SDL_test_harness.c | 34 +++++++++++++++++-----------------
src/test/SDL_test_md5.c | 8 ++++----
src/test/SDL_test_memory.c | 4 ++--
src/test/SDL_test_random.c | 6 +++---
test/checkkeys.c | 4 ++--
test/checkkeysthreads.c | 2 +-
test/controllermap.c | 11 ++++++-----
test/loopwave.c | 2 +-
test/loopwavequeue.c | 2 +-
test/testaudiohotplug.c | 4 ++--
test/testaudioinfo.c | 6 +++---
test/testautomation.c | 2 +-
test/testautomation_mouse.c | 6 +++---
test/testautomation_render.c | 12 ++++++------
test/testautomation_stdlib.c | 4 ++--
test/testautomation_video.c | 30 +++++++++++++++---------------
test/testcustomcursor.c | 2 +-
test/testdisplayinfo.c | 2 +-
test/testdraw2.c | 2 +-
test/testdrawchessboard.c | 4 ++--
test/testdropfile.c | 2 +-
test/testerror.c | 2 +-
test/testfile.c | 18 +++++++++---------
test/testfilesystem.c | 6 +++---
test/testgamecontroller.c | 17 +++++++++--------
test/testgeometry.c | 4 ++--
test/testgesture.c | 4 ++--
test/testgl2.c | 2 +-
test/testgles.c | 6 +++---
test/testgles2.c | 6 +++---
test/testgles2_sdf.c | 12 ++++++------
test/testhaptic.c | 6 +++---
test/testhittesting.c | 2 +-
test/testhotplug.c | 2 +-
test/testiconv.c | 2 +-
test/testime.c | 24 ++++++++++++------------
test/testintersections.c | 2 +-
test/testjoystick.c | 6 +++---
test/testloadso.c | 4 ++--
test/testlocale.c | 2 +-
test/testlock.c | 2 +-
test/testmouse.c | 14 +++++++-------
test/testnative.c | 14 +++++++-------
test/testnativew32.c | 2 +-
test/testoffscreen.c | 4 ++--
test/testoverlay2.c | 12 ++++++------
test/testplatform.c | 2 +-
test/testrelative.c | 2 +-
test/testrendercopyex.c | 2 +-
test/testrendertarget.c | 4 ++--
test/testresample.c | 4 ++--
test/testrumble.c | 6 +++---
test/testscale.c | 2 +-
test/testsensor.c | 4 ++--
test/testshader.c | 10 +++++-----
test/testshape.c | 6 +++---
test/testsprite2.c | 6 +++---
test/testspriteminimal.c | 2 +-
test/teststreaming.c | 10 +++++-----
test/testthread.c | 4 ++--
test/testutils.c | 20 ++++++++++----------
test/testviewport.c | 4 ++--
test/testvulkan.c | 12 ++++++------
test/testwm2.c | 6 +++---
test/testyuv.c | 12 ++++++------
71 files changed, 244 insertions(+), 242 deletions(-)
diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c
index 4f57a44..3087b42 100644
--- a/src/dynapi/SDL_dynapi.c
+++ b/src/dynapi/SDL_dynapi.c
@@ -369,7 +369,7 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
void *retval = NULL;
if (lib) {
retval = (void *) GetProcAddress(lib, sym);
- if (retval == NULL) {
+ if (!retval) {
FreeLibrary(lib);
}
}
@@ -384,9 +384,9 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
void *retval = NULL;
- if (lib != NULL) {
+ if (lib) {
retval = dlsym(lib, sym);
- if (retval == NULL) {
+ if (!retval) {
dlclose(lib);
}
}
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 80c6275..6079b61 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -72,7 +72,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;
}
@@ -592,7 +592,7 @@ void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const
static const char *BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2)
{
char *str = *pstr;
- if (str == NULL) {
+ if (!str) {
size_t len = SDL_strlen("[--trackmem]") + 2;
int i;
for (i = 0; i < numitems; i++) {
@@ -604,7 +604,7 @@ static const char *BuildCommonUsageString(char **pstr, const char **strlist, con
}
}
str = (char *)SDL_calloc(1, len);
- if (str == NULL) {
+ if (!str) {
return ""; /* oh well. */
}
SDL_strlcat(str, "[--trackmem] ", len);
@@ -992,7 +992,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;
}
@@ -1757,7 +1757,7 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer)
SDL_Rect viewport;
SDL_Surface *surface;
- if (renderer == NULL) {
+ if (!renderer) {
return;
}
@@ -1769,7 +1769,7 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer)
0x000000FF, 0x0000FF00, 0x00FF0000,
#endif
0x00000000);
- if (surface == NULL) {
+ if (!surface) {
SDL_Log("Couldn't create surface: %s\n", SDL_GetError());
return;
}
@@ -1793,7 +1793,7 @@ static void FullscreenTo(int index, int windowId)
Uint32 flags;
struct SDL_Rect rect = { 0, 0, 0, 0 };
SDL_Window *window = SDL_GetWindowFromID(windowId);
- if (window == NULL) {
+ if (!window) {
return;
}
diff --git a/src/test/SDL_test_compare.c b/src/test/SDL_test_compare.c
index b840880..d55d37a 100644
--- a/src/test/SDL_test_compare.c
+++ b/src/test/SDL_test_compare.c
@@ -70,7 +70,7 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
char referenceFilename[FILENAME_SIZE];
/* Validate input surfaces */
- if (surface == NULL || referenceSurface == NULL) {
+ if (!surface || !referenceSurface) {
return -1;
}
diff --git a/src/test/SDL_test_crc32.c b/src/test/SDL_test_crc32.c
index 453124b..4ad097f 100644
--- a/src/test/SDL_test_crc32.c
+++ b/src/test/SDL_test_crc32.c
@@ -36,7 +36,7 @@ int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext)
CrcUint32 c;
/* Sanity check context pointer */
- if (crcContext == NULL) {
+ if (!crcContext) {
return -1;
}
@@ -90,7 +90,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;
}
@@ -108,7 +108,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;
}
@@ -128,12 +128,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;
}
@@ -155,7 +155,7 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, C
int SDLTest_Crc32Done(SDLTest_Crc32Context *crcContext)
{
- if (crcContext == NULL) {
+ if (!crcContext) {
return -1;
}
diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c
index d3bdad6..57998fb 100644
--- a/src/test/SDL_test_font.c
+++ b/src/test/SDL_test_font.c
@@ -3166,14 +3166,14 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int 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;
@@ -3190,7 +3190,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c)
character = SDL_CreateRGBSurface(SDL_SWSURFACE,
charWidth, charHeight, 32,
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
- if (character == NULL) {
+ if (!character) {
return -1;
}
@@ -3358,7 +3358,7 @@ SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h)
{
SDLTest_TextWindow *textwin = (SDLTest_TextWindow *)SDL_malloc(sizeof(*textwin));
- if (textwin == NULL) {
+ if (!textwin) {
return NULL;
}
diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c
index 9e2e757..a26ca64 100644
--- a/src/test/SDL_test_fuzzer.c
+++ b/src/test/SDL_test_fuzzer.c
@@ -488,7 +488,7 @@ char *SDLTest_RandomAsciiStringOfSize(int size)
}
string = (char *)SDL_malloc((size + 1) * sizeof(char));
- if (string == NULL) {
+ if (!string) {
return NULL;
}
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 6141513..8f05c6d 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -64,7 +64,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;
@@ -108,17 +108,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;
}
@@ -139,7 +139,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;
@@ -171,7 +171,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;
}
@@ -229,7 +229,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;
}
@@ -402,9 +402,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;
}
@@ -445,20 +445,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;
@@ -471,7 +471,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;
@@ -487,7 +487,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);
}
@@ -511,7 +511,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' skipped\n",
@@ -540,7 +540,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' skipped\n",
@@ -562,7 +562,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);
}
diff --git a/src/test/SDL_test_md5.c b/src/test/SDL_test_md5.c
index 8e8cd49..2b7b505 100644
--- a/src/test/SDL_test_md5.c
+++ b/src/test/SDL_test_md5.c
@@ -113,7 +113,7 @@ static unsigned char MD5PADDING[64] = {
void SDLTest_Md5Init(SDLTest_Md5Context *mdContext)
{
- if (mdContext == NULL) {
+ if (!mdContext) {
return;
}
@@ -141,10 +141,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;
}
@@ -193,7 +193,7 @@ void SDLTest_Md5Final(SDLTest_Md5Context *mdContext)
unsigned int i, ii;
unsigned int padLen;
- if (mdContext == NULL) {
+ if (!mdContext) {
return;
}
diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c
index bb773a6..420762c 100644
--- a/src/test/SDL_test_memory.c
+++ b/src/test/SDL_test_memory.c
@@ -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 == NULL) {
+ if (!entry) {
return;
}
entry->mem = mem;
@@ -184,7 +184,7 @@ static void *SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size)
static void SDLCALL SDLTest_TrackedFree(void *ptr)
{
- if (ptr == NULL) {
+ if (!ptr) {
return;
}
diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c
index ab3fec5..d74dc65 100644
--- a/src/test/SDL_test_random.c
+++ b/src/test/SDL_test_random.c
@@ -40,7 +40,7 @@
void SDLTest_RandomInit(SDLTest_RandomContext *rndContext, unsigned int xi, unsigned int ci)
{
- if (rndContext == NULL) {
+ if (!rndContext) {
return;
}
@@ -68,7 +68,7 @@ void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext)
{
int a, b;
- if (rndContext == NULL) {
+ if (!rndContext) {
return;
}
@@ -85,7 +85,7 @@ unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext)
{
unsigned int xh, xl;
- if (rndContext == NULL) {
+ if (!rndContext) {
return -1;
}
diff --git a/test/checkkeys.c b/test/checkkeys.c
index 20ec8ef..c5059b7 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -269,14 +269,14 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("CheckKeys Test",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, 0);
- if (window == NULL) {
+ if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
SDL_GetError());
quit(2);
}
renderer = SDL_CreateRenderer(window, -1, 0);
- if (renderer == NULL) {
+ if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n",
SDL_GetError());
quit(2);
diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c
index dd85754..8afc46d 100644
--- a/test/checkkeysthreads.c
+++ b/test/checkkeysthreads.c
@@ -254,7 +254,7 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("CheckKeys Test",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, 0);
- if (window == NULL) {
+ if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
SDL_GetError());
quit(2);
diff --git a/test/controllermap.c b/test/controllermap.c
index cfb0eff..4f91588 100644
--- a/test/controllermap.c
+++ b/test/controllermap.c
@@ -288,7 +288,8 @@ ConfigureBinding(const SDL_GameControllerExtendedBind *pBinding)
SDL_Log("Configuring button binding for button %d\n", pBinding->value.button);
break;
case SDL_CONTROLLER_BINDTYPE_AXIS:
- SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, pBinding->committed ? "true" : "false");
+ SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max,
+ pBinding->committed ? "true" : "false");
break;
case SDL_CONTROLLER_BINDTYPE_HAT:
SDL_Log("Configuring hat binding for hat %d %d\n", pBinding->value.hat.hat, pBinding->value.hat.hat_mask);
@@ -729,13 +730,13 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
- if (window == NULL) {
+ if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return 2;
}
screen = SDL_CreateRenderer(window, -1, 0);
- if (screen == NULL) {
+ if (!screen) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
return 2;
}
@@ -766,7 +767,7 @@ int main(int argc, char *argv[])
name = SDL_JoystickNameForIndex(i);
SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
joystick = SDL_JoystickOpen(i);
- if (joystick == NULL) {
+ if (!joystick) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i,
SDL_GetError());
} else {
@@ -792,7 +793,7 @@ int main(int argc, char *argv[])
}
}
joystick = SDL_JoystickOpen(joystick_index);
- if (joystick == NULL) {
+ if (!joystick) {
SDL_Log("Couldn't open joystick %d: %s\n", joystick_index, SDL_GetError());
} else {
WatchJoystick(joystick);
diff --git a/test/loopwave.c b/test/loopwave.c
index 156767c..18bb0ad 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
- if (filename == NULL) {
+ if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
quit(1);
}
diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c
index 17bdc24..a5f039a 100644
--- a/test/loopwavequeue.c
+++ b/test/loopwavequeue.c
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
- if (filename == NULL) {
+ if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
quit(1);
}
diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c
index 1c4fba2..2a8e017 100644
--- a/test/testaudiohotplug.c
+++ b/test/testaudiohotplug.c
@@ -96,7 +96,7 @@ iteration()
int index = e.adevice.which;
int iscapture = e.adevice.iscapture;
const char *name = SDL_GetAudioDeviceName(index, iscapture);
- if (name != NULL) {
+ if (name) {
SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int)index, name);
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n",
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
- if (filename == NULL) {
+ if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
quit(1);
}
diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c
index ae59cbc..2e0f090 100644
--- a/test/testaudioinfo.c
+++ b/test/testaudioinfo.c
@@ -29,7 +29,7 @@ print_devices(int iscapture)
int i;
for (i = 0; i < n; i++) {
const char *name = SDL_GetAudioDeviceName(i, iscapture);
- if (name != NULL) {
+ if (name) {
SDL_Log(" %d: %s\n", i, name);
} else {
SDL_Log(" %d Error: %s\n", i, SDL_GetError());
@@ -81,7 +81,7 @@ int main(int argc, char **argv)
if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 0) < 0) {
SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
} else {
- SDL_Log("Default Output Name: %s\n", deviceName != NULL ? deviceName : "unknown");
+ SDL_Log("Default Output Name: %s\n", deviceName ? deviceName : "unknown");
SDL_free(deviceName);
SDL_Log("Sample Rate: %d\n", spec.freq);
SDL_Log("Channels: %d\n", spec.channels);
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 1) < 0) {
SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
} else {
- SDL_Log("Default Capture Name: %s\n", deviceName != NULL ? deviceName : "unknown");
+ SDL_Log("Default Capture Name: %s\n", deviceName ? deviceName : "unknown");
SDL_free(deviceName);
SDL_Log("Sample Rate: %d\n", spec.freq);
SDL_Log("Channels: %d\n", spec.channels);
diff --git a/test/testautomation.c b/test/testautomation.c
index 2150ed2..6f3448a 100644
--- a/test/testautomation.c
+++ b/test/testautomation.c
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
- if (state == NULL) {
+ if (!state) {
return 1;
}
diff --git a/test/testautomation_mouse.c b/test/testautomation_mouse.c
index 9fa7ef0..19b1a9f 100644
--- a/test/testautomation_mouse.c
+++ b/test/testautomation_mouse.c
@@ -423,7 +423,7 @@ SDL_Window *_createMouseSuiteTestWindow()
*/
void _destroyMouseSuiteTestWindow(SDL_Window *window)
{
- if (window != NULL) {
+ if (window) {
SDL_DestroyWindow(window);
window = NULL;
SDLTest_AssertPass("SDL_DestroyWindow()");
@@ -458,7 +458,7 @@ int mouse_warpMouseInWindow(void *arg)
yPositions[5] = h + 1;
/* Create test window */
window = _createMouseSuiteTestWindow();
- if (window == NULL) {
+ if (!window) {
return TEST_ABORTED;
}
@@ -511,7 +511,7 @@ int mouse_getMouseFocus(void *arg)
/* Create test window */
window = _createMouseSuiteTestWindow();
- if (window == NULL) {
+ if (!window) {
return TEST_ABORTED;
}
diff --git a/test/testautomation_render.c b/test/testautomation_render.c
index b035244..9cf48ef 100644
--- a/test/testautomation_render.c
+++ b/test/testautomation_render.c
@@ -65,13 +65,13 @@ void InitCreateRenderer(void *arg)
*/
void CleanupDestroyRenderer(void *arg)
{
- if (renderer != NULL) {
+ if (renderer) {
SDL_DestroyRenderer(renderer);
renderer = NULL;
SDLTest_AssertPass("SDL_DestroyRenderer()");
}
- if (window != NULL) {
+ if (window) {
SDL_DestroyWindow(window);
window = NULL;
SDLTest_AssertPass("SDL_DestroyWindow");
@@ -938,12 +938,12 @@ _loadTestFace(void)
SDL_Texture *tface;
face = SDLTest_ImageFace();
- if (face == NULL) {
+ if (!face) {
return NULL;
}
tface = SDL_CreateTextureFromSurface(renderer, face);
- if (tface == NULL) {
+ if (!tface) {
SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError());
}
@@ -970,7 +970,7 @@ _hasTexColor(void)
/* Get test face. */
tface = _loadTestFace();
- if (tface == NULL) {
+ if (!tface) {
return 0;
}
@@ -1014,7 +1014,7 @@ _hasTexAlpha(void)
/* Get test face. */
tface = _loadTestFace();
- if (tface == NULL) {
+ if (!tface) {
return 0;
}
diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c
index 5b681fc..9228b17 100644
--- a/test/testautomation_stdlib.c
+++ b/test/testautomation_stdlib.c
@@ -219,10 +219,10 @@ int stdlib_getsetenv(void *arg)
text = SDL_getenv(name);
SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
- if (text != NULL) {
+ if (text) {
SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, (int)SDL_strlen(text));
}
- } while (text != NULL);
+ } while (text);
/* Create random values to set */
value1 = SDLTest_RandomAsciiStringOfSize(10);
diff --git a/test/testautomation_video.c b/test/testautomation_video.c
index fb81cff..f340edc 100644
--- a/test/testautomation_video.c
+++ b/test/testautomation_video.c
@@ -78,7 +78,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title)
*/
void _destroyVideoSuiteTestWindow(SDL_Window *window)
{
- if (window != NULL) {
+ if (window) {
SDL_DestroyWindow(window);
window = NULL;
SDLTest_AssertPass("Call to SDL_DestroyWindow()");
@@ -608,7 +608,7 @@ int video_getWindowDisplayMode(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
- if (window != NULL) {
+ if (window) {
result = SDL_GetWindowDisplayMode(window, &mode);
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
@@ -702,7 +702,7 @@ video_getWindowGammaRamp(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
- if (window == NULL) return TEST_ABORTED;
+ if (!window) return TEST_ABORTED;
/* Retrieve no channel */
result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
@@ -856,7 +856,7 @@ int video_getSetWindowGrab(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
- if (window == NULL) {
+ if (!window) {
return TEST_ABORTED;
}
@@ -1019,7 +1019,7 @@ int video_getWindowId(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
- if (window == NULL) {
+ if (!window) {
return TEST_ABORTED;
}
@@ -1074,7 +1074,7 @@ int video_getWindowPixelFormat(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
- if (window == NULL) {
+ if (!window) {
return TEST_ABORTED;
}
@@ -
(Patch may be truncated, please check the link at the top of this post.)