[SDL2] pointer boolean (#8523)

This commit is contained in:
Sylvain Becker
2023-11-10 15:30:56 +01:00
committed by GitHub
parent 4a3a9f3ad8
commit a14b948b6c
394 changed files with 2564 additions and 2559 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -369,21 +369,21 @@ int surface_testCompleteSurfaceConversion(void *arg)
for (i = 0; i < SDL_arraysize(pixel_formats); ++i) {
for (j = 0; j < SDL_arraysize(pixel_formats); ++j) {
fmt1 = SDL_AllocFormat(pixel_formats[i]);
SDL_assert(fmt1 != NULL);
SDL_assert(fmt1);
cvt1 = SDL_ConvertSurface(face, fmt1, 0);
SDL_assert(cvt1 != NULL);
SDL_assert(cvt1);
fmt2 = SDL_AllocFormat(pixel_formats[j]);
SDL_assert(fmt1 != NULL);
SDL_assert(fmt1);
cvt2 = SDL_ConvertSurface(cvt1, fmt2, 0);
SDL_assert(cvt2 != NULL);
SDL_assert(cvt2);
if ( fmt1->BytesPerPixel == face->format->BytesPerPixel &&
fmt2->BytesPerPixel == face->format->BytesPerPixel &&
(fmt1->Amask != 0) == (face->format->Amask != 0) &&
(fmt2->Amask != 0) == (face->format->Amask != 0) ) {
final = SDL_ConvertSurface( cvt2, face->format, 0 );
SDL_assert(final != NULL);
SDL_assert(final);
/* Compare surface. */
ret = SDLTest_CompareSurfaces(face, final, 0);

View File

@@ -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;
}
@@ -1144,7 +1144,7 @@ int video_getSetWindowPosition(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
if (window == NULL) {
if (!window) {
return TEST_ABORTED;
}
@@ -1316,7 +1316,7 @@ int video_getSetWindowSize(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
if (window == NULL) {
if (!window) {
return TEST_ABORTED;
}
@@ -1499,7 +1499,7 @@ int video_getSetWindowMinimumSize(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
if (window == NULL) {
if (!window) {
return TEST_ABORTED;
}
@@ -1641,7 +1641,7 @@ int video_getSetWindowMaximumSize(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
if (window == NULL) {
if (!window) {
return TEST_ABORTED;
}
@@ -1779,30 +1779,30 @@ int video_getSetWindowData(void *arg)
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
if (window == NULL) {
if (!window) {
return TEST_ABORTED;
}
/* Create testdata */
datasize = SDLTest_RandomIntegerInRange(1, 32);
referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize);
if (referenceUserdata == NULL) {
if (!referenceUserdata) {
returnValue = TEST_ABORTED;
goto cleanup;
}
userdata = SDL_strdup(referenceUserdata);
if (userdata == NULL) {
if (!userdata) {
returnValue = TEST_ABORTED;
goto cleanup;
}
datasize = SDLTest_RandomIntegerInRange(1, 32);
referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize);
if (referenceUserdata2 == NULL) {
if (!referenceUserdata2) {
returnValue = TEST_ABORTED;
goto cleanup;
}
userdata2 = SDL_strdup(referenceUserdata2);
if (userdata2 == NULL) {
if (!userdata2) {
returnValue = TEST_ABORTED;
goto cleanup;
}

View File

@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {

View File

@@ -20,7 +20,7 @@
static void
print_mode(const char *prefix, const SDL_DisplayMode *mode)
{
if (mode == NULL) {
if (!mode) {
return;
}

View File

@@ -227,7 +227,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {

View File

@@ -106,13 +106,13 @@ int main(int argc, char *argv[])
/* Create window and renderer for given surface */
window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
if (window == NULL) {
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError());
return 1;
}
surface = SDL_GetWindowSurface(window);
renderer = SDL_CreateSoftwareRenderer(surface);
if (renderer == NULL) {
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n", SDL_GetError());
return 1;
}

View File

@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}

View File

@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
alive = 1;
thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
if (thread == NULL) {
if (!thread) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
quit(1);
}

View File

@@ -107,25 +107,25 @@ int main(int argc, char *argv[])
RWOP_ERR_QUIT(rwops);
}
rwops = SDL_RWFromFile(FBASENAME2, "wb");
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
rwops->close(rwops);
unlink(FBASENAME2);
rwops = SDL_RWFromFile(FBASENAME2, "wb+");
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
rwops->close(rwops);
unlink(FBASENAME2);
rwops = SDL_RWFromFile(FBASENAME2, "ab");
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
rwops->close(rwops);
unlink(FBASENAME2);
rwops = SDL_RWFromFile(FBASENAME2, "ab+");
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
rwops->close(rwops);
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
test : w mode, r mode, w+ mode
*/
rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (1 != rwops->write(rwops, "1234567890", 10, 1)) {
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
rwops->close(rwops);
rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) {
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
/* test 3: same with w+ mode */
rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (1 != rwops->write(rwops, "1234567890", 10, 1)) {
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
/* test 4: same in r+ mode */
rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (1 != rwops->write(rwops, "1234567890", 10, 1)) {
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
/* test5 : append mode */
rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */
if (rwops == NULL) {
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (1 != rwops->write(rwops, "1234567890", 10, 1)) {

View File

@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
}
base_path = SDL_GetBasePath();
if (base_path == NULL) {
if (!base_path) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n",
SDL_GetError());
} else {
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
}
pref_path = SDL_GetPrefPath("libsdl", "test_filesystem");
if (pref_path == NULL) {
if (!pref_path) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n",
SDL_GetError());
} else {
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
}
pref_path = SDL_GetPrefPath(NULL, "test_filesystem");
if (pref_path == NULL) {
if (!pref_path) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n",
SDL_GetError());
} else {

View File

@@ -109,7 +109,7 @@ static SDL_GameControllerButton virtual_button_active = SDL_CONTROLLER_BUTTON_IN
static void UpdateWindowTitle()
{
if (window == NULL) {
if (!window) {
return;
}
@@ -201,13 +201,13 @@ static void AddController(int device_index, SDL_bool verbose)
}
controller = SDL_GameControllerOpen(device_index);
if (controller == NULL) {
if (!controller) {
SDL_Log("Couldn't open controller: %s\n", SDL_GetError());
return;
}
controllers = (SDL_GameController **)SDL_realloc(gamecontrollers, (num_controllers + 1) * sizeof(*controllers));
if (controllers == NULL) {
if (!controllers) {
SDL_GameControllerClose(controller);
return;
}
@@ -413,7 +413,7 @@ static void OpenVirtualController()
SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError());
} else {
virtual_joystick = SDL_JoystickOpen(virtual_index);
if (virtual_joystick == NULL) {
if (!virtual_joystick) {
SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError());
}
}
@@ -624,7 +624,8 @@ void loop(void *arg)
if (event.type == SDL_CONTROLLERBUTTONDOWN) {
SetController(event.cbutton.which);
}
SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released");
SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button),
event.cbutton.state ? "pressed" : "released");
/* Cycle PS5 trigger effects when the microphone button is pressed */
if (event.type == SDL_CONTROLLERBUTTONDOWN &&
@@ -896,13 +897,13 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("Game Controller Test", 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());
SDL_DestroyWindow(window);
return 2;
@@ -920,7 +921,7 @@ int main(int argc, char *argv[])
button_texture = LoadTexture(screen, "button.bmp", SDL_TRUE, NULL, NULL);
axis_texture = LoadTexture(screen, "axis.bmp", SDL_TRUE, NULL, NULL);
if (background_front == NULL || background_back == NULL || button_texture == NULL || axis_texture == NULL) {
if (!background_front || !background_back || !button_texture || !axis_texture) {
SDL_DestroyRenderer(screen);
SDL_DestroyWindow(window);
return 2;

View File

@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
@@ -216,7 +216,7 @@ int main(int argc, char *argv[])
/* Create the windows, initialize the renderers, and load the textures */
sprites =
(SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites));
if (sprites == NULL) {
if (!sprites) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}

View File

@@ -131,7 +131,7 @@ DrawScreen(SDL_Window *window)
SDL_Surface *screen = SDL_GetWindowSurface(window);
int i;
if (screen == NULL) {
if (!screen) {
return;
}
@@ -272,7 +272,7 @@ loop(void)
int main(int argc, char *argv[])
{
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}

View File

@@ -226,7 +226,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {

View File

@@ -34,7 +34,7 @@ quit(int rc)
{
int i;
if (context != NULL) {
if (context) {
for (i = 0; i < state->num_windows; i++) {
if (context[i]) {
SDL_GL_DeleteContext(context[i]);
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
}
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (context == NULL) {
if (!context) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}

View File

@@ -96,7 +96,7 @@ quit(int rc)
{
int i;
if (context != NULL) {
if (context) {
for (i = 0; i < state->num_windows; i++) {
if (context[i]) {
SDL_GL_DeleteContext(context[i]);
@@ -636,7 +636,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
@@ -696,7 +696,7 @@ int main(int argc, char *argv[])
}
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (context == NULL) {
if (!context) {
SDL_Log("Out of memory!\n");
quit(2);
}

View File

@@ -94,7 +94,7 @@ quit(int rc)
{
int i;
if (context != NULL) {
if (context) {
for (i = 0; i < state->num_windows; i++) {
if (context[i]) {
SDL_GL_DeleteContext(context[i]);
@@ -445,7 +445,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
@@ -502,7 +502,7 @@ int main(int argc, char *argv[])
}
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (context == NULL) {
if (!context) {
SDL_Log("Out of memory!\n");
quit(2);
}
@@ -543,17 +543,17 @@ int main(int argc, char *argv[])
#if 1
path = GetNearbyFilename(f);
if (path == NULL) {
if (!path) {
path = SDL_strdup(f);
}
if (path == NULL) {
if (!path) {
SDL_Log("out of memory\n");
exit(-1);
}
tmp = SDL_LoadBMP(path);
if (tmp == NULL) {
if (!tmp) {
SDL_Log("missing image file: %s", path);
exit(-1);
} else {

View File

@@ -69,7 +69,7 @@ int main(int argc, char **argv)
SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
if (SDL_NumHaptics() > 0) {
/* We'll just use index or the first force feedback device found */
if (name == NULL) {
if (!name) {
i = (index != -1) ? index : 0;
}
/* Try to find matching device */
@@ -88,7 +88,7 @@ int main(int argc, char **argv)
}
haptic = SDL_HapticOpen(i);
if (haptic == NULL) {
if (!haptic) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
SDL_GetError());
return 1;
@@ -279,7 +279,7 @@ int main(int argc, char **argv)
}
/* Quit */
if (haptic != NULL) {
if (haptic) {
SDL_HapticClose(haptic);
}
SDL_Quit();

View File

@@ -106,7 +106,7 @@ int main(int argc, char **argv)
if (e.key.keysym.sym == SDLK_ESCAPE) {
done = 1;
} else if (e.key.keysym.sym == SDLK_x) {
if (areas == NULL) {
if (!areas) {
areas = drag_areas;
numareas = SDL_arraysize(drag_areas);
} else {

View File

@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
keepGoing = SDL_FALSE;
break;
case SDL_JOYDEVICEADDED:
if (joystick != NULL) {
if (joystick) {
SDL_Log("Only one joystick supported by this test\n");
} else {
joystick = SDL_JoystickOpen(event.jdevice.which);

View File

@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
fname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "utf8.txt");
file = fopen(fname, "rb");
if (file == NULL) {
if (!file) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", fname);
return 1;
}

View File

@@ -97,7 +97,7 @@ static Uint8 validate_hex(const char *cp, size_t len, Uint32 *np)
}
n = (n << 4) | c;
}
if (np != NULL) {
if (np) {
*np = n;
}
return 1;
@@ -116,7 +116,7 @@ static int unifont_init(const char *fontname)
/* Allocate memory for the glyph data so the file can be closed after initialization. */
unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize);
if (unifontGlyph == NULL) {
if (!unifontGlyph) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.\n", (int)(unifontGlyphSize + 1023) / 1024);
return -1;
}
@@ -124,20 +124,20 @@ static int unifont_init(const char *fontname)
/* Allocate memory for texture pointers for all renderers. */
unifontTexture = (SDL_Texture **)SDL_malloc(unifontTextureSize);
if (unifontTexture == NULL) {
if (!unifontTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.\n", (int)(unifontTextureSize + 1023) / 1024);
return -1;
}
SDL_memset(unifontTexture, 0, unifontTextureSize);
filename = GetResourceFilename(NULL, fontname);
if (filename == NULL) {
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
return -1;
}
hexFile = SDL_RWFromFile(filename, "rb");
SDL_free(filename);
if (hexFile == NULL) {
if (!hexFile) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname);
return -1;
}
@@ -269,7 +269,7 @@ static int unifont_load_texture(Uint32 textureID)
}
textureRGBA = (Uint8 *)SDL_malloc(UNIFONT_TEXTURE_SIZE);
if (textureRGBA == NULL) {
if (!textureRGBA) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.\n", UNIFONT_TEXTURE_SIZE / 1024 / 1024);
return -1;
}
@@ -324,7 +324,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst
}
}
texture = unifontTexture[UNIFONT_NUM_TEXTURES * rendererID + textureID];
if (texture != NULL) {
if (texture) {
const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE;
srcrect.x = cInTex % UNIFONT_GLYPHS_IN_ROW * 16;
srcrect.y = cInTex / UNIFONT_GLYPHS_IN_ROW * 16;
@@ -338,12 +338,12 @@ static void unifont_cleanup()
int i, j;
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];
if (state->windows[i] == NULL || renderer == NULL) {
if (state->windows[i] == NULL || !renderer) {
continue;
}
for (j = 0; j < UNIFONT_NUM_TEXTURES; j++) {
SDL_Texture *tex = unifontTexture[UNIFONT_NUM_TEXTURES * i + j];
if (tex != NULL) {
if (tex) {
SDL_DestroyTexture(tex);
}
}
@@ -530,7 +530,7 @@ void _Redraw(int rendererID)
if (cursor) {
char *p = utf8_advance(markedText, cursor);
char c = 0;
if (p == NULL) {
if (!p) {
p = &markedText[SDL_strlen(markedText)];
}
@@ -626,7 +626,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc; i++) {
@@ -660,7 +660,7 @@ int main(int argc, char *argv[])
TTF_Init();
font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
if (font == NULL) {
if (!font) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
return -1;
}

View File

@@ -289,7 +289,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {

View File

@@ -117,7 +117,7 @@ void loop(void *arg)
case SDL_JOYDEVICEADDED:
SDL_Log("Joystick device %d added.\n", (int)event.jdevice.which);
if (joystick == NULL) {
if (!joystick) {
joystick = SDL_JoystickOpen(event.jdevice.which);
if (joystick) {
PrintJoystick(joystick);
@@ -296,13 +296,13 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("Joystick Test", 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 SDL_FALSE;
}
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());
SDL_DestroyWindow(window);
return SDL_FALSE;

View File

@@ -53,13 +53,13 @@ int main(int argc, char *argv[])
}
lib = SDL_LoadObject(libname);
if (lib == NULL) {
if (!lib) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
libname, SDL_GetError());
retval = 3;
} else {
fn = (fntype)SDL_LoadFunction(lib, symname);
if (fn == NULL) {
if (!fn) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
symname, SDL_GetError());
retval = 4;

View File

@@ -17,7 +17,7 @@
static void log_locales(void)
{
SDL_Locale *locales = SDL_GetPreferredLocales();
if (locales == NULL) {
if (!locales) {
SDL_Log("Couldn't determine locales: %s", SDL_GetError());
} else {
SDL_Locale *l;

View File

@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
SDL_AtomicSet(&doterminate, 0);
mutex = SDL_CreateMutex();
if (mutex == NULL) {
if (!mutex) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
exit(1);
}

View File

@@ -83,7 +83,7 @@ void DrawObject(SDL_Renderer *renderer, Object *object)
void DrawObjects(SDL_Renderer *renderer)
{
Object *next = objects;
while (next != NULL) {
while (next) {
DrawObject(renderer, next);
next = next->next;
}
@@ -93,7 +93,7 @@ void AppendObject(Object *object)
{
if (objects) {
Object *next = objects;
while (next->next != NULL) {
while (next->next) {
next = next->next;
}
next->next = object;
@@ -130,7 +130,7 @@ void loop(void *arg)
break;
case SDL_MOUSEMOTION:
if (active == NULL) {
if (!active) {
break;
}
@@ -139,7 +139,7 @@ void loop(void *arg)
break;
case SDL_MOUSEBUTTONDOWN:
if (active == NULL) {
if (!active) {
active = SDL_calloc(1, sizeof(*active));
active->x1 = active->x2 = event.button.x;
active->y1 = active->y2 = event.button.y;
@@ -173,7 +173,7 @@ void loop(void *arg)
break;
case SDL_MOUSEBUTTONUP:
if (active == NULL) {
if (!active) {
break;
}
@@ -266,13 +266,13 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("Mouse Test", 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 SDL_FALSE;
}
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());
SDL_DestroyWindow(window);
return SDL_FALSE;

View File

@@ -47,7 +47,7 @@ static void
quit(int rc)
{
SDL_VideoQuit();
if (native_window != NULL && factory != NULL) {
if (native_window && factory) {
factory->DestroyNativeWindow(native_window);
}
exit(rc);
@@ -119,19 +119,19 @@ int main(int argc, char *argv[])
break;
}
}
if (factory == NULL) {
if (!factory) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n",
driver);
quit(2);
}
SDL_Log("Creating native window for %s driver\n", driver);
native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H);
if (native_window == NULL) {
if (!native_window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n");
quit(3);
}
window = SDL_CreateWindowFrom(native_window);
if (window == NULL) {
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError());
quit(4);
}
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
/* Create the renderer */
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(5);
}
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
SDL_RenderClear(renderer);
sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, NULL, NULL);
if (sprite == NULL) {
if (!sprite) {
quit(6);
}
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h);
positions = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
velocities = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
if (positions == NULL || velocities == NULL) {
if (!positions || !velocities) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}

View File

@@ -66,7 +66,7 @@ CreateWindowNative(int w, int h)
CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL),
NULL);
if (hwnd == NULL) {
if (!hwnd) {
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;

View File

@@ -115,14 +115,14 @@ int main(int argc, char *argv[])
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, 0);
if (window == NULL) {
if (!window) {
SDL_Log("Couldn't create window: %s\n", SDL_GetError());
return SDL_FALSE;
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
if (!renderer) {
SDL_Log("Couldn't create renderer: %s\n",
SDL_GetError());
return SDL_FALSE;

View File

@@ -311,21 +311,21 @@ int main(int argc, char **argv)
}
RawMooseData = (Uint8 *)SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
if (RawMooseData == NULL) {
if (!RawMooseData) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
quit(1);
}
/* load the trojan moose images */
filename = GetResourceFilename(NULL, "moose.dat");
if (filename == NULL) {
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
SDL_free(RawMooseData);
return -1;
}
handle = SDL_RWFromFile(filename, "rb");
SDL_free(filename);
if (handle == NULL) {
if (!handle) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
SDL_free(RawMooseData);
quit(2);
@@ -343,21 +343,21 @@ int main(int argc, char **argv)
SDL_WINDOWPOS_UNDEFINED,
window_w, window_h,
SDL_WINDOW_RESIZABLE);
if (window == NULL) {
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
SDL_free(RawMooseData);
quit(4);
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
SDL_free(RawMooseData);
quit(4);
}
MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (MooseTexture == NULL) {
if (!MooseTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
SDL_free(RawMooseData);
quit(5);

View File

@@ -366,7 +366,7 @@ int Test64Bit(SDL_bool verbose)
LL_Test *t;
int failed = 0;
for (t = LL_Tests; t->routine != NULL; t++) {
for (t = LL_Tests; t->routine; t++) {
unsigned long long result = 0;
unsigned int *al = (unsigned int *)&t->a;
unsigned int *bl = (unsigned int *)&t->b;

View File

@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc; ++i) {

View File

@@ -121,7 +121,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}

View File

@@ -138,7 +138,7 @@ Draw(DrawState *s)
SDL_RenderGetViewport(s->renderer, &viewport);
target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h);
if (target == NULL) {
if (!target) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError());
return SDL_FALSE;
}
@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc;) {

View File

@@ -57,7 +57,7 @@ int main(int argc, char **argv)
cvt.len = len;
cvt.buf = (Uint8 *)SDL_malloc((size_t)len * cvt.len_mult);
if (cvt.buf == NULL) {
if (!cvt.buf) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
SDL_FreeWAV(data);
SDL_Quit();
@@ -75,7 +75,7 @@ int main(int argc, char **argv)
/* write out a WAV header... */
io = SDL_RWFromFile(argv[2], "wb");
if (io == NULL) {
if (!io) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
SDL_free(cvt.buf);
SDL_FreeWAV(data);

View File

@@ -71,7 +71,7 @@ int main(int argc, char **argv)
SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
if (SDL_NumHaptics() > 0) {
/* We'll just use index or the first force feedback device found */
if (name == NULL) {
if (!name) {
i = (index != -1) ? index : 0;
}
/* Try to find matching device */
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
}
haptic = SDL_HapticOpen(i);
if (haptic == NULL) {
if (!haptic) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
SDL_GetError());
return 1;
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
SDL_Delay(2000);
/* Quit */
if (haptic != NULL) {
if (haptic) {
SDL_HapticClose(haptic);
}
SDL_Quit();

View File

@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}

View File

@@ -36,7 +36,7 @@ static const char *GetSensorTypeString(SDL_SensorType type)
static void HandleSensorEvent(SDL_SensorEvent *event)
{
SDL_Sensor *sensor = SDL_SensorFromInstanceID(event->which);
if (sensor == NULL) {
if (!sensor) {
SDL_Log("Couldn't get sensor for sensor event\n");
return;
}
@@ -78,7 +78,7 @@ int main(int argc, char **argv)
if (SDL_SensorGetDeviceType(i) != SDL_SENSOR_UNKNOWN) {
SDL_Sensor *sensor = SDL_SensorOpen(i);
if (sensor == NULL) {
if (!sensor) {
SDL_Log("Couldn't open sensor %" SDL_PRIs32 ": %s\n", SDL_SensorGetDeviceInstanceID(i), SDL_GetError());
} else {
++num_opened;

View File

@@ -135,7 +135,7 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source)
glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
info = (char *)SDL_malloc((size_t)length + 1);
if (info == NULL) {
if (!info) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
} else {
glGetInfoLogARB(shader, length, NULL, info);
@@ -163,7 +163,7 @@ static SDL_bool LinkProgram(ShaderData *data)
glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
info = (char *)SDL_malloc((size_t)length + 1);
if (info == NULL) {
if (!info) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
} else {
glGetInfoLogARB(data->program, length, NULL, info);
@@ -329,7 +329,7 @@ SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord)
0x00FF0000, 0x0000FF00, 0x000000FF
#endif
);
if (image == NULL) {
if (!image) {
return 0;
}
@@ -462,7 +462,7 @@ int main(int argc, char **argv)
/* Create a 640x480 OpenGL screen */
window = SDL_CreateWindow("Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL);
if (window == NULL) {
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
@@ -475,7 +475,7 @@ int main(int argc, char **argv)
}
surface = SDL_LoadBMP("icon.bmp");
if (surface == NULL) {
if (!surface) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
SDL_Quit();
exit(3);

View File

@@ -71,7 +71,7 @@ int main(int argc, char **argv)
num_pictures = argc - 1;
pictures = (LoadedPicture *)SDL_malloc(sizeof(LoadedPicture) * num_pictures);
if (pictures == NULL) {
if (!pictures) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate memory.");
exit(1);
}
@@ -106,7 +106,7 @@ int main(int argc, char **argv)
SHAPED_WINDOW_DIMENSION, SHAPED_WINDOW_DIMENSION,
0);
SDL_SetWindowPosition(window, SHAPED_WINDOW_X, SHAPED_WINDOW_Y);
if (window == NULL) {
if (!window) {
for (i = 0; i < num_pictures; i++) {
SDL_FreeSurface(pictures[i].surface);
}
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
exit(-4);
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
if (!renderer) {
SDL_DestroyWindow(window);
for (i = 0; i < num_pictures; i++) {
SDL_FreeSurface(pictures[i].surface);

View File

@@ -453,7 +453,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
@@ -541,7 +541,7 @@ int main(int argc, char *argv[])
/* Create the windows, initialize the renderers, and load the textures */
sprites =
(SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites));
if (sprites == NULL) {
if (!sprites) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
@@ -557,7 +557,7 @@ int main(int argc, char *argv[])
/* Allocate memory for the sprite info */
positions = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect));
velocities = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect));
if (positions == NULL || velocities == NULL) {
if (!positions || !velocities) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}

View File

@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h);
if (sprite == NULL) {
if (!sprite) {
quit(2);
}

View File

@@ -141,13 +141,13 @@ int main(int argc, char **argv)
/* load the moose images */
filename = GetResourceFilename(NULL, "moose.dat");
if (filename == NULL) {
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
return -1;
}
handle = SDL_RWFromFile(filename, "rb");
SDL_free(filename);
if (handle == NULL) {
if (!handle) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
quit(2);
}
@@ -160,19 +160,19 @@ int main(int argc, char **argv)
SDL_WINDOWPOS_UNDEFINED,
MOOSEPIC_W * 4, MOOSEPIC_H * 4,
SDL_WINDOW_RESIZABLE);
if (window == NULL) {
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
quit(3);
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
quit(4);
}
MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (MooseTexture == NULL) {
if (!MooseTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
quit(5);
}

View File

@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
alive = 1;
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
if (thread == NULL) {
if (!thread) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
quit(1);
}
@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
alive = 1;
(void)signal(SIGTERM, killed);
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
if (thread == NULL) {
if (!thread) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
quit(1);
}

View File

@@ -28,13 +28,13 @@ GetNearbyFilename(const char *file)
base = SDL_GetBasePath();
if (base != NULL) {
if (base) {
SDL_RWops *rw;
size_t len = SDL_strlen(base) + SDL_strlen(file) + 1;
path = SDL_malloc(len);
if (path == NULL) {
if (!path) {
SDL_free(base);
SDL_OutOfMemory();
return NULL;
@@ -54,7 +54,7 @@ GetNearbyFilename(const char *file)
}
path = SDL_strdup(file);
if (path == NULL) {
if (!path) {
SDL_OutOfMemory();
}
return path;
@@ -72,10 +72,10 @@ GetNearbyFilename(const char *file)
char *
GetResourceFilename(const char *user_specified, const char *def)
{
if (user_specified != NULL) {
if (user_specified) {
char *ret = SDL_strdup(user_specified);
if (ret == NULL) {
if (!ret) {
SDL_OutOfMemory();
}
@@ -105,12 +105,12 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent,
path = GetNearbyFilename(file);
if (path != NULL) {
if (path) {
file = path;
}
temp = SDL_LoadBMP(file);
if (temp == NULL) {
if (!temp) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
} else {
/* Set transparent pixel as the pixel at (0,0) */
@@ -137,16 +137,16 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent,
}
}
if (width_out != NULL) {
if (width_out) {
*width_out = temp->w;
}
if (height_out != NULL) {
if (height_out) {
*height_out = temp->h;
}
texture = SDL_CreateTextureFromSurface(renderer, temp);
if (texture == NULL) {
if (!texture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
}
}

View File

@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
@@ -180,7 +180,7 @@ int main(int argc, char *argv[])
sprite = LoadTexture(state->renderers[0], "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h);
if (sprite == NULL) {
if (!sprite) {
quit(2);
}

View File

@@ -236,7 +236,7 @@ static void createInstance(void)
quit(2);
}
extensions = (const char **)SDL_malloc(sizeof(const char *) * extensionCount);
if (extensions == NULL) {
if (!extensions) {
SDL_OutOfMemory();
quit(2);
}
@@ -312,7 +312,7 @@ static void findPhysicalDevice(void)
quit(2);
}
physicalDevices = (VkPhysicalDevice *)SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
if (physicalDevices == NULL) {
if (!physicalDevices) {
SDL_OutOfMemory();
quit(2);
}
@@ -346,7 +346,7 @@ static void findPhysicalDevice(void)
SDL_free(queueFamiliesProperties);
queueFamiliesPropertiesAllocatedSize = queueFamiliesCount;
queueFamiliesProperties = (VkQueueFamilyProperties *)SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize);
if (queueFamiliesProperties == NULL) {
if (!queueFamiliesProperties) {
SDL_free(physicalDevices);
SDL_free(deviceExtensions);
SDL_OutOfMemory();
@@ -408,7 +408,7 @@ static void findPhysicalDevice(void)
SDL_free(deviceExtensions);
deviceExtensionsAllocatedSize = deviceExtensionCount;
deviceExtensions = SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize);
if (deviceExtensions == NULL) {
if (!deviceExtensions) {
SDL_free(physicalDevices);
SDL_free(queueFamiliesProperties);
SDL_OutOfMemory();
@@ -929,7 +929,7 @@ static void initVulkan(void)
SDL_Vulkan_LoadLibrary(NULL);
vulkanContexts = (VulkanContext *)SDL_calloc(state->num_windows, sizeof(VulkanContext));
if (vulkanContexts == NULL) {
if (!vulkanContexts) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
quit(2);
}
@@ -1092,7 +1092,7 @@ int main(int argc, char **argv)
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}

View File

@@ -208,7 +208,7 @@ void loop()
}
if (event.type == SDL_MOUSEBUTTONUP) {
SDL_Window *window = SDL_GetMouseFocus();
if (highlighted_mode != -1 && window != NULL) {
if (highlighted_mode != -1 && window) {
const int display_index = SDL_GetWindowDisplayIndex(window);
SDL_DisplayMode mode;
if (0 != SDL_GetDisplayMode(display_index, highlighted_mode, &mode)) {
@@ -223,7 +223,7 @@ void loop()
for (i = 0; i < state->num_windows; ++i) {
SDL_Window *window = state->windows[i];
SDL_Renderer *renderer = state->renderers[i];
if (window != NULL && renderer != NULL) {
if (window && renderer) {
int y = 0;
SDL_Rect viewport, menurect;
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}

View File

@@ -75,7 +75,7 @@ static SDL_bool verify_yuv_data(Uint32 format, const Uint8 *yuv, int yuv_pitch,
SDL_bool result = SDL_FALSE;
rgb = (Uint8 *)SDL_malloc(size);
if (rgb == NULL) {
if (!rgb) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory");
return SDL_FALSE;
}
@@ -126,7 +126,7 @@ static int run_automated_tests(int pattern_size, int extra_pitch)
int yuv1_pitch, yuv2_pitch;
int result = -1;
if (pattern == NULL || yuv1 == NULL || yuv2 == NULL) {
if (!pattern || !yuv1 || !yuv2) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate test surfaces");
goto done;
}
@@ -327,7 +327,7 @@ int main(int argc, char **argv)
filename = "testyuv.bmp";
}
original = SDL_ConvertSurfaceFormat(SDL_LoadBMP(filename), SDL_PIXELFORMAT_RGB24, 0);
if (original == NULL) {
if (!original) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
return 3;
}
@@ -339,7 +339,7 @@ int main(int argc, char **argv)
pitch = CalculateYUVPitch(yuv_format, original->w);
converted = SDL_CreateRGBSurfaceWithFormat(0, original->w, original->h, 0, rgb_format);
if (converted == NULL) {
if (!converted) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError());
return 3;
}
@@ -356,13 +356,13 @@ int main(int argc, char **argv)
SDL_WINDOWPOS_UNDEFINED,
original->w, original->h,
0);
if (window == NULL) {
if (!window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return 4;
}
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());
return 4;
}