From a14b948b6ca6def59099b212733edb28b97ff327 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Fri, 10 Nov 2023 15:30:56 +0100 Subject: [PATCH] [SDL2] pointer boolean (#8523) --- VisualC-GDK/tests/testgdk/src/testgdk.cpp | 6 +- Xcode-iOS/Demos/src/accelerometer.c | 10 +- Xcode-iOS/Demos/src/fireworks.c | 2 +- Xcode-iOS/Demos/src/happy.c | 4 +- Xcode-iOS/Demos/src/keyboard.c | 4 +- Xcode-iOS/Demos/src/rectangles.c | 4 +- Xcode-iOS/Demos/src/touch.c | 4 +- cmake/test/main_gui.c | 2 +- src/SDL.c | 2 +- src/SDL_assert.c | 16 +- src/SDL_dataqueue.c | 30 ++-- src/SDL_error.c | 2 +- src/SDL_guid.c | 2 +- src/SDL_hints.c | 32 ++-- src/SDL_list.c | 4 +- src/SDL_log.c | 12 +- src/atomic/SDL_spinlock.c | 2 +- src/audio/SDL_audio.c | 2 +- src/audio/SDL_audiocvt.c | 36 ++-- src/audio/SDL_audiodev.c | 6 +- src/audio/SDL_wave.c | 36 ++-- src/audio/aaudio/SDL_aaudio.c | 24 +-- src/audio/alsa/SDL_alsa_audio.c | 40 ++--- src/audio/android/SDL_androidaudio.c | 16 +- src/audio/arts/SDL_artsaudio.c | 10 +- src/audio/directsound/SDL_directsound.c | 18 +- src/audio/disk/SDL_diskaudio.c | 14 +- src/audio/dsp/SDL_dspaudio.c | 8 +- src/audio/emscripten/SDL_emscriptenaudio.c | 4 +- src/audio/esd/SDL_esdaudio.c | 10 +- src/audio/fusionsound/SDL_fsaudio.c | 10 +- src/audio/haiku/SDL_haikuaudio.cc | 2 +- src/audio/jack/SDL_jackaudio.c | 12 +- src/audio/n3ds/SDL_n3dsaudio.c | 6 +- src/audio/nacl/SDL_naclaudio.c | 4 +- src/audio/nas/SDL_nasaudio.c | 14 +- src/audio/netbsd/SDL_netbsdaudio.c | 8 +- src/audio/openslES/SDL_openslES.c | 6 +- src/audio/os2/SDL_os2audio.c | 6 +- src/audio/paudio/SDL_paudio.c | 12 +- src/audio/pipewire/SDL_pipewire.c | 78 ++++----- src/audio/ps2/SDL_ps2audio.c | 6 +- src/audio/psp/SDL_pspaudio.c | 6 +- src/audio/pulseaudio/SDL_pulseaudio.c | 58 +++---- src/audio/qsa/SDL_qsa_audio.c | 8 +- src/audio/sndio/SDL_sndioaudio.c | 22 +-- src/audio/sun/SDL_sunaudio.c | 10 +- src/audio/vita/SDL_vitaaudio.c | 6 +- src/audio/wasapi/SDL_wasapi.c | 18 +- src/audio/wasapi/SDL_wasapi_win32.c | 4 +- src/audio/wasapi/SDL_wasapi_winrt.cpp | 2 +- src/audio/winmm/SDL_winmm.c | 8 +- src/core/android/SDL_android.c | 46 ++--- src/core/freebsd/SDL_evdev_kbd_freebsd.c | 10 +- src/core/linux/SDL_dbus.c | 20 +-- src/core/linux/SDL_evdev.c | 38 ++-- src/core/linux/SDL_evdev_kbd.c | 18 +- src/core/linux/SDL_fcitx.c | 2 +- src/core/linux/SDL_ibus.c | 30 ++-- src/core/linux/SDL_ime.c | 6 +- src/core/linux/SDL_threadprio.c | 10 +- src/core/linux/SDL_udev.c | 88 +++++----- src/core/openbsd/SDL_wscons_kbd.c | 8 +- src/core/openbsd/SDL_wscons_mouse.c | 4 +- src/core/os2/geniconv/os2cp.c | 4 +- src/core/os2/geniconv/os2iconv.c | 8 +- src/core/os2/geniconv/sys2utf8.c | 2 +- src/core/windows/SDL_hid.c | 6 +- src/core/windows/SDL_immdevice.c | 12 +- src/core/windows/SDL_windows.c | 2 +- src/core/windows/SDL_xinput.c | 4 +- src/core/winrt/SDL_winrtapp_direct3d.cpp | 2 +- src/cpuinfo/SDL_cpuinfo.c | 2 +- src/dynapi/SDL_dynapi.c | 6 +- src/events/SDL_displayevents.c | 2 +- src/events/SDL_gesture.c | 14 +- src/events/SDL_keyboard.c | 10 +- src/events/SDL_mouse.c | 30 ++-- src/events/SDL_touch.c | 16 +- src/events/SDL_windowevents.c | 2 +- src/file/SDL_rwops.c | 34 ++-- src/file/n3ds/SDL_rwopsromfs.c | 2 +- src/filesystem/android/SDL_sysfilesystem.c | 2 +- src/filesystem/emscripten/SDL_sysfilesystem.c | 6 +- src/filesystem/gdk/SDL_sysfilesystem.cpp | 6 +- src/filesystem/haiku/SDL_sysfilesystem.cc | 10 +- src/filesystem/n3ds/SDL_sysfilesystem.c | 4 +- src/filesystem/ps2/SDL_sysfilesystem.c | 4 +- src/filesystem/psp/SDL_sysfilesystem.c | 4 +- src/filesystem/riscos/SDL_sysfilesystem.c | 24 +-- src/filesystem/unix/SDL_sysfilesystem.c | 42 ++--- src/filesystem/vita/SDL_sysfilesystem.c | 6 +- src/filesystem/windows/SDL_sysfilesystem.c | 10 +- src/filesystem/winrt/SDL_sysfilesystem.cpp | 16 +- src/haptic/SDL_haptic.c | 8 +- src/haptic/android/SDL_syshaptic.c | 24 +-- src/haptic/darwin/SDL_syshaptic.c | 40 ++--- src/haptic/linux/SDL_syshaptic.c | 30 ++-- src/haptic/windows/SDL_dinputhaptic.c | 36 ++-- src/haptic/windows/SDL_windowshaptic.c | 10 +- src/haptic/windows/SDL_xinputhaptic.c | 14 +- src/hidapi/SDL_hidapi.c | 21 ++- src/joystick/SDL_gamecontroller.c | 112 ++++++------ src/joystick/SDL_joystick.c | 18 +- src/joystick/android/SDL_sysjoystick.c | 26 +-- src/joystick/bsd/SDL_bsdjoystick.c | 30 ++-- src/joystick/darwin/SDL_iokitjoystick.c | 20 +-- src/joystick/emscripten/SDL_sysjoystick.c | 20 +-- src/joystick/hidapi/SDL_hidapi_gamecube.c | 6 +- src/joystick/hidapi/SDL_hidapi_luna.c | 4 +- src/joystick/hidapi/SDL_hidapi_ps3.c | 10 +- src/joystick/hidapi/SDL_hidapi_ps4.c | 4 +- src/joystick/hidapi/SDL_hidapi_ps5.c | 4 +- src/joystick/hidapi/SDL_hidapi_rumble.c | 2 +- src/joystick/hidapi/SDL_hidapi_shield.c | 6 +- src/joystick/hidapi/SDL_hidapi_stadia.c | 4 +- src/joystick/hidapi/SDL_hidapi_steam.c | 4 +- src/joystick/hidapi/SDL_hidapi_switch.c | 8 +- src/joystick/hidapi/SDL_hidapi_wii.c | 4 +- src/joystick/hidapi/SDL_hidapi_xbox360.c | 4 +- src/joystick/hidapi/SDL_hidapi_xbox360w.c | 4 +- src/joystick/hidapi/SDL_hidapi_xboxone.c | 18 +- src/joystick/hidapi/SDL_hidapijoystick.c | 24 +-- src/joystick/linux/SDL_sysjoystick.c | 90 +++++----- src/joystick/os2/SDL_os2joystick.c | 2 +- src/joystick/virtual/SDL_virtualjoystick.c | 24 +-- src/joystick/windows/SDL_dinputjoystick.c | 18 +- src/joystick/windows/SDL_rawinputjoystick.c | 10 +- .../windows/SDL_windows_gaming_input.c | 8 +- src/joystick/windows/SDL_windowsjoystick.c | 14 +- src/joystick/windows/SDL_xinputjoystick.c | 4 +- src/loadso/dlopen/SDL_sysloadso.c | 8 +- src/loadso/os2/SDL_sysloadso.c | 2 +- src/loadso/windows/SDL_sysloadso.c | 8 +- src/locale/SDL_locale.c | 4 +- src/locale/unix/SDL_syslocale.c | 6 +- src/locale/windows/SDL_syslocale.c | 6 +- src/main/haiku/SDL_BeApp.cc | 6 +- src/main/ngage/SDL_ngage_main.cpp | 2 +- src/main/windows/SDL_windows_main.c | 6 +- src/misc/SDL_url.c | 2 +- src/misc/windows/SDL_sysurl.c | 2 +- src/power/SDL_power.c | 4 +- src/power/linux/SDL_syspower.c | 10 +- src/render/SDL_render.c | 152 ++++++++-------- src/render/SDL_yuv_sw.c | 2 +- src/render/direct3d/SDL_render_d3d.c | 44 ++--- src/render/direct3d11/SDL_render_d3d11.c | 42 ++--- src/render/direct3d11/SDL_render_winrt.cpp | 2 +- src/render/direct3d12/SDL_render_d3d12.c | 34 ++-- src/render/opengl/SDL_render_gl.c | 32 ++-- src/render/opengl/SDL_shaders_gl.c | 2 +- src/render/opengles/SDL_render_gles.c | 22 +-- src/render/opengles2/SDL_render_gles2.c | 40 ++--- src/render/ps2/SDL_render_ps2.c | 16 +- src/render/psp/SDL_render_psp.c | 42 ++--- src/render/software/SDL_blendfillrect.c | 6 +- src/render/software/SDL_blendline.c | 8 +- src/render/software/SDL_blendpoint.c | 6 +- src/render/software/SDL_drawline.c | 8 +- src/render/software/SDL_drawpoint.c | 4 +- src/render/software/SDL_render_sw.c | 68 ++++---- src/render/software/SDL_rotate.c | 6 +- src/render/software/SDL_triangle.c | 6 +- src/render/vitagxm/SDL_render_vita_gxm.c | 24 +-- .../vitagxm/SDL_render_vita_gxm_memory.c | 8 +- .../vitagxm/SDL_render_vita_gxm_tools.c | 6 +- src/sensor/SDL_sensor.c | 4 +- src/sensor/android/SDL_androidsensor.c | 10 +- src/sensor/vita/SDL_vitasensor.c | 4 +- src/sensor/windows/SDL_windowssensor.c | 8 +- src/stdlib/SDL_getenv.c | 22 +-- src/stdlib/SDL_iconv.c | 28 +-- src/stdlib/SDL_string.c | 10 +- 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 | 6 +- src/test/SDL_test_random.c | 6 +- src/thread/SDL_thread.c | 34 ++-- src/thread/generic/SDL_syscond.c | 6 +- src/thread/generic/SDL_sysmutex.c | 2 +- src/thread/generic/SDL_syssem.c | 8 +- src/thread/n3ds/SDL_syscond.c | 8 +- src/thread/n3ds/SDL_sysmutex.c | 2 +- src/thread/n3ds/SDL_syssem.c | 10 +- src/thread/n3ds/SDL_systhread.c | 2 +- src/thread/ngage/SDL_syssem.cpp | 10 +- src/thread/os2/SDL_syssem.c | 8 +- src/thread/os2/SDL_systhread.c | 2 +- src/thread/os2/SDL_systls.c | 6 +- src/thread/ps2/SDL_syssem.c | 10 +- src/thread/psp/SDL_syscond.c | 6 +- src/thread/psp/SDL_sysmutex.c | 2 +- src/thread/psp/SDL_syssem.c | 10 +- src/thread/pthread/SDL_syscond.c | 8 +- src/thread/pthread/SDL_sysmutex.c | 2 +- src/thread/pthread/SDL_syssem.c | 14 +- src/thread/pthread/SDL_systhread.c | 4 +- src/thread/stdcpp/SDL_syscond.cpp | 6 +- src/thread/stdcpp/SDL_sysmutex.cpp | 4 +- src/thread/vita/SDL_syscond.c | 10 +- src/thread/vita/SDL_sysmutex.c | 8 +- src/thread/vita/SDL_syssem.c | 10 +- src/thread/windows/SDL_syscond_cv.c | 16 +- src/thread/windows/SDL_sysmutex.c | 12 +- src/thread/windows/SDL_syssem.c | 26 +-- src/thread/windows/SDL_systhread.c | 8 +- src/timer/SDL_timer.c | 8 +- src/video/SDL_RLEaccel.c | 14 +- src/video/SDL_blit.c | 6 +- src/video/SDL_blit_A.c | 6 +- src/video/SDL_blit_N.c | 8 +- src/video/SDL_bmp.c | 8 +- src/video/SDL_clipboard.c | 20 +-- src/video/SDL_egl.c | 50 +++--- src/video/SDL_fillrect.c | 14 +- src/video/SDL_pixels.c | 36 ++-- src/video/SDL_rect.c | 4 +- src/video/SDL_rect_impl.h | 32 ++-- src/video/SDL_shape.c | 20 +-- src/video/SDL_surface.c | 72 ++++---- src/video/SDL_video.c | 162 +++++++++--------- src/video/SDL_vulkan_utils.c | 14 +- src/video/SDL_yuv.c | 10 +- src/video/android/SDL_androidkeyboard.c | 2 +- src/video/android/SDL_androidmouse.c | 8 +- src/video/android/SDL_androidtouch.c | 2 +- src/video/android/SDL_androidvideo.c | 4 +- src/video/android/SDL_androidvulkan.c | 6 +- src/video/android/SDL_androidwindow.c | 4 +- src/video/directfb/SDL_DirectFB_WM.c | 8 +- src/video/directfb/SDL_DirectFB_dyn.c | 2 +- src/video/directfb/SDL_DirectFB_events.c | 4 +- src/video/directfb/SDL_DirectFB_opengl.c | 16 +- src/video/directfb/SDL_DirectFB_shape.c | 4 +- src/video/dummy/SDL_nullframebuffer.c | 4 +- src/video/dummy/SDL_nullvideo.c | 2 +- src/video/emscripten/SDL_emscriptenevents.c | 4 +- .../emscripten/SDL_emscriptenframebuffer.c | 4 +- src/video/emscripten/SDL_emscriptenmouse.c | 8 +- src/video/emscripten/SDL_emscriptenvideo.c | 4 +- src/video/haiku/SDL_bclipboard.cc | 2 +- src/video/haiku/SDL_bframebuffer.cc | 2 +- src/video/haiku/SDL_bmessagebox.cc | 8 +- src/video/haiku/SDL_bopengl.cc | 8 +- src/video/haiku/SDL_bvideo.cc | 8 +- src/video/haiku/SDL_bwindow.cc | 2 +- src/video/kmsdrm/SDL_kmsdrmdyn.c | 12 +- src/video/kmsdrm/SDL_kmsdrmmouse.c | 14 +- src/video/kmsdrm/SDL_kmsdrmopengles.c | 2 +- src/video/kmsdrm/SDL_kmsdrmvideo.c | 38 ++-- src/video/kmsdrm/SDL_kmsdrmvulkan.c | 6 +- src/video/n3ds/SDL_n3dsframebuffer.c | 4 +- src/video/n3ds/SDL_n3dsvideo.c | 10 +- src/video/ngage/SDL_ngageframebuffer.cpp | 4 +- src/video/ngage/SDL_ngagevideo.cpp | 4 +- src/video/ngage/SDL_ngagewindow.cpp | 2 +- .../offscreen/SDL_offscreenframebuffer.c | 4 +- src/video/offscreen/SDL_offscreenvideo.c | 2 +- src/video/offscreen/SDL_offscreenwindow.c | 2 +- src/video/os2/SDL_os2dive.c | 8 +- src/video/os2/SDL_os2messagebox.c | 20 +-- src/video/os2/SDL_os2mouse.c | 10 +- src/video/os2/SDL_os2util.c | 2 +- src/video/os2/SDL_os2video.c | 82 ++++----- src/video/os2/SDL_os2vman.c | 22 +-- src/video/pandora/SDL_pandora.c | 22 +-- src/video/ps2/SDL_ps2video.c | 2 +- src/video/psp/SDL_pspvideo.c | 10 +- src/video/qnx/gl.c | 2 +- src/video/qnx/video.c | 4 +- src/video/raspberry/SDL_rpimouse.c | 26 +-- src/video/raspberry/SDL_rpivideo.c | 8 +- src/video/riscos/SDL_riscosframebuffer.c | 4 +- src/video/riscos/SDL_riscosmodes.c | 12 +- src/video/riscos/SDL_riscosvideo.c | 4 +- src/video/riscos/SDL_riscoswindow.c | 4 +- src/video/vita/SDL_vitaframebuffer.c | 2 +- src/video/vita/SDL_vitagl_pvr.c | 4 +- src/video/vita/SDL_vitagles_pvr.c | 4 +- src/video/vita/SDL_vitakeyboard.c | 2 +- src/video/vita/SDL_vitamouse.c | 2 +- src/video/vita/SDL_vitatouch.c | 2 +- src/video/vita/SDL_vitavideo.c | 10 +- src/video/vivante/SDL_vivantevideo.c | 10 +- src/video/vivante/SDL_vivantevulkan.c | 6 +- src/video/wayland/SDL_waylandclipboard.c | 28 +-- src/video/wayland/SDL_waylanddatamanager.c | 84 ++++----- src/video/wayland/SDL_waylanddyn.c | 12 +- src/video/wayland/SDL_waylandevents.c | 118 ++++++------- src/video/wayland/SDL_waylandkeyboard.c | 12 +- src/video/wayland/SDL_waylandmessagebox.c | 14 +- src/video/wayland/SDL_waylandmouse.c | 26 +-- src/video/wayland/SDL_waylandtouch.c | 2 +- src/video/wayland/SDL_waylandtouch.h | 2 +- src/video/wayland/SDL_waylandvideo.c | 28 +-- src/video/wayland/SDL_waylandvulkan.c | 6 +- src/video/wayland/SDL_waylandwindow.c | 58 +++---- src/video/windows/SDL_windowsclipboard.c | 2 +- src/video/windows/SDL_windowsevents.c | 12 +- src/video/windows/SDL_windowsframebuffer.c | 2 +- src/video/windows/SDL_windowskeyboard.c | 20 +-- src/video/windows/SDL_windowsmessagebox.c | 32 ++-- src/video/windows/SDL_windowsmodes.c | 18 +- src/video/windows/SDL_windowsmouse.c | 4 +- src/video/windows/SDL_windowsopengl.c | 14 +- src/video/windows/SDL_windowsopengles.c | 4 +- src/video/windows/SDL_windowsshape.c | 14 +- src/video/windows/SDL_windowsvideo.c | 10 +- src/video/windows/SDL_windowsvulkan.c | 6 +- src/video/windows/SDL_windowswindow.c | 14 +- src/video/winrt/SDL_winrtgamebar.cpp | 6 +- src/video/winrt/SDL_winrtvideo.cpp | 8 +- src/video/x11/SDL_x11clipboard.c | 2 +- src/video/x11/SDL_x11dyn.c | 12 +- src/video/x11/SDL_x11events.c | 12 +- src/video/x11/SDL_x11framebuffer.c | 4 +- src/video/x11/SDL_x11keyboard.c | 2 +- src/video/x11/SDL_x11messagebox.c | 20 +-- src/video/x11/SDL_x11modes.c | 34 ++-- src/video/x11/SDL_x11mouse.c | 10 +- src/video/x11/SDL_x11shape.c | 12 +- src/video/x11/SDL_x11video.c | 12 +- src/video/x11/SDL_x11vulkan.c | 8 +- src/video/x11/SDL_x11window.c | 28 +-- src/video/x11/SDL_x11xfixes.c | 2 +- src/video/x11/SDL_x11xinput2.c | 18 +- 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_surface.c | 10 +- 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 +- 394 files changed, 2564 insertions(+), 2559 deletions(-) diff --git a/VisualC-GDK/tests/testgdk/src/testgdk.cpp b/VisualC-GDK/tests/testgdk/src/testgdk.cpp index 6aea4cc3e..fd86d628c 100644 --- a/VisualC-GDK/tests/testgdk/src/testgdk.cpp +++ b/VisualC-GDK/tests/testgdk/src/testgdk.cpp @@ -383,7 +383,7 @@ main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO); - if (state == NULL) { + if (!state) { return 1; } @@ -446,7 +446,7 @@ 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); } @@ -461,7 +461,7 @@ main(int argc, char *argv[]) soundname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav"); - if (soundname == NULL) { + if (!soundname) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); quit(1); } diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index 3ce812513..4c166a621 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -118,7 +118,7 @@ initializeTextures(SDL_Renderer *renderer) /* load the ship */ bmp_surface = SDL_LoadBMP("ship.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not ship.bmp"); } /* set blue to transparent on the ship */ @@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer) /* create ship texture from surface */ ship = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (ship == NULL) { + if (!ship) { fatalError("could not create ship texture"); } SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND); @@ -140,12 +140,12 @@ initializeTextures(SDL_Renderer *renderer) /* load the space background */ bmp_surface = SDL_LoadBMP("space.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load space.bmp"); } /* create space texture from surface */ space = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (space == NULL) { + if (!space) { fatalError("could not create space texture"); } SDL_FreeSurface(bmp_surface); @@ -179,7 +179,7 @@ main(int argc, char *argv[]) printf("There are %d joysticks available\n", SDL_NumJoysticks()); printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0)); accelerometer = SDL_JoystickOpen(0); - if (accelerometer == NULL) { + if (!accelerometer) { fatalError("Could not open joystick (accelerometer)"); } printf("joystick number of axis = %d\n", diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c index eb3bb4cde..a9af3fb58 100644 --- a/Xcode-iOS/Demos/src/fireworks.c +++ b/Xcode-iOS/Demos/src/fireworks.c @@ -334,7 +334,7 @@ initializeTexture() to format passed into OpenGL */ bmp_surface = SDL_LoadBMP("stroke.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load stroke.bmp"); } diff --git a/Xcode-iOS/Demos/src/happy.c b/Xcode-iOS/Demos/src/happy.c index 42562007e..163d3463f 100644 --- a/Xcode-iOS/Demos/src/happy.c +++ b/Xcode-iOS/Demos/src/happy.c @@ -108,7 +108,7 @@ initializeTexture(SDL_Renderer *renderer) SDL_Surface *bmp_surface; /* load the bmp */ bmp_surface = SDL_LoadBMP("icon.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load bmp"); } /* set white to transparent on the happyface */ @@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer) /* convert RGBA surface to texture */ texture = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (texture == NULL) { + if (!texture) { fatalError("could not create texture"); } SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c index 6ab1db213..4d630bae5 100644 --- a/Xcode-iOS/Demos/src/keyboard.c +++ b/Xcode-iOS/Demos/src/keyboard.c @@ -165,7 +165,7 @@ loadFont(void) { SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp"); - if (surface == NULL) { + if (!surface) { printf("Error loading bitmap: %s\n", SDL_GetError()); return 0; } else { @@ -183,7 +183,7 @@ loadFont(void) SDL_BlitSurface(surface, NULL, converted, NULL); /* create our texture */ texture = SDL_CreateTextureFromSurface(renderer, converted); - if (texture == NULL) { + if (!texture) { printf("texture creation failed: %s\n", SDL_GetError()); } else { /* set blend mode for our texture */ diff --git a/Xcode-iOS/Demos/src/rectangles.c b/Xcode-iOS/Demos/src/rectangles.c index 9102cf279..a08f99790 100644 --- a/Xcode-iOS/Demos/src/rectangles.c +++ b/Xcode-iOS/Demos/src/rectangles.c @@ -58,11 +58,11 @@ main(int argc, char *argv[]) /* create window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI); - if (window == NULL) { + if (!window) { fatalError("Could not initialize Window"); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { fatalError("Could not create renderer"); } diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c index 22a251be1..4b7ff9548 100644 --- a/Xcode-iOS/Demos/src/touch.c +++ b/Xcode-iOS/Demos/src/touch.c @@ -57,13 +57,13 @@ initializeTexture(SDL_Renderer *renderer) { SDL_Surface *bmp_surface; bmp_surface = SDL_LoadBMP("stroke.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load stroke.bmp"); } brush = SDL_CreateTextureFromSurface(renderer, bmp_surface); SDL_FreeSurface(bmp_surface); - if (brush == NULL) { + if (!brush) { fatalError("could not create brush texture"); } /* additive blending -- laying strokes on top of eachother makes them brighter */ diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c index 4ffe9be1c..ca2d92ecd 100644 --- a/cmake/test/main_gui.c +++ b/cmake/test/main_gui.c @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { 640, 480, SDL_WINDOW_SHOWN ); - if (window == NULL) { + if (!window) { fprintf(stderr, "could not create window: %s\n", SDL_GetError()); return 1; } diff --git a/src/SDL.c b/src/SDL.c index da3a4ccce..14dbd0326 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -533,7 +533,7 @@ void SDL_GetVersion(SDL_version *ver) static SDL_bool check_hint = SDL_TRUE; static SDL_bool legacy_version = SDL_FALSE; - if (ver == NULL) { + if (!ver) { return; } diff --git a/src/SDL_assert.c b/src/SDL_assert.c index fe7619be1..57cd47762 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -114,11 +114,11 @@ static void SDL_GenerateAssertionReport(void) const SDL_assert_data *item = triggered_assertions; /* only do this if the app hasn't assigned an assertion handler. */ - if ((item != NULL) && (assertion_handler != SDL_PromptAssertion)) { + if ((item) && (assertion_handler != SDL_PromptAssertion)) { debug_print("\n\nSDL assertion report.\n"); debug_print("All SDL assertions between last init/quit:\n\n"); - while (item != NULL) { + while (item) { debug_print( "'%s'\n" " * %s (%s:%d)\n" @@ -206,7 +206,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, /* let env. variable override, so unit tests won't block in a GUI. */ envr = SDL_getenv("SDL_ASSERT"); - if (envr != NULL) { + if (envr) { if (message != stack_buf) { SDL_free(message); } @@ -342,9 +342,9 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co #ifndef SDL_THREADS_DISABLED static SDL_SpinLock spinlock = 0; SDL_AtomicLock(&spinlock); - if (assertion_mutex == NULL) { /* never called SDL_Init()? */ + if (!assertion_mutex) { /* never called SDL_Init()? */ assertion_mutex = SDL_CreateMutex(); - if (assertion_mutex == NULL) { + if (!assertion_mutex) { SDL_AtomicUnlock(&spinlock); return SDL_ASSERTION_IGNORE; /* oh well, I guess. */ } @@ -409,7 +409,7 @@ void SDL_AssertionsQuit(void) #if SDL_ASSERT_LEVEL > 0 SDL_GenerateAssertionReport(); #ifndef SDL_THREADS_DISABLED - if (assertion_mutex != NULL) { + if (assertion_mutex) { SDL_DestroyMutex(assertion_mutex); assertion_mutex = NULL; } @@ -437,7 +437,7 @@ void SDL_ResetAssertionReport(void) { SDL_assert_data *next = NULL; SDL_assert_data *item; - for (item = triggered_assertions; item != NULL; item = next) { + for (item = triggered_assertions; item; item = next) { next = (SDL_assert_data *)item->next; item->always_ignore = SDL_FALSE; item->trigger_count = 0; @@ -454,7 +454,7 @@ SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void) SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata) { - if (userdata != NULL) { + if (userdata) { *userdata = assertion_userdata; } return assertion_handler; diff --git a/src/SDL_dataqueue.c b/src/SDL_dataqueue.c index 2019c3083..4176f1361 100644 --- a/src/SDL_dataqueue.c +++ b/src/SDL_dataqueue.c @@ -54,7 +54,7 @@ SDL_DataQueue *SDL_NewDataQueue(const size_t _packetlen, const size_t initialsla { SDL_DataQueue *queue = (SDL_DataQueue *)SDL_calloc(1, sizeof(SDL_DataQueue)); - if (queue == NULL) { + if (!queue) { SDL_OutOfMemory(); } else { const size_t packetlen = _packetlen ? _packetlen : 1024; @@ -101,7 +101,7 @@ void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack) SDL_DataQueuePacket *prev = NULL; size_t i; - if (queue == NULL) { + if (!queue) { return; } @@ -144,16 +144,16 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue) { SDL_DataQueuePacket *packet; - SDL_assert(queue != NULL); + SDL_assert(queue); packet = queue->pool; - if (packet != NULL) { + if (packet) { /* we have one available in the pool. */ queue->pool = packet->next; } else { /* Have to allocate a new one! */ packet = (SDL_DataQueuePacket *)SDL_malloc(sizeof(SDL_DataQueuePacket) + queue->packet_size); - if (packet == NULL) { + if (!packet) { return NULL; } } @@ -163,7 +163,7 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue) packet->next = NULL; SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); - if (queue->tail == NULL) { + if (!queue->tail) { queue->head = packet; } else { queue->tail->next = packet; @@ -182,7 +182,7 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _ size_t origlen; size_t datalen; - if (queue == NULL) { + if (!queue) { return SDL_InvalidParamError("queue"); } @@ -194,13 +194,13 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _ while (len > 0) { SDL_DataQueuePacket *packet = queue->tail; - SDL_assert(packet == NULL || (packet->datalen <= packet_size)); - if (packet == NULL || (packet->datalen >= packet_size)) { + SDL_assert(!packet || (packet->datalen <= packet_size)); + if (!packet || (packet->datalen >= packet_size)) { /* tail packet missing or completely full; we need a new packet. */ packet = AllocateDataQueuePacket(queue); - if (packet == NULL) { + if (!packet) { /* uhoh, reset so we've queued nothing new, free what we can. */ - if (origtail == NULL) { + if (!origtail) { packet = queue->head; /* whole queue. */ } else { packet = origtail->next; /* what we added to existing queue. */ @@ -238,7 +238,7 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) Uint8 *ptr = buf; SDL_DataQueuePacket *packet; - if (queue == NULL) { + if (!queue) { return 0; } @@ -267,7 +267,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) Uint8 *ptr = buf; SDL_DataQueuePacket *packet; - if (queue == NULL) { + if (!queue) { return 0; } @@ -286,7 +286,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) if (packet->startpos == packet->datalen) { /* packet is done, put it in the pool. */ queue->head = packet->next; - SDL_assert((packet->next != NULL) || (packet == queue->tail)); + SDL_assert((packet->next) || (packet == queue->tail)); packet->next = queue->pool; queue->pool = packet; } @@ -294,7 +294,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); - if (queue->head == NULL) { + if (!queue->head) { queue->tail = NULL; /* in case we drained the queue entirely. */ } diff --git a/src/SDL_error.c b/src/SDL_error.c index 501d39584..336c7fcda 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -28,7 +28,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { /* Ignore call if invalid format pointer was passed */ - if (fmt != NULL) { + if (fmt) { va_list ap; int result; SDL_error *error = SDL_GetErrBuf(); diff --git a/src/SDL_guid.c b/src/SDL_guid.c index f8c4c6008..d8d20cddd 100644 --- a/src/SDL_guid.c +++ b/src/SDL_guid.c @@ -29,7 +29,7 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) static const char k_rgchHexToASCII[] = "0123456789abcdef"; int i; - if ((pszGUID == NULL) || (cbGUID <= 0)) { + if ((!pszGUID) || (cbGUID <= 0)) { return; } diff --git a/src/SDL_hints.c b/src/SDL_hints.c index ceec0d5fb..88f112258 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -51,7 +51,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr SDL_Hint *hint; SDL_HintWatch *entry; - if (name == NULL) { + if (!name) { return SDL_FALSE; } @@ -66,7 +66,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr return SDL_FALSE; } if (hint->value != value && - (value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) { + (!value || !hint->value || SDL_strcmp(hint->value, value) != 0)) { for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; @@ -83,7 +83,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr /* Couldn't find the hint, add a new one */ hint = (SDL_Hint *)SDL_malloc(sizeof(*hint)); - if (hint == NULL) { + if (!hint) { return SDL_FALSE; } hint->name = SDL_strdup(name); @@ -101,16 +101,16 @@ SDL_bool SDL_ResetHint(const char *name) SDL_Hint *hint; SDL_HintWatch *entry; - if (name == NULL) { + if (!name) { return SDL_FALSE; } env = SDL_getenv(name); for (hint = SDL_hints; hint; hint = hint->next) { if (SDL_strcmp(name, hint->name) == 0) { - if ((env == NULL && hint->value != NULL) || - (env != NULL && hint->value == NULL) || - (env != NULL && SDL_strcmp(env, hint->value) != 0)) { + if ((!env && hint->value) || + (env && !hint->value) || + (env && SDL_strcmp(env, hint->value) != 0)) { for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; @@ -135,9 +135,9 @@ void SDL_ResetHints(void) for (hint = SDL_hints; hint; hint = hint->next) { env = SDL_getenv(hint->name); - if ((env == NULL && hint->value != NULL) || - (env != NULL && hint->value == NULL) || - (env != NULL && SDL_strcmp(env, hint->value) != 0)) { + if ((!env && hint->value) || + (env && !hint->value) || + (env && SDL_strcmp(env, hint->value) != 0)) { for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; @@ -164,7 +164,7 @@ const char *SDL_GetHint(const char *name) env = SDL_getenv(name); for (hint = SDL_hints; hint; hint = hint->next) { if (SDL_strcmp(name, hint->name) == 0) { - if (env == NULL || hint->priority == SDL_HINT_OVERRIDE) { + if (!env || hint->priority == SDL_HINT_OVERRIDE) { return hint->value; } break; @@ -175,7 +175,7 @@ const char *SDL_GetHint(const char *name) SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value) { - if (value == NULL || !*value) { + if (!value || !*value) { return default_value; } if (*value == '0' || SDL_strcasecmp(value, "false") == 0) { @@ -196,7 +196,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user SDL_HintWatch *entry; const char *value; - if (name == NULL || !*name) { + if (!name || !*name) { SDL_InvalidParamError("name"); return; } @@ -208,7 +208,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user SDL_DelHintCallback(name, callback, userdata); entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return; } @@ -220,10 +220,10 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user break; } } - if (hint == NULL) { + if (!hint) { /* Need to add a hint entry for this watcher */ hint = (SDL_Hint *)SDL_malloc(sizeof(*hint)); - if (hint == NULL) { + if (!hint) { SDL_OutOfMemory(); SDL_free(entry); return; diff --git a/src/SDL_list.c b/src/SDL_list.c index b08919642..e1c22e1ee 100644 --- a/src/SDL_list.c +++ b/src/SDL_list.c @@ -28,7 +28,7 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent) { SDL_ListNode *node = SDL_malloc(sizeof(*node)); - if (node == NULL) { + if (!node) { return SDL_OutOfMemory(); } @@ -44,7 +44,7 @@ void SDL_ListPop(SDL_ListNode **head, void **ent) SDL_ListNode **ptr = head; /* Invalid or empty */ - if (head == NULL || *head == NULL) { + if (!head || !*head) { return; } diff --git a/src/SDL_log.c b/src/SDL_log.c index ab6e7c2cb..7fd79378f 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -106,7 +106,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { void SDL_LogInit(void) { - if (log_function_mutex == NULL) { + if (!log_function_mutex) { /* if this fails we'll try to continue without it. */ log_function_mutex = SDL_CreateMutex(); } @@ -299,7 +299,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va return; } - if (log_function_mutex == NULL) { + if (!log_function_mutex) { /* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */ log_function_mutex = SDL_CreateMutex(); } @@ -317,7 +317,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) { /* Allocate exactly what we need, including the zero-terminator */ message = (char *)SDL_malloc(len_plus_term); - if (message == NULL) { + if (!message) { return; } va_copy(aq, ap); @@ -453,7 +453,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority { FILE *pFile; pFile = fopen("SDL_Log.txt", "a"); - if (pFile != NULL) { + if (pFile) { (void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); (void)fclose(pFile); } @@ -462,7 +462,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority { FILE *pFile; pFile = fopen("ux0:/data/SDL_Log.txt", "a"); - if (pFile != NULL) { + if (pFile) { (void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); (void)fclose(pFile); } @@ -471,7 +471,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority { FILE *pFile; pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a"); - if (pFile != NULL) { + if (pFile) { (void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); (void)fclose(pFile); } diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 9fd3e6167..81ff24392 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -67,7 +67,7 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock) /* Terrible terrible damage */ static SDL_mutex *_spinlock_mutex; - if (_spinlock_mutex == NULL) { + if (!_spinlock_mutex) { /* Race condition on first lock... */ _spinlock_mutex = SDL_CreateMutex(); } diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 60242e60a..8480698fe 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -962,7 +962,7 @@ int SDL_AudioInit(const char *driver_name) } } - driver_attempt = (driver_attempt_end != NULL) ? (driver_attempt_end + 1) : NULL; + driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL; } } else { for (i = 0; (!initialized) && (bootstrap[i]); ++i) { diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index ed4333eca..bf6665df5 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -266,7 +266,7 @@ int SDL_ConvertAudio(SDL_AudioCVT *cvt) /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */ /* Make sure there's data to convert */ - if (cvt->buf == NULL) { + if (!cvt->buf) { return SDL_SetError("No buffer allocated for conversion"); } @@ -517,7 +517,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF /* we keep no streaming state here, so pad with silence on both ends. */ padding = (float *)SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof(float)); - if (padding == NULL) { + if (!padding) { SDL_OutOfMemory(); return; } @@ -614,7 +614,7 @@ static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, } filter = ChooseCVTResampler(dst_channels); - if (filter == NULL) { + if (!filter) { return SDL_SetError("No conversion available for these rates"); } @@ -687,7 +687,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_AudioFilter channel_converter = NULL; /* Sanity check target pointer */ - if (cvt == NULL) { + if (!cvt) { return SDL_InvalidParamError("cvt"); } @@ -782,7 +782,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0])); channel_converter = channel_converters[src_channels - 1][dst_channels - 1]; - if ((channel_converter == NULL) != (src_channels == dst_channels)) { + if ((!channel_converter) != (src_channels == dst_channels)) { /* All combinations of supported channel counts should have been handled by now, but let's be defensive */ return SDL_SetError("Invalid channel combination"); } else if (channel_converter != NULL) { @@ -878,7 +878,7 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen) ptr = stream->work_buffer_base; } else { ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, (size_t)newlen + 32); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); return NULL; } @@ -950,12 +950,12 @@ static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream) if (SRC_available) { state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result); - if (state == NULL) { + if (!state) { SDL_SetError("src_new() failed: %s", SRC_src_strerror(result)); } } - if (state == NULL) { + if (!state) { SDL_CleanupAudioStreamResampler_SRC(stream); return SDL_FALSE; } @@ -1027,7 +1027,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, } retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream)); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -1053,7 +1053,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels; retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float)); - if (retval->resampler_padding == NULL) { + if (!retval->resampler_padding) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); return NULL; @@ -1062,7 +1062,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->staging_buffer_size = ((retval->resampler_padding_samples / retval->pre_resample_channels) * retval->src_sample_frame_size); if (retval->staging_buffer_size > 0) { retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size); - if (retval->staging_buffer == NULL) { + if (!retval->staging_buffer) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); return NULL; @@ -1169,7 +1169,7 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, #endif workbuf = EnsureStreamBufferSize(stream, workbuflen); - if (workbuf == NULL) { + if (!workbuf) { return -1; /* probably out of memory. */ } @@ -1260,10 +1260,10 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } - if (buf == NULL) { + if (!buf) { return SDL_InvalidParamError("buf"); } if (len == 0) { @@ -1315,7 +1315,7 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) int SDL_AudioStreamFlush(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } @@ -1373,10 +1373,10 @@ int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } - if (buf == NULL) { + if (!buf) { return SDL_InvalidParamError("buf"); } if (len <= 0) { @@ -1397,7 +1397,7 @@ int SDL_AudioStreamAvailable(SDL_AudioStream *stream) void SDL_AudioStreamClear(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { SDL_InvalidParamError("stream"); } else { SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2); diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index ac35cb265..fb2fb9904 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -81,16 +81,16 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla const char *audiodev; char audiopath[1024]; - if (test == NULL) { + if (!test) { test = test_stub; } /* Figure out what our audio device is */ audiodev = SDL_getenv("SDL_PATH_DSP"); - if (audiodev == NULL) { + if (!audiodev) { audiodev = SDL_getenv("AUDIODEV"); } - if (audiodev == NULL) { + if (!audiodev) { if (classic) { audiodev = _PATH_DEV_AUDIO; } else { diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 209a577c0..5504b257b 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -264,7 +264,7 @@ static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, U int res; dumpstr = SDL_malloc(bufsize); - if (dumpstr == NULL) { + if (!dumpstr) { return; } dumpstr[0] = 0; @@ -441,7 +441,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength) coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4); file->decoderdata = coeffdata; /* Freed in cleanup. */ - if (coeffdata == NULL) { + if (!coeffdata) { return SDL_OutOfMemory(); } coeffdata->coeff = &coeffdata->aligndummy; @@ -684,7 +684,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) state.output.pos = 0; state.output.size = outputsize / sizeof(Sint16); state.output.data = (Sint16 *)SDL_calloc(1, outputsize); - if (state.output.data == NULL) { + if (!state.output.data) { return SDL_OutOfMemory(); } @@ -1075,12 +1075,12 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len state.output.pos = 0; state.output.size = outputsize / sizeof(Sint16); state.output.data = (Sint16 *)SDL_malloc(outputsize); - if (state.output.data == NULL) { + if (!state.output.data) { return SDL_OutOfMemory(); } cstate = (Sint8 *)SDL_calloc(state.channels, sizeof(Sint8)); - if (cstate == NULL) { + if (!cstate) { SDL_free(state.output.data); return SDL_OutOfMemory(); } @@ -1235,7 +1235,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) /* 1 to avoid allocating zero bytes, to keep static analysis happy. */ src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1); - if (src == NULL) { + if (!src) { return SDL_OutOfMemory(); } chunk->data = NULL; @@ -1366,7 +1366,7 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 * /* 1 to avoid allocating zero bytes, to keep static analysis happy. */ ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1); - if (ptr == NULL) { + if (!ptr) { return SDL_OutOfMemory(); } @@ -1442,7 +1442,7 @@ static WaveRiffSizeHint WaveGetRiffSizeHint() { const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "force") == 0) { return RiffSizeForce; } else if (SDL_strcmp(hint, "ignore") == 0) { @@ -1461,7 +1461,7 @@ static WaveTruncationHint WaveGetTruncationHint() { const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "verystrict") == 0) { return TruncVeryStrict; } else if (SDL_strcmp(hint, "strict") == 0) { @@ -1480,7 +1480,7 @@ static WaveFactChunkHint WaveGetFactChunkHint() { const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "truncate") == 0) { return FactTruncate; } else if (SDL_strcmp(hint, "strict") == 0) { @@ -1497,7 +1497,7 @@ static WaveFactChunkHint WaveGetFactChunkHint() static void WaveFreeChunkData(WaveChunk *chunk) { - if (chunk->data != NULL) { + if (chunk->data) { SDL_free(chunk->data); chunk->data = NULL; } @@ -1546,7 +1546,7 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len if (length > 0) { chunk->data = (Uint8 *)SDL_malloc(length); - if (chunk->data == NULL) { + if (!chunk->data) { return SDL_OutOfMemory(); } @@ -1612,7 +1612,7 @@ static int WaveReadFormat(WaveFile *file) return SDL_SetError("Data of WAVE fmt chunk too big"); } fmtsrc = SDL_RWFromConstMem(chunk->data, (int)chunk->size); - if (fmtsrc == NULL) { + if (!fmtsrc) { return SDL_OutOfMemory(); } @@ -1787,7 +1787,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 * SDL_zero(datachunk); envchunkcountlimit = SDL_getenv("SDL_WAVE_CHUNK_LIMIT"); - if (envchunkcountlimit != NULL) { + if (envchunkcountlimit) { unsigned int count; if (SDL_sscanf(envchunkcountlimit, "%u", &count) == 1) { chunkcountlimit = count <= SDL_MAX_UINT32 ? count : SDL_MAX_UINT32; @@ -2085,16 +2085,16 @@ SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, SDL_zero(file); /* Make sure we are passed a valid data source */ - if (src == NULL) { + if (!src) { /* Error may come from RWops. */ return NULL; - } else if (spec == NULL) { + } else if (!spec) { SDL_InvalidParamError("spec"); return NULL; - } else if (audio_buf == NULL) { + } else if (!audio_buf) { SDL_InvalidParamError("audio_buf"); return NULL; - } else if (audio_len == NULL) { + } else if (!audio_len) { SDL_InvalidParamError("audio_len"); return NULL; } diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index 8dfd16ce0..4e389a157 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -77,8 +77,8 @@ static int aaudio_OpenDevice(_THIS, const char *devname) aaudio_result_t res; LOGI(__func__); - SDL_assert((captureDevice == NULL) || !iscapture); - SDL_assert((audioDevice == NULL) || iscapture); + SDL_assert((!captureDevice) || !iscapture); + SDL_assert((!audioDevice) || iscapture); if (iscapture) { if (!Android_JNI_RequestPermission("android.permission.RECORD_AUDIO")) { @@ -94,14 +94,14 @@ static int aaudio_OpenDevice(_THIS, const char *devname) } this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } private = this->hidden; ctx.AAudioStreamBuilder_setSampleRate(ctx.builder, this->spec.freq); ctx.AAudioStreamBuilder_setChannelCount(ctx.builder, this->spec.channels); - if(devname != NULL) { + if(devname) { int aaudio_device_id = SDL_atoi(devname); LOGI("Opening device id %d", aaudio_device_id); ctx.AAudioStreamBuilder_setDeviceId(ctx.builder, aaudio_device_id); @@ -153,7 +153,7 @@ static int aaudio_OpenDevice(_THIS, const char *devname) if (!iscapture) { private->mixlen = this->spec.size; private->mixbuf = (Uint8 *)SDL_malloc(private->mixlen); - if (private->mixbuf == NULL) { + if (!private->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(private->mixbuf, this->spec.silence, this->spec.size); @@ -285,7 +285,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl) SDL_zero(ctx); ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO); - if (ctx.handle == NULL) { + if (!ctx.handle) { LOGI("SDL couldn't find " LIB_AAUDIO_SO); goto failure; } @@ -300,7 +300,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl) goto failure; } - if (ctx.builder == NULL) { + if (!ctx.builder) { LOGI("SDL Failed AAudio_createStreamBuilder - builder NULL"); goto failure; } @@ -344,7 +344,7 @@ void aaudio_PauseDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->stream) { @@ -365,7 +365,7 @@ void aaudio_PauseDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->stream) { @@ -393,7 +393,7 @@ void aaudio_ResumeDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->resume) { @@ -411,7 +411,7 @@ void aaudio_ResumeDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->resume) { @@ -441,7 +441,7 @@ SDL_bool aaudio_DetectBrokenPlayState(void) int64_t framePosition, timeNanoseconds; aaudio_result_t res; - if (audioDevice == NULL || !audioDevice->hidden) { + if (!audioDevice || !audioDevice->hidden) { return SDL_FALSE; } diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index c53161357..ab837f6cb 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -98,7 +98,7 @@ static void *alsa_handle = NULL; static int load_alsa_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(alsa_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -166,7 +166,7 @@ static int load_alsa_syms(void) static void UnloadALSALibrary(void) { - if (alsa_handle != NULL) { + if (alsa_handle) { SDL_UnloadObject(alsa_handle); alsa_handle = NULL; } @@ -175,9 +175,9 @@ static void UnloadALSALibrary(void) static int LoadALSALibrary(void) { int retval = 0; - if (alsa_handle == NULL) { + if (!alsa_handle) { alsa_handle = SDL_LoadObject(alsa_library); - if (alsa_handle == NULL) { + if (!alsa_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -208,13 +208,13 @@ static const char *get_audio_device(void *handle, const int channels) { const char *device; - if (handle != NULL) { + if (handle) { return (const char *)handle; } /* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */ device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */ - if (device != NULL) { + if (device) { return device; } @@ -539,7 +539,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -687,7 +687,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); @@ -717,7 +717,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D char *handle = NULL; char *ptr; - if (dev == NULL) { + if (!dev) { return; } @@ -727,7 +727,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D Make sure not to free the storage associated with desc in this case */ if (hint) { desc = ALSA_snd_device_name_get_hint(hint, "DESC"); - if (desc == NULL) { + if (!desc) { SDL_free(dev); return; } @@ -735,20 +735,20 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D desc = (char *)name; } - SDL_assert(name != NULL); + SDL_assert(name); /* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output". just chop the extra lines off, this seems to get a reasonable device name without extra details. */ ptr = SDL_strchr(desc, '\n'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } /*printf("ALSA: adding %s device '%s' (%s)\n", iscapture ? "capture" : "output", name, desc);*/ handle = SDL_strdup(name); - if (handle == NULL) { + if (!handle) { if (hint) { free(desc); } @@ -800,7 +800,7 @@ static void ALSA_HotplugIteration(void) if we can find a preferred prefix for the system. */ for (i = 0; hints[i]; i++) { char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); - if (name == NULL) { + if (!name) { continue; } @@ -829,20 +829,20 @@ static void ALSA_HotplugIteration(void) char *name; /* if we didn't find a device name prefix we like at all... */ - if ((match == NULL) && (defaultdev != i)) { + if ((!match) && (defaultdev != i)) { continue; /* ...skip anything that isn't the default device. */ } name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); - if (name == NULL) { + if (!name) { continue; } /* only want physical hardware interfaces */ - if (match == NULL || (SDL_strncmp(name, match, match_len) == 0)) { + if (!match || (SDL_strncmp(name, match, match_len) == 0)) { char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID"); - const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0); - const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0); + const SDL_bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0); + const SDL_bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0); SDL_bool have_output = SDL_FALSE; SDL_bool have_input = SDL_FALSE; @@ -940,7 +940,7 @@ static void ALSA_Deinitialize(void) ALSA_Device *next; #if SDL_ALSA_HOTPLUG_THREAD - if (ALSA_hotplug_thread != NULL) { + if (ALSA_hotplug_thread) { SDL_AtomicSet(&ALSA_hotplug_shutdown, 1); SDL_WaitThread(ALSA_hotplug_thread, NULL); ALSA_hotplug_thread = NULL; diff --git a/src/audio/android/SDL_androidaudio.c b/src/audio/android/SDL_androidaudio.c index b46fdda09..03874d0eb 100644 --- a/src/audio/android/SDL_androidaudio.c +++ b/src/audio/android/SDL_androidaudio.c @@ -41,8 +41,8 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) SDL_AudioFormat test_format; SDL_bool iscapture = this->iscapture; - SDL_assert((captureDevice == NULL) || !iscapture); - SDL_assert((audioDevice == NULL) || iscapture); + SDL_assert((!captureDevice) || !iscapture); + SDL_assert((!audioDevice) || iscapture); if (iscapture) { captureDevice = this; @@ -51,7 +51,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) } this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } @@ -71,7 +71,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) { int audio_device_id = 0; - if (devname != NULL) { + if (devname) { audio_device_id = SDL_atoi(devname); } if (Android_JNI_OpenAudioDevice(iscapture, audio_device_id, &this->spec) < 0) { @@ -149,7 +149,7 @@ void ANDROIDAUDIO_PauseDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (SDL_AtomicGet(&audioDevice->paused)) { /* The device is already paused, leave it alone */ @@ -161,7 +161,7 @@ void ANDROIDAUDIO_PauseDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (SDL_AtomicGet(&captureDevice->paused)) { /* The device is already paused, leave it alone */ @@ -179,7 +179,7 @@ void ANDROIDAUDIO_ResumeDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->resume) { SDL_AtomicSet(&audioDevice->paused, 0); @@ -188,7 +188,7 @@ void ANDROIDAUDIO_ResumeDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->resume) { SDL_AtomicSet(&captureDevice->paused, 0); diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index f3aa94b15..632df6fe7 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -88,7 +88,7 @@ static struct static void UnloadARTSLibrary() { - if (arts_handle != NULL) { + if (arts_handle) { SDL_UnloadObject(arts_handle); arts_handle = NULL; } @@ -98,9 +98,9 @@ static int LoadARTSLibrary(void) { int i, retval = -1; - if (arts_handle == NULL) { + if (!arts_handle) { arts_handle = SDL_LoadObject(arts_library); - if (arts_handle != NULL) { + if (arts_handle) { retval = 0; for (i = 0; i < SDL_arraysize(arts_functions); ++i) { *arts_functions[i].func = @@ -214,7 +214,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -281,7 +281,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index a61a068f7..99755b812 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -64,7 +64,7 @@ static void DSOUND_Unload(void) pDirectSoundCaptureCreate8 = NULL; pDirectSoundCaptureEnumerateW = NULL; - if (DSoundDLL != NULL) { + if (DSoundDLL) { SDL_UnloadObject(DSoundDLL); DSoundDLL = NULL; } @@ -77,7 +77,7 @@ static int DSOUND_Load(void) DSOUND_Unload(); DSoundDLL = SDL_LoadObject("DSOUND.DLL"); - if (DSoundDLL == NULL) { + if (!DSoundDLL) { SDL_SetError("DirectSound: failed to load DSOUND.DLL"); } else { /* Now make sure we have DirectX 8 or better... */ @@ -172,7 +172,7 @@ static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVO const int iscapture = (int)((size_t)data); if (guid != NULL) { /* skip default device */ char *str = WIN_LookupAudioDeviceName(desc, guid); - if (str != NULL) { + if (str) { LPGUID cpyguid = (LPGUID)SDL_malloc(sizeof(GUID)); SDL_memcpy(cpyguid, guid, sizeof(GUID)); @@ -354,7 +354,7 @@ static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen) } SDL_assert(ptr1len == this->spec.size); - SDL_assert(ptr2 == NULL); + SDL_assert(!ptr2); SDL_assert(ptr2len == 0); SDL_memcpy(buffer, ptr1, ptr1len); @@ -379,18 +379,18 @@ static void DSOUND_FlushCapture(_THIS) static void DSOUND_CloseDevice(_THIS) { - if (this->hidden->mixbuf != NULL) { + if (this->hidden->mixbuf) { IDirectSoundBuffer_Stop(this->hidden->mixbuf); IDirectSoundBuffer_Release(this->hidden->mixbuf); } - if (this->hidden->sound != NULL) { + if (this->hidden->sound) { IDirectSound_Release(this->hidden->sound); } - if (this->hidden->capturebuf != NULL) { + if (this->hidden->capturebuf) { IDirectSoundCaptureBuffer_Stop(this->hidden->capturebuf); IDirectSoundCaptureBuffer_Release(this->hidden->capturebuf); } - if (this->hidden->capture != NULL) { + if (this->hidden->capture) { IDirectSoundCapture_Release(this->hidden->capture); } SDL_free(this->hidden); @@ -493,7 +493,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index e98dbea7e..cd37e53bb 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -98,7 +98,7 @@ static void DISKAUDIO_FlushCapture(_THIS) static void DISKAUDIO_CloseDevice(_THIS) { - if (_this->hidden->io != NULL) { + if (_this->hidden->io) { SDL_RWclose(_this->hidden->io); } SDL_free(_this->hidden->mixbuf); @@ -107,9 +107,9 @@ static void DISKAUDIO_CloseDevice(_THIS) static const char *get_filename(const SDL_bool iscapture, const char *devname) { - if (devname == NULL) { + if (!devname) { devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE); - if (devname == NULL) { + if (!devname) { devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE; } } @@ -126,12 +126,12 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname) _this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*_this->hidden)); - if (_this->hidden == NULL) { + if (!_this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(_this->hidden); - if (envr != NULL) { + if (envr) { _this->hidden->io_delay = SDL_atoi(envr); } else { _this->hidden->io_delay = ((_this->spec.samples * 1000) / _this->spec.freq); @@ -139,14 +139,14 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname) /* Open the audio device */ _this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb"); - if (_this->hidden->io == NULL) { + if (!_this->hidden->io) { return -1; } /* Allocate mixing buffer */ if (!iscapture) { _this->hidden->mixbuf = (Uint8 *)SDL_malloc(_this->spec.size); - if (_this->hidden->mixbuf == NULL) { + if (!_this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(_this->hidden->mixbuf, _this->spec.silence, _this->spec.size); diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index 441aa2574..cb8bb7a68 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -67,9 +67,9 @@ static int DSP_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } @@ -86,7 +86,7 @@ static int DSP_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -228,7 +228,7 @@ static int DSP_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index a7dca5d88..a89d34fd8 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -70,7 +70,7 @@ static void HandleAudioProcess(_THIS) return; } - if (this->stream == NULL) { /* no conversion necessary. */ + if (!this->stream) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); } else { /* streaming/converting */ @@ -130,7 +130,7 @@ static void HandleCaptureProcess(_THIS) /* okay, we've got an interleaved float32 array in C now. */ - if (this->stream == NULL) { /* no conversion necessary. */ + if (!this->stream) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); } else { /* streaming/converting */ diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index 800caaf0b..c2ad33ba8 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -66,7 +66,7 @@ static struct static void UnloadESDLibrary() { - if (esd_handle != NULL) { + if (esd_handle) { SDL_UnloadObject(esd_handle); esd_handle = NULL; } @@ -76,7 +76,7 @@ static int LoadESDLibrary(void) { int i, retval = -1; - if (esd_handle == NULL) { + if (!esd_handle) { esd_handle = SDL_LoadObject(esd_library); if (esd_handle) { retval = 0; @@ -185,7 +185,7 @@ static char *get_progname(void) if (fp != NULL) { if (fgets(temp, sizeof(temp) - 1, fp)) { progname = SDL_strrchr(temp, '/'); - if (progname == NULL) { + if (!progname) { progname = temp; } else { progname = progname + 1; @@ -206,7 +206,7 @@ static int ESD_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -264,7 +264,7 @@ static int ESD_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c index f79ab22f7..077fa57c8 100644 --- a/src/audio/fusionsound/SDL_fsaudio.c +++ b/src/audio/fusionsound/SDL_fsaudio.c @@ -79,7 +79,7 @@ static struct static void UnloadFusionSoundLibrary() { - if (fs_handle != NULL) { + if (fs_handle) { SDL_UnloadObject(fs_handle); fs_handle = NULL; } @@ -89,9 +89,9 @@ static int LoadFusionSoundLibrary(void) { int i, retval = -1; - if (fs_handle == NULL) { + if (!fs_handle) { fs_handle = SDL_LoadObject(fs_library); - if (fs_handle != NULL) { + if (fs_handle) { retval = 0; for (i = 0; i < SDL_arraysize(fs_functions); ++i) { *fs_functions[i].func = @@ -175,7 +175,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -250,7 +250,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc index ca946ed75..02678ff19 100644 --- a/src/audio/haiku/SDL_haikuaudio.cc +++ b/src/audio/haiku/SDL_haikuaudio.cc @@ -59,7 +59,7 @@ static void FillSound(void *device, void *stream, size_t len, } else { SDL_assert(audio->spec.size == len); - if (audio->stream == NULL) { /* no conversion necessary. */ + if (!audio->stream) { /* no conversion necessary. */ callback(audio->callbackspec.userdata, (Uint8 *) stream, len); } else { /* streaming/converting */ const int stream_len = audio->callbackspec.size; diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c index f9e942c57..94ea12dc5 100644 --- a/src/audio/jack/SDL_jackaudio.c +++ b/src/audio/jack/SDL_jackaudio.c @@ -58,7 +58,7 @@ static void *jack_handle = NULL; static int load_jack_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(jack_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -73,7 +73,7 @@ static int load_jack_sym(const char *fn, void **addr) static void UnloadJackLibrary(void) { - if (jack_handle != NULL) { + if (jack_handle) { SDL_UnloadObject(jack_handle); jack_handle = NULL; } @@ -82,9 +82,9 @@ static void UnloadJackLibrary(void) static int LoadJackLibrary(void) { int retval = 0; - if (jack_handle == NULL) { + if (!jack_handle) { jack_handle = SDL_LoadObject(jack_library); - if (jack_handle == NULL) { + if (!jack_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -341,7 +341,7 @@ static int JACK_OpenDevice(_THIS, const char *devname) /* Build SDL's ports, which we will connect to the device ports. */ this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *)); - if (this->hidden->sdlports == NULL) { + if (!this->hidden->sdlports) { SDL_free(audio_ports); return SDL_OutOfMemory(); } @@ -400,7 +400,7 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) /* Make sure a JACK server is running and available. */ jack_status_t status; jack_client_t *client = JACK_jack_client_open("SDL", JackNoStartServer, &status, NULL); - if (client == NULL) { + if (!client) { UnloadJackLibrary(); return SDL_FALSE; } diff --git a/src/audio/n3ds/SDL_n3dsaudio.c b/src/audio/n3ds/SDL_n3dsaudio.c index a72e364d5..78d1a6525 100644 --- a/src/audio/n3ds/SDL_n3dsaudio.c +++ b/src/audio/n3ds/SDL_n3dsaudio.c @@ -89,7 +89,7 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname) float mix[12]; this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } @@ -127,14 +127,14 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname) this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); data_vaddr = (Uint8 *)linearAlloc(this->hidden->mixlen * NUM_BUFFERS); - if (data_vaddr == NULL) { + if (!data_vaddr) { return SDL_OutOfMemory(); } diff --git a/src/audio/nacl/SDL_naclaudio.c b/src/audio/nacl/SDL_naclaudio.c index cdb01bcb7..36ef6a0f1 100644 --- a/src/audio/nacl/SDL_naclaudio.c +++ b/src/audio/nacl/SDL_naclaudio.c @@ -62,7 +62,7 @@ static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta } else { SDL_assert(_this->spec.size == len); - if (_this->stream == NULL) { /* no conversion necessary. */ + if (!_this->stream) { /* no conversion necessary. */ callback(_this->callbackspec.userdata, stream, len); } else { /* streaming/converting */ const int stream_len = _this->callbackspec.size; @@ -103,7 +103,7 @@ static int NACLAUDIO_OpenDevice(_THIS, const char *devname) const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig(); private = (SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*private)); - if (private == NULL) { + if (!private) { return SDL_OutOfMemory(); } diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index d6807203d..0362cd606 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -59,7 +59,7 @@ static void *nas_handle = NULL; static int load_nas_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(nas_handle, fn); - if (*addr == NULL) { + if (!*addr) { return 0; } return 1; @@ -94,7 +94,7 @@ static int load_nas_syms(void) static void UnloadNASLibrary(void) { - if (nas_handle != NULL) { + if (nas_handle) { SDL_UnloadObject(nas_handle); nas_handle = NULL; } @@ -103,9 +103,9 @@ static void UnloadNASLibrary(void) static int LoadNASLibrary(void) { int retval = 0; - if (nas_handle == NULL) { + if (!nas_handle) { nas_handle = SDL_LoadObject(nas_library); - if (nas_handle == NULL) { + if (!nas_handle) { /* Copy error string so we can use it in a new SDL_SetError(). */ const char *origerr = SDL_GetError(); const size_t len = SDL_strlen(origerr) + 1; @@ -305,7 +305,7 @@ static int NAS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -389,7 +389,7 @@ static int NAS_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); @@ -410,7 +410,7 @@ static SDL_bool NAS_Init(SDL_AudioDriverImpl * impl) return SDL_FALSE; } else { AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL); - if (aud == NULL) { + if (!aud) { SDL_SetError("NAS: AuOpenServer() failed (no audio server?)"); return SDL_FALSE; } diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c index d90f28a94..42e638d6b 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.c +++ b/src/audio/netbsd/SDL_netbsdaudio.c @@ -202,16 +202,16 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -296,7 +296,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index 998104c24..41f9ba148 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -320,7 +320,7 @@ static int openslES_CreatePCMRecorder(_THIS) /* Create the sound buffers */ audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -566,7 +566,7 @@ static int openslES_CreatePCMPlayer(_THIS) /* Create the sound buffers */ audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -591,7 +591,7 @@ failed: static int openslES_OpenDevice(_THIS, const char *devname) { this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } diff --git a/src/audio/os2/SDL_os2audio.c b/src/audio/os2/SDL_os2audio.c index 2f1e6bc66..9eaa21d08 100644 --- a/src/audio/os2/SDL_os2audio.c +++ b/src/audio/os2/SDL_os2audio.c @@ -43,7 +43,7 @@ static ULONG _getEnvULong(const char *name, ULONG ulMax, ULONG ulDefault) char* end; char* envval = SDL_getenv(name); - if (envval == NULL) + if (!envval) return ulDefault; ulValue = SDL_strtoul(envval, &end, 10); @@ -351,7 +351,7 @@ static void OS2_CloseDevice(_THIS) debug_os2("Enter"); - if (pAData == NULL) + if (!pAData) return; pAData->ulState = 2; @@ -429,7 +429,7 @@ static int OS2_OpenDevice(_THIS, const char *devname) } pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData)); - if (pAData == NULL) + if (!pAData) return SDL_OutOfMemory(); _this->hidden = pAData; diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index 5c5c36fc2..266cadd1d 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -78,11 +78,11 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags) if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) { audiodev = SDL_getenv("AUDIODEV"); } - if (audiodev == NULL) { + if (!audiodev) { return -1; } fd = open(audiodev, flags, 0); - if (path != NULL) { + if (path) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen - 1] = '\0'; } @@ -110,7 +110,7 @@ static int OpenAudioPath(char *path, int maxlen, int flags, int classic) if (stat(audiopath, &sb) == 0) { fd = open(audiopath, flags, 0); if (fd >= 0) { - if (path != NULL) { + if (path) { SDL_strlcpy(path, audiopath, maxlen); } return fd; @@ -232,7 +232,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -403,7 +403,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); @@ -445,7 +445,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) } /* Check to see if we need to use SDL_IOReady() workaround */ - if (workaround != NULL) { + if (workaround) { this->hidden->frame_ticks = (float) (this->spec.samples * 1000) / this->spec.freq; this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks; diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index f9694334d..60dde24fd 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -129,7 +129,7 @@ static void *pipewire_handle = NULL; static int pipewire_dlsym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pipewire_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -145,7 +145,7 @@ static int pipewire_dlsym(const char *fn, void **addr) static int load_pipewire_library() { pipewire_handle = SDL_LoadObject(pipewire_library); - return pipewire_handle != NULL ? 0 : -1; + return pipewire_handle ? 0 : -1; } static void unload_pipewire_library() @@ -347,10 +347,10 @@ static void io_list_sort() /* Find and move the default nodes to the beginning of the list */ spa_list_for_each_safe (n, temp, &hotplug_io_list, link) { - if (pipewire_default_sink_id != NULL && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) { + if (pipewire_default_sink_id && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) { default_sink = n; spa_list_remove(&n->link); - } else if (pipewire_default_source_id != NULL && SDL_strcmp(n->path, pipewire_default_source_id) == 0) { + } else if (pipewire_default_source_id && SDL_strcmp(n->path, pipewire_default_source_id) == 0) { default_source = n; spa_list_remove(&n->link); } @@ -442,7 +442,7 @@ static void *node_object_new(Uint32 id, const char *type, Uint32 version, const /* Create the proxy object */ proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object)); - if (proxy == NULL) { + if (!proxy) { SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno); return NULL; } @@ -648,15 +648,15 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons { struct node_object *node = object; - if (subject == PW_ID_CORE && key != NULL && value != NULL) { + if (subject == PW_ID_CORE && key && value) { if (!SDL_strcmp(key, "default.audio.sink")) { - if (pipewire_default_sink_id != NULL) { + if (pipewire_default_sink_id) { SDL_free(pipewire_default_sink_id); } pipewire_default_sink_id = get_name_from_json(value); node->persist = SDL_TRUE; } else if (!SDL_strcmp(key, "default.audio.source")) { - if (pipewire_default_source_id != NULL) { + if (pipewire_default_source_id) { SDL_free(pipewire_default_source_id); } pipewire_default_source_id = get_name_from_json(value); @@ -701,7 +701,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p if (node_desc && node_path) { node = node_object_new(id, type, version, &interface_node_events, &interface_core_events); - if (node == NULL) { + if (!node) { SDL_SetError("Pipewire: Failed to allocate interface node"); return; } @@ -710,7 +710,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p desc_buffer_len = SDL_strlen(node_desc) + 1; path_buffer_len = SDL_strlen(node_path) + 1; node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + desc_buffer_len + path_buffer_len); - if (io == NULL) { + if (!io) { node_object_destroy(node); SDL_OutOfMemory(); return; @@ -731,7 +731,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p } } else if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Metadata)) { node = node_object_new(id, type, version, &metadata_node_events, &metadata_core_events); - if (node == NULL) { + if (!node) { SDL_SetError("Pipewire: Failed to allocate metadata node"); return; } @@ -759,22 +759,22 @@ static int hotplug_loop_init() spa_list_init(&hotplug_io_list); hotplug_loop = PIPEWIRE_pw_thread_loop_new("SDLAudioHotplug", NULL); - if (hotplug_loop == NULL) { + if (!hotplug_loop) { return SDL_SetError("Pipewire: Failed to create hotplug detection loop (%i)", errno); } hotplug_context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(hotplug_loop), NULL, 0); - if (hotplug_context == NULL) { + if (!hotplug_context) { return SDL_SetError("Pipewire: Failed to create hotplug detection context (%i)", errno); } hotplug_core = PIPEWIRE_pw_context_connect(hotplug_context, NULL, 0); - if (hotplug_core == NULL) { + if (!hotplug_core) { return SDL_SetError("Pipewire: Failed to connect hotplug detection context (%i)", errno); } hotplug_registry = pw_core_get_registry(hotplug_core, PW_VERSION_REGISTRY, 0); - if (hotplug_registry == NULL) { + if (!hotplug_registry) { return SDL_SetError("Pipewire: Failed to acquire hotplug detection registry (%i)", errno); } @@ -806,11 +806,11 @@ static void hotplug_loop_destroy() hotplug_init_complete = SDL_FALSE; hotplug_events_enabled = SDL_FALSE; - if (pipewire_default_sink_id != NULL) { + if (pipewire_default_sink_id) { SDL_free(pipewire_default_sink_id); pipewire_default_sink_id = NULL; } - if (pipewire_default_source_id != NULL) { + if (pipewire_default_source_id) { SDL_free(pipewire_default_source_id); pipewire_default_source_id = NULL; } @@ -961,7 +961,7 @@ static void output_callback(void *data) /* See if a buffer is available */ pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); - if (pw_buf == NULL) { + if (!pw_buf) { return; } @@ -1025,13 +1025,13 @@ static void input_callback(void *data) } pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); - if (pw_buf == NULL) { + if (!pw_buf) { return; } spa_buf = pw_buf->buffer; (src = (Uint8 *)spa_buf->datas[0].data); - if (src == NULL) { + if (!src) { return; } @@ -1079,7 +1079,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer) this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride; this->spec.size = buffer->buffer->datas[0].maxsize; } - } else if (this->hidden->buffer == NULL) { + } else if (!this->hidden->buffer) { /* * The latency of source nodes can change, so buffering is always required. * @@ -1137,7 +1137,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) struct SDL_PrivateAudioData *priv; struct pw_properties *props; const char *app_name, *stream_name, *stream_role, *error; - Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); + Uint32 node_id = !this->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); SDL_bool iscapture = this->iscapture; int res; @@ -1146,15 +1146,15 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) /* Get the hints for the application name, stream name and role */ app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME); - if (app_name == NULL || *app_name == '\0') { + if (!app_name || *app_name == '\0') { app_name = SDL_GetHint(SDL_HINT_APP_NAME); - if (app_name == NULL || *app_name == '\0') { + if (!app_name || *app_name == '\0') { app_name = "SDL Application"; } } stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); - if (stream_name == NULL || *stream_name == '\0') { + if (!stream_name || *stream_name == '\0') { stream_name = "Audio Stream"; } @@ -1163,20 +1163,20 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) * but 'Game' seems more appropriate for the majority of SDL applications. */ stream_role = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE); - if (stream_role == NULL || *stream_role == '\0') { + if (!stream_role || *stream_role == '\0') { stream_role = "Game"; } /* Initialize the Pipewire stream info from the SDL audio spec */ initialize_spa_info(&this->spec, &spa_info); params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &spa_info); - if (params == NULL) { + if (!params) { return SDL_SetError("Pipewire: Failed to set audio format parameters"); } priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData)); this->hidden = priv; - if (priv == NULL) { + if (!priv) { return SDL_OutOfMemory(); } @@ -1190,23 +1190,23 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) (void)SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle); priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL); - if (priv->loop == NULL) { + if (!priv->loop) { return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno); } /* Load the realtime module so Pipewire can set the loop thread to the appropriate priority. */ props = PIPEWIRE_pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf", NULL); - if (props == NULL) { + if (!props) { return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno); } priv->context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), props, 0); - if (priv->context == NULL) { + if (!priv->context) { return SDL_SetError("Pipewire: Failed to create stream context (%i)", errno); } props = PIPEWIRE_pw_properties_new(NULL, NULL); - if (props == NULL) { + if (!props) { return SDL_SetError("Pipewire: Failed to create stream properties (%i)", errno); } @@ -1232,7 +1232,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) PIPEWIRE_pw_thread_loop_lock(hotplug_loop); node = io_list_get_by_id(node_id); - if (node != NULL) { + if (node) { PIPEWIRE_pw_properties_set(props, PW_KEY_TARGET_OBJECT, node->path); } PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); @@ -1244,7 +1244,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) /* Create the new stream */ priv->stream = PIPEWIRE_pw_stream_new_simple(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), stream_name, props, iscapture ? &stream_input_events : &stream_output_events, this); - if (priv->stream == NULL) { + if (!priv->stream) { return SDL_SetError("Pipewire: Failed to create stream (%i)", errno); } @@ -1272,7 +1272,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) } /* If this is a capture stream, make sure the intermediate buffer was successfully allocated. */ - if (iscapture && priv->buffer == NULL) { + if (iscapture && !priv->buffer) { return SDL_SetError("Pipewire: Failed to allocate source buffer"); } @@ -1313,13 +1313,13 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is PIPEWIRE_pw_thread_loop_lock(hotplug_loop); if (iscapture) { - if (pipewire_default_source_id == NULL) { + if (!pipewire_default_source_id) { ret = SDL_SetError("PipeWire could not find a default source"); goto failed; } target = pipewire_default_source_id; } else { - if (pipewire_default_sink_id == NULL) { + if (!pipewire_default_sink_id) { ret = SDL_SetError("PipeWire could not find a default sink"); goto failed; } @@ -1327,12 +1327,12 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is } node = io_list_get_by_path(target); - if (node == NULL) { + if (!node) { ret = SDL_SetError("PipeWire device list is out of sync with defaults"); goto failed; } - if (name != NULL) { + if (name) { *name = SDL_strdup(node->name); } SDL_copyp(spec, &node->spec); diff --git a/src/audio/ps2/SDL_ps2audio.c b/src/audio/ps2/SDL_ps2audio.c index ffbf6c5cf..d796c119b 100644 --- a/src/audio/ps2/SDL_ps2audio.c +++ b/src/audio/ps2/SDL_ps2audio.c @@ -42,7 +42,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -90,7 +90,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname) 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); - if (this->hidden->rawbuf == NULL) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -129,7 +129,7 @@ static void PS2AUDIO_CloseDevice(_THIS) this->hidden->channel = -1; } - if (this->hidden->rawbuf != NULL) { + if (this->hidden->rawbuf) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; } diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 3b0156489..c19a4b8aa 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -52,7 +52,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -108,7 +108,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname) 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); - if (this->hidden->rawbuf == NULL) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -156,7 +156,7 @@ static void PSPAUDIO_CloseDevice(_THIS) this->hidden->channel = -1; } - if (this->hidden->rawbuf != NULL) { + if (this->hidden->rawbuf) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; } diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 2bb4409e0..1d8d0cc91 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -125,7 +125,7 @@ static void *pulseaudio_handle = NULL; static int load_pulseaudio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pulseaudio_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -140,7 +140,7 @@ static int load_pulseaudio_sym(const char *fn, void **addr) static void UnloadPulseAudioLibrary(void) { - if (pulseaudio_handle != NULL) { + if (pulseaudio_handle) { SDL_UnloadObject(pulseaudio_handle); pulseaudio_handle = NULL; } @@ -149,9 +149,9 @@ static void UnloadPulseAudioLibrary(void) static int LoadPulseAudioLibrary(void) { int retval = 0; - if (pulseaudio_handle == NULL) { + if (!pulseaudio_handle) { pulseaudio_handle = SDL_LoadObject(pulseaudio_library); - if (pulseaudio_handle == NULL) { + if (!pulseaudio_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -257,7 +257,7 @@ static const char *getAppName(void) } else { const char *verstr = PULSEAUDIO_pa_get_library_version(); retval = "SDL Application"; /* the "oh well" default. */ - if (verstr != NULL) { + if (verstr) { int maj, min, patch; if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) { if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) { @@ -275,7 +275,7 @@ static const char *getAppName(void) static void WaitForPulseOperation(pa_operation *o) { /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */ - SDL_assert(pulseaudio_threaded_mainloop != NULL); + SDL_assert(pulseaudio_threaded_mainloop); if (o) { while (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING) { PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); /* this releases the lock and blocks on an internal condition variable. */ @@ -286,7 +286,7 @@ static void WaitForPulseOperation(pa_operation *o) static void DisconnectFromPulseServer(void) { - if (pulseaudio_threaded_mainloop != NULL) { + if (pulseaudio_threaded_mainloop) { PULSEAUDIO_pa_threaded_mainloop_stop(pulseaudio_threaded_mainloop); } if (pulseaudio_context) { @@ -294,7 +294,7 @@ static void DisconnectFromPulseServer(void) PULSEAUDIO_pa_context_unref(pulseaudio_context); pulseaudio_context = NULL; } - if (pulseaudio_threaded_mainloop != NULL) { + if (pulseaudio_threaded_mainloop) { PULSEAUDIO_pa_threaded_mainloop_free(pulseaudio_threaded_mainloop); pulseaudio_threaded_mainloop = NULL; } @@ -310,8 +310,8 @@ static int ConnectToPulseServer(void) pa_mainloop_api *mainloop_api = NULL; int state = 0; - SDL_assert(pulseaudio_threaded_mainloop == NULL); - SDL_assert(pulseaudio_context == NULL); + SDL_assert(!pulseaudio_threaded_mainloop); + SDL_assert(!pulseaudio_context); /* Set up a new main loop */ if (!(pulseaudio_threaded_mainloop = PULSEAUDIO_pa_threaded_mainloop_new())) { @@ -334,7 +334,7 @@ static int ConnectToPulseServer(void) SDL_assert(mainloop_api); /* this never fails, right? */ pulseaudio_context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName()); - if (pulseaudio_context == NULL) { + if (!pulseaudio_context) { SDL_SetError("pa_context_new() failed"); goto failed; } @@ -445,7 +445,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); while (SDL_AtomicGet(&this->enabled)) { - if (h->capturebuf != NULL) { + if (h->capturebuf) { const int cpy = SDL_min(buflen, h->capturelen); SDL_memcpy(buffer, h->capturebuf, cpy); /*printf("PULSEAUDIO: fed %d captured bytes\n", cpy);*/ @@ -478,7 +478,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); SDL_assert(nbytes > 0); /* If data == NULL, then the buffer had a hole, ignore that */ - if (data == NULL) { + if (!data) { PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ } else { /* store this fragment's data, start feeding it to SDL. */ @@ -501,7 +501,7 @@ static void PULSEAUDIO_FlushCapture(_THIS) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); - if (h->capturebuf != NULL) { + if (h->capturebuf) { PULSEAUDIO_pa_stream_drop(h->stream); h->capturebuf = NULL; h->capturelen = 0; @@ -530,7 +530,7 @@ static void PULSEAUDIO_CloseDevice(_THIS) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); if (this->hidden->stream) { - if (this->hidden->capturebuf != NULL) { + if (this->hidden->capturebuf) { PULSEAUDIO_pa_stream_drop(this->hidden->stream); } PULSEAUDIO_pa_stream_disconnect(this->hidden->stream); @@ -566,7 +566,7 @@ static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool is { const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1; - if (handle == NULL) { /* NULL == default device. */ + if (!handle) { /* NULL == default device. */ return SDL_TRUE; } @@ -596,12 +596,12 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) int format = PA_SAMPLE_INVALID; int retval = 0; - SDL_assert(pulseaudio_threaded_mainloop != NULL); - SDL_assert(pulseaudio_context != NULL); + SDL_assert(pulseaudio_threaded_mainloop); + SDL_assert(pulseaudio_context); /* Initialize all variables that we clean on shutdown */ h = this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -651,7 +651,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) if (!iscapture) { h->mixlen = this->spec.size; h->mixbuf = (Uint8 *)SDL_malloc(h->mixlen); - if (h->mixbuf == NULL) { + if (!h->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(h->mixbuf, this->spec.silence, this->spec.size); @@ -686,7 +686,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) &pacmap /* channel map */ ); - if (h->stream == NULL) { + if (!h->stream) { retval = SDL_SetError("Could not set up PulseAudio stream"); } else { int rc; @@ -694,7 +694,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) PULSEAUDIO_pa_stream_set_state_callback(h->stream, PulseStreamStateChangeCallback, NULL); /* now that we have multi-device support, don't move a stream from a device that was unplugged to something else, unless we're default. */ - if (h->device_name != NULL) { + if (h->device_name) { flags |= PA_STREAM_DONT_MOVE; } @@ -772,8 +772,8 @@ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } - if (default_sink_path != NULL && SDL_strcmp(i->name, default_sink_path) == 0) { - if (default_sink_name != NULL) { + if (default_sink_path && SDL_strcmp(i->name, default_sink_path) == 0) { + if (default_sink_name) { SDL_free(default_sink_name); } default_sink_name = SDL_strdup(i->description); @@ -803,8 +803,8 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } - if (default_source_path != NULL && SDL_strcmp(i->name, default_source_path) == 0) { - if (default_source_name != NULL) { + if (default_source_path && SDL_strcmp(i->name, default_source_path) == 0) { + if (default_source_name) { SDL_free(default_source_name); } default_source_name = SDL_strdup(i->description); @@ -909,12 +909,12 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int char *target; if (iscapture) { - if (default_source_name == NULL) { + if (!default_source_name) { return SDL_SetError("PulseAudio could not find a default source"); } target = default_source_name; } else { - if (default_sink_name == NULL) { + if (!default_sink_name) { return SDL_SetError("PulseAudio could not find a default sink"); } target = default_sink_name; @@ -923,7 +923,7 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int numdevices = SDL_GetNumAudioDevices(iscapture); for (i = 0; i < numdevices; i += 1) { if (SDL_strcmp(SDL_GetAudioDeviceName(i, iscapture), target) == 0) { - if (name != NULL) { + if (name) { *name = SDL_strdup(target); } SDL_GetAudioDeviceSpec(i, iscapture, spec); diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c index 1a80f94f0..893eb4ea8 100644 --- a/src/audio/qsa/SDL_qsa_audio.c +++ b/src/audio/qsa/SDL_qsa_audio.c @@ -232,7 +232,7 @@ static Uint8 *QSA_GetDeviceBuf(_THIS) static void QSA_CloseDevice(_THIS) { - if (this->hidden->audio_handle != NULL) { + if (this->hidden->audio_handle) { #if _NTO_VERSION < 710 if (!this->iscapture) { /* Finish playing available samples */ @@ -267,14 +267,14 @@ static int QSA_OpenDevice(_THIS, const char *devname) (sizeof (struct SDL_PrivateAudioData))); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } /* Initialize channel transfer parameters to default */ QSA_InitAudioParams(&cparams); - if (device != NULL) { + if (device) { /* Open requested audio device */ this->hidden->deviceno = device->deviceno; this->hidden->cardno = device->cardno; @@ -387,7 +387,7 @@ static int QSA_OpenDevice(_THIS, const char *devname) */ this->hidden->pcm_buf = (Uint8 *) SDL_malloc(this->hidden->pcm_len); - if (this->hidden->pcm_buf == NULL) { + if (!this->hidden->pcm_buf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->pcm_buf, this->spec.silence, diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index d62d179d4..03cc6e68e 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -73,7 +73,7 @@ static void *sndio_handle = NULL; static int load_sndio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(sndio_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -113,7 +113,7 @@ static int load_sndio_syms(void) static void UnloadSNDIOLibrary(void) { - if (sndio_handle != NULL) { + if (sndio_handle) { SDL_UnloadObject(sndio_handle); sndio_handle = NULL; } @@ -122,9 +122,9 @@ static void UnloadSNDIOLibrary(void) static int LoadSNDIOLibrary(void) { int retval = 0; - if (sndio_handle == NULL) { + if (!sndio_handle) { sndio_handle = SDL_LoadObject(sndio_library); - if (sndio_handle == NULL) { + if (!sndio_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -211,10 +211,10 @@ static Uint8 *SNDIO_GetDeviceBuf(_THIS) static void SNDIO_CloseDevice(_THIS) { - if (this->hidden->pfd != NULL) { + if (this->hidden->pfd) { SDL_free(this->hidden->pfd); } - if (this->hidden->dev != NULL) { + if (this->hidden->dev) { SNDIO_sio_stop(this->hidden->dev); SNDIO_sio_close(this->hidden->dev); } @@ -230,7 +230,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -238,16 +238,16 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) this->hidden->mixlen = this->spec.size; /* Capture devices must be non-blocking for SNDIO_FlushCapture */ - this->hidden->dev = SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY, + this->hidden->dev = SNDIO_sio_open(devname ? devname : SIO_DEVANY, iscapture ? SIO_REC : SIO_PLAY, iscapture); - if (this->hidden->dev == NULL) { + if (!this->hidden->dev) { return SDL_SetError("sio_open() failed"); } /* Allocate the pollfd array for capture devices */ if (iscapture) { this->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev)); - if (this->hidden->pfd == NULL) { + if (!this->hidden->pfd) { return SDL_OutOfMemory(); } } @@ -315,7 +315,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 25deb9098..2c15b479d 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -194,16 +194,16 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -305,7 +305,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) (this->spec.freq / 8); this->hidden->frequency = 8; this->hidden->ulaw_buf = (Uint8 *) SDL_malloc(this->hidden->fragsize); - if (this->hidden->ulaw_buf == NULL) { + if (!this->hidden->ulaw_buf) { return SDL_OutOfMemory(); } this->spec.channels = 1; @@ -325,7 +325,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c index 058896be2..018cf0ab5 100644 --- a/src/audio/vita/SDL_vitaaudio.c +++ b/src/audio/vita/SDL_vitaaudio.c @@ -67,7 +67,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_memset(this->hidden, 0, sizeof(*this->hidden)); @@ -98,7 +98,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname) 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); - if (this->hidden->rawbuf == NULL) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -162,7 +162,7 @@ static void VITAAUD_CloseDevice(_THIS) this->hidden->port = -1; } - if (!this->iscapture && this->hidden->rawbuf != NULL) { + if (!this->iscapture && this->hidden->rawbuf) { free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */ this->hidden->rawbuf = NULL; } diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index c46577664..fa1e7f546 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -114,7 +114,7 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec) /* make sure our scratch buffer can cover the new device spec. */ if (this->spec.size > this->work_buffer_len) { Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size); - if (ptr == NULL) { + if (!ptr) { return SDL_OutOfMemory(); } this->work_buffer = ptr; @@ -181,7 +181,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS) if (!WasapiFailed(this, IAudioRenderClient_GetBuffer(this->hidden->render, this->spec.samples, &buffer))) { return (Uint8 *)buffer; } - SDL_assert(buffer == NULL); + SDL_assert(!buffer); } return (Uint8 *)buffer; @@ -189,7 +189,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS) static void WASAPI_PlayDevice(_THIS) { - if (this->hidden->render != NULL) { /* definitely activated? */ + if (this->hidden->render) { /* definitely activated? */ /* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */ WasapiFailed(this, IAudioRenderClient_ReleaseBuffer(this->hidden->render, this->spec.samples, 0)); } @@ -407,7 +407,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) HRESULT ret = S_OK; DWORD streamflags = 0; - SDL_assert(client != NULL); + SDL_assert(client); #if defined(__WINRT__) || defined(__GDK__) /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */ this->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); @@ -415,7 +415,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) this->hidden->event = CreateEventW(NULL, 0, 0, NULL); #endif - if (this->hidden->event == NULL) { + if (!this->hidden->event) { return WIN_SetError("WASAPI can't create an event handle"); } @@ -424,7 +424,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't determine mix format", ret); } - SDL_assert(waveformat != NULL); + SDL_assert(waveformat); this->hidden->waveformat = waveformat; this->spec.channels = (Uint8)waveformat->nChannels; @@ -502,7 +502,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't get capture client service", ret); } - SDL_assert(capture != NULL); + SDL_assert(capture); this->hidden->capture = capture; ret = IAudioClient_Start(client); if (FAILED(ret)) { @@ -516,7 +516,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't get render client service", ret); } - SDL_assert(render != NULL); + SDL_assert(render); this->hidden->render = render; ret = IAudioClient_Start(client); if (FAILED(ret)) { @@ -537,7 +537,7 @@ static int WASAPI_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index 965e7ff69..1b31311aa 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -120,11 +120,11 @@ int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) IMMDevice_Release(device); if (FAILED(ret)) { - SDL_assert(this->hidden->client == NULL); + SDL_assert(!this->hidden->client); return WIN_SetErrorFromHRESULT("WASAPI can't activate audio endpoint", ret); } - SDL_assert(this->hidden->client != NULL); + SDL_assert(this->hidden->client); if (WASAPI_PrepDevice(this, isrecovery) == -1) { /* not async, fire it right away. */ return -1; } diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp index 93ed3b834..aa0130012 100644 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -405,7 +405,7 @@ static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVE } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); - if (devidlist == NULL) { + if (!devidlist) { return; /* oh well. */ } diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c index d0c4b9768..d3c5b1ba6 100644 --- a/src/audio/winmm/SDL_winmm.c +++ b/src/audio/winmm/SDL_winmm.c @@ -279,7 +279,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname) UINT devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */ UINT i; - if (handle != NULL) { /* specific device requested? */ + if (handle) { /* specific device requested? */ /* -1 because we increment the original value to avoid NULL. */ const size_t val = ((size_t) handle) - 1; devId = (UINT) val; @@ -287,7 +287,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -365,14 +365,14 @@ static int WINMM_OpenDevice(_THIS, const char *devname) /* Create the audio buffer semaphore */ this->hidden->audio_sem = CreateSemaphore(NULL, iscapture ? 0 : NUM_BUFFERS - 1, NUM_BUFFERS, NULL); - if (this->hidden->audio_sem == NULL) { + if (!this->hidden->audio_sem) { return SDL_SetError("Couldn't create semaphore"); } /* Create the sound buffers */ this->hidden->mixbuf = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 0c8811c99..2886f1094 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -420,12 +420,12 @@ JNIEnv *Android_JNI_GetEnv(void) { /* Get JNIEnv from the Thread local storage */ JNIEnv *env = pthread_getspecific(mThreadKey); - if (env == NULL) { + if (!env) { /* If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() */ int status; /* There should be a JVM */ - if (mJavaVM == NULL) { + if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM"); return NULL; } @@ -454,7 +454,7 @@ int Android_JNI_SetupThread(void) int status; /* There should be a JVM */ - if (mJavaVM == NULL) { + if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM"); return 0; } @@ -480,7 +480,7 @@ static void Android_JNI_ThreadDestroyed(void *value) { /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ JNIEnv *env = (JNIEnv *)value; - if (env != NULL) { + if (env) { (*mJavaVM)->DetachCurrentThread(mJavaVM); Android_JNI_SetEnv(NULL); } @@ -506,7 +506,7 @@ static void Android_JNI_CreateKey_once(void) static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb) { jclass clazz = (*env)->FindClass(env, classname); - if (clazz == NULL || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) { + if (!clazz || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed to register methods of %s", classname); return; } @@ -566,28 +566,28 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl /* Save JNIEnv of SDLActivity */ Android_JNI_SetEnv(env); - if (mJavaVM == NULL) { + if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to found a JavaVM"); } /* Use a mutex to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'. * (Eg. Java sending Touch events, while native code is destroying the main SDL_Window. ) */ - if (Android_ActivityMutex == NULL) { + if (!Android_ActivityMutex) { Android_ActivityMutex = SDL_CreateMutex(); /* Could this be created twice if onCreate() is called a second time ? */ } - if (Android_ActivityMutex == NULL) { + if (!Android_ActivityMutex) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ActivityMutex mutex"); } Android_PauseSem = SDL_CreateSemaphore(0); - if (Android_PauseSem == NULL) { + if (!Android_PauseSem) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_PauseSem semaphore"); } Android_ResumeSem = SDL_CreateSemaphore(0); - if (Android_ResumeSem == NULL) { + if (!Android_ResumeSem) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ResumeSem semaphore"); } @@ -1557,7 +1557,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, int device_id, SDL_AudioSpec *spe __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for output"); result = (*env)->CallStaticObjectMethod(env, mAudioManagerClass, midAudioOpen, spec->freq, audioformat, spec->channels, spec->samples, device_id); } - if (result == NULL) { + if (!result) { /* Error during audio initialization, error printed from Java */ return SDL_SetError("Java-side initialization failed"); } @@ -1618,7 +1618,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, int device_id, SDL_AudioSpec *spe return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat); } - if (jbufobj == NULL) { + if (!jbufobj) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer"); return SDL_OutOfMemory(); } @@ -1910,7 +1910,7 @@ static void Internal_Android_Create_AssetManager() javaAssetManagerRef = (*env)->NewGlobalRef(env, javaAssetManager); asset_manager = AAssetManager_fromJava(env, javaAssetManagerRef); - if (asset_manager == NULL) { + if (!asset_manager) { (*env)->DeleteGlobalRef(env, javaAssetManagerRef); Android_JNI_ExceptionOccurred(SDL_TRUE); } @@ -1934,16 +1934,16 @@ int Android_JNI_FileOpen(SDL_RWops *ctx, AAsset *asset = NULL; ctx->hidden.androidio.asset = NULL; - if (asset_manager == NULL) { + if (!asset_manager) { Internal_Android_Create_AssetManager(); } - if (asset_manager == NULL) { + if (!asset_manager) { return SDL_SetError("Couldn't create asset manager"); } asset = AAssetManager_open(asset_manager, fileName, AASSET_MODE_UNKNOWN); - if (asset == NULL) { + if (!asset) { return SDL_SetError("Couldn't open asset '%s'", fileName); } @@ -2022,7 +2022,7 @@ char *Android_JNI_GetClipboardText(void) (*env)->DeleteLocalRef(env, string); } - return (text == NULL) ? SDL_strdup("") : text; + return (!text) ? SDL_strdup("") : text; } SDL_bool Android_JNI_HasClipboardText(void) @@ -2343,7 +2343,7 @@ void *SDL_AndroidGetActivity(void) /* See SDL_system.h for caveats on using this function. */ JNIEnv *env = Android_JNI_GetEnv(); - if (env == NULL) { + if (!env) { return NULL; } @@ -2397,7 +2397,7 @@ const char *SDL_AndroidGetInternalStoragePath(void) { static char *s_AndroidInternalFilesPath = NULL; - if (s_AndroidInternalFilesPath == NULL) { + if (!s_AndroidInternalFilesPath) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); jmethodID mid; jobject context; @@ -2490,7 +2490,7 @@ const char *SDL_AndroidGetExternalStoragePath(void) { static char *s_AndroidExternalFilesPath = NULL; - if (s_AndroidExternalFilesPath == NULL) { + if (!s_AndroidExternalFilesPath) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); jmethodID mid; jobject context; @@ -2646,16 +2646,16 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) /* Need to re-create the asset manager if locale has changed (SDL_LOCALECHANGED) */ Internal_Android_Destroy_AssetManager(); - if (asset_manager == NULL) { + if (!asset_manager) { Internal_Android_Create_AssetManager(); } - if (asset_manager == NULL) { + if (!asset_manager) { return -1; } cfg = AConfiguration_new(); - if (cfg == NULL) { + if (!cfg) { return -1; } diff --git a/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/src/core/freebsd/SDL_evdev_kbd_freebsd.c index a4fd0e48b..ca0ad4562 100644 --- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -88,7 +88,7 @@ static void kbd_cleanup(void) { struct mouse_info mData; SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state; - if (kbd == NULL) { + if (!kbd) { return; } kbd_cleanup_state = NULL; @@ -179,7 +179,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx, signum; - if (kbd_cleanup_state != NULL) { + if (kbd_cleanup_state) { return; } kbd_cleanup_state = kbd; @@ -231,7 +231,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) SDL_zero(mData); mData.operation = MOUSE_HIDE; kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(SDL_EVDEV_keyboard_state)); - if (kbd == NULL) { + if (!kbd) { return NULL; } @@ -297,7 +297,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) { struct mouse_info mData; - if (kbd == NULL) { + if (!kbd) { return; } SDL_zero(mData); @@ -487,7 +487,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, unsigned int final_key_state; unsigned int map_from_key_sym; - if (kbd == NULL) { + if (!kbd) { return; } diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index 353e0777c..b82ac11df 100644 --- a/src/core/linux/SDL_dbus.c +++ b/src/core/linux/SDL_dbus.c @@ -99,7 +99,7 @@ static int LoadDBUSSyms(void) static void UnloadDBUSLibrary(void) { - if (dbus_handle != NULL) { + if (dbus_handle) { SDL_UnloadObject(dbus_handle); dbus_handle = NULL; } @@ -108,9 +108,9 @@ static void UnloadDBUSLibrary(void) static int LoadDBUSLibrary(void) { int retval = 0; - if (dbus_handle == NULL) { + if (!dbus_handle) { dbus_handle = SDL_LoadObject(dbus_library); - if (dbus_handle == NULL) { + if (!dbus_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -202,7 +202,7 @@ void SDL_DBus_Quit(void) SDL_DBusContext *SDL_DBus_GetContext(void) { - if (dbus_handle == NULL || !dbus.session_conn) { + if (!dbus_handle || !dbus.session_conn) { SDL_DBus_Init(); } @@ -363,7 +363,7 @@ SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char * void SDL_DBus_ScreensaverTickle(void) { - if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */ + if (screensaver_cookie == 0 && !inhibit_handle) { /* no need to tickle if we're inhibiting. */ /* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */ SDL_DBus_CallVoidMethod("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID); SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID); @@ -411,7 +411,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) { const char *default_inhibit_reason = "Playing a game"; - if ((inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL))) { + if ((inhibit && (screensaver_cookie != 0 || inhibit_handle)) || (!inhibit && (screensaver_cookie == 0 && !inhibit_handle))) { return SDL_TRUE; } @@ -435,12 +435,12 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) const char *key = "reason"; const char *reply = NULL; const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME); - if (reason == NULL || !reason[0]) { + if (!reason || !reason[0]) { reason = default_inhibit_reason; } msg = dbus.message_new_method_call(bus_name, path, interface, "Inhibit"); - if (msg == NULL) { + if (!msg) { return SDL_FALSE; } @@ -477,10 +477,10 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) if (inhibit) { const char *app = SDL_GetHint(SDL_HINT_APP_NAME); const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME); - if (app == NULL || !app[0]) { + if (!app || !app[0]) { app = "My SDL application"; } - if (reason == NULL || !reason[0]) { + if (!reason || !reason[0]) { reason = default_inhibit_reason; } diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index 89777e69e..cd27e2f16 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -162,9 +162,9 @@ static void SDL_EVDEV_UpdateKeyboardMute(void) int SDL_EVDEV_Init(void) { - if (_this == NULL) { + if (!_this) { _this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); - if (_this == NULL) { + if (!_this) { return SDL_OutOfMemory(); } @@ -226,7 +226,7 @@ int SDL_EVDEV_Init(void) void SDL_EVDEV_Quit(void) { - if (_this == NULL) { + if (!_this) { return; } @@ -239,14 +239,14 @@ void SDL_EVDEV_Quit(void) #endif /* SDL_USE_LIBUDEV */ /* Remove existing devices */ - while (_this->first != NULL) { + while (_this->first) { SDL_EVDEV_device_removed(_this->first->path); } SDL_EVDEV_kbd_quit(_this->kbd); - SDL_assert(_this->first == NULL); - SDL_assert(_this->last == NULL); + SDL_assert(!_this->first); + SDL_assert(!_this->last); SDL_assert(_this->num_devices == 0); SDL_free(_this); @@ -258,7 +258,7 @@ void SDL_EVDEV_Quit(void) static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path) { - if (dev_path == NULL) { + if (!dev_path) { return; } @@ -296,7 +296,7 @@ int SDL_EVDEV_GetDeviceCount(int device_class) SDL_evdevlist_item *item; int count = 0; - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { if ((item->udev_class & device_class) == device_class) { ++count; } @@ -326,7 +326,7 @@ void SDL_EVDEV_Poll(void) mouse = SDL_GetMouse(); - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { while ((len = read(item->fd, events, sizeof(events))) > 0) { len /= sizeof(events[0]); for (i = 0; i < len; ++i) { @@ -625,7 +625,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) } item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data)); - if (item->touchscreen_data == NULL) { + if (!item->touchscreen_data) { return SDL_OutOfMemory(); } @@ -636,7 +636,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) } item->touchscreen_data->name = SDL_strdup(name); - if (item->touchscreen_data->name == NULL) { + if (!item->touchscreen_data->name) { SDL_free(item->touchscreen_data); return SDL_OutOfMemory(); } @@ -691,7 +691,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) item->touchscreen_data->slots = SDL_calloc( item->touchscreen_data->max_slots, sizeof(*item->touchscreen_data->slots)); - if (item->touchscreen_data->slots == NULL) { + if (!item->touchscreen_data->slots) { SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); return SDL_OutOfMemory(); @@ -752,7 +752,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item) sizeof(*mt_req_values) * item->touchscreen_data->max_slots; mt_req_code = SDL_calloc(1, mt_req_size); - if (mt_req_code == NULL) { + if (!mt_req_code) { return; } @@ -858,14 +858,14 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) unsigned long relbit[NBITS(REL_MAX)] = { 0 }; /* Check to make sure it's not already in list. */ - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { if (SDL_strcmp(dev_path, item->path) == 0) { return -1; /* already have this one */ } } item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } @@ -876,7 +876,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) } item->path = SDL_strdup(dev_path); - if (item->path == NULL) { + if (!item->path) { close(item->fd); SDL_free(item); return SDL_OutOfMemory(); @@ -910,7 +910,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) } } - if (_this->last == NULL) { + if (!_this->last) { _this->first = _this->last = item; } else { _this->last->next = item; @@ -929,10 +929,10 @@ static int SDL_EVDEV_device_removed(const char *dev_path) SDL_evdevlist_item *item; SDL_evdevlist_item *prev = NULL; - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(dev_path, item->path) == 0) { - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(_this->first == item); diff --git a/src/core/linux/SDL_evdev_kbd.c b/src/core/linux/SDL_evdev_kbd.c index 823bcd64a..71b3732db 100644 --- a/src/core/linux/SDL_evdev_kbd.c +++ b/src/core/linux/SDL_evdev_kbd.c @@ -174,7 +174,7 @@ static int fatal_signals[] = { static void kbd_cleanup(void) { SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state; - if (kbd == NULL) { + if (!kbd) { return; } kbd_cleanup_state = NULL; @@ -259,7 +259,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx, signum; - if (kbd_cleanup_state != NULL) { + if (kbd_cleanup_state) { return; } kbd_cleanup_state = kbd; @@ -385,7 +385,7 @@ static int kbd_vt_init(int console_fd) vt_release_signal = find_free_signal(kbd_vt_release_signal_action); vt_acquire_signal = find_free_signal(kbd_vt_acquire_signal_action); - if (!vt_release_signal || !vt_acquire_signal ) { + if (!vt_release_signal || !vt_acquire_signal) { kbd_vt_quit(console_fd); return -1; } @@ -429,7 +429,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) char shift_state[sizeof(long)] = { TIOCL_GETSHIFTSTATE, 0 }; kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd)); - if (kbd == NULL) { + if (!kbd) { return NULL; } @@ -465,7 +465,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted) { - if (state == NULL) { + if (!state) { return; } @@ -499,7 +499,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted) void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data) { - if (state == NULL) { + if (!state) { return; } @@ -520,7 +520,7 @@ void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state) void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) { - if (state == NULL) { + if (!state) { return; } @@ -893,7 +893,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode unsigned short *key_map; unsigned short keysym; - if (state == NULL) { + if (!state) { return; } @@ -901,7 +901,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode shift_final = (state->shift_state | state->slockstate) ^ state->lockstate; key_map = state->key_maps[shift_final]; - if (key_map == NULL) { + if (!key_map) { /* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */ state->shift_state = 0; state->slockstate = 0; diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index 5f76a626e..a0e13ee19 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -438,7 +438,7 @@ void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) } focused_win = SDL_GetKeyboardFocus(); - if (focused_win == NULL) { + if (!focused_win) { return; } diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index a81ba1d4d..e6b6eb82e 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -112,7 +112,7 @@ static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, S } dbus->message_iter_get_basic(inside, &struct_id); - if (struct_id == NULL || SDL_strncmp(struct_id, struct_id, id_size) != 0) { + if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) { return SDL_FALSE; } return SDL_TRUE; @@ -306,7 +306,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path) FILE *addr_file; addr_file = fopen(file_path, "r"); - if (addr_file == NULL) { + if (!addr_file) { return NULL; } @@ -351,7 +351,7 @@ static char *IBus_GetDBusAddressFilename(void) } dbus = SDL_DBus_GetContext(); - if (dbus == NULL) { + if (!dbus) { return NULL; } @@ -365,7 +365,7 @@ static char *IBus_GetDBusAddressFilename(void) and look up the address from a filepath using all those bits, eek. */ disp_env = SDL_getenv("DISPLAY"); - if (disp_env == NULL || !*disp_env) { + if (!disp_env || !*disp_env) { display = SDL_strdup(":0.0"); } else { display = SDL_strdup(disp_env); @@ -375,7 +375,7 @@ static char *IBus_GetDBusAddressFilename(void) disp_num = SDL_strrchr(display, ':'); screen_num = SDL_strrchr(display, '.'); - if (disp_num == NULL) { + if (!disp_num) { SDL_free(display); return NULL; } @@ -389,7 +389,7 @@ static char *IBus_GetDBusAddressFilename(void) if (!*host) { const char *session = SDL_getenv("XDG_SESSION_TYPE"); - if (session != NULL && SDL_strcmp(session, "wayland") == 0) { + if (session && SDL_strcmp(session, "wayland") == 0) { host = "unix-wayland"; } else { host = "unix"; @@ -403,7 +403,7 @@ static char *IBus_GetDBusAddressFilename(void) SDL_strlcpy(config_dir, conf_env, sizeof(config_dir)); } else { const char *home_env = SDL_getenv("HOME"); - if (home_env == NULL || !*home_env) { + if (!home_env || !*home_env) { SDL_free(display); return NULL; } @@ -412,7 +412,7 @@ static char *IBus_GetDBusAddressFilename(void) key = SDL_DBus_GetLocalMachineId(); - if (key == NULL) { + if (!key) { SDL_free(display); return NULL; } @@ -473,7 +473,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) ibus_input_interface = IBUS_INPUT_INTERFACE; ibus_conn = dbus->connection_open_private(addr, NULL); - if (ibus_conn == NULL) { + if (!ibus_conn) { return SDL_FALSE; /* oh well. */ } @@ -513,7 +513,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus) { - if (dbus == NULL) { + if (!dbus) { return SDL_FALSE; } @@ -533,7 +533,7 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus) struct inotify_event *event = (struct inotify_event *)p; if (event->len > 0) { char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/'); - if (addr_file_no_path == NULL) { + if (!addr_file_no_path) { return SDL_FALSE; } @@ -570,12 +570,12 @@ SDL_bool SDL_IBus_Init(void) char *addr; char *addr_file_dir; - if (addr_file == NULL) { + if (!addr_file) { return SDL_FALSE; } addr = IBus_ReadAddressFromFile(addr_file); - if (addr == NULL) { + if (!addr) { SDL_free(addr_file); return SDL_FALSE; } @@ -661,7 +661,7 @@ static void IBus_SimpleMessage(const char *method) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if ((input_ctx_path != NULL) && (IBus_CheckConnection(dbus))) { + if ((input_ctx_path) && (IBus_CheckConnection(dbus))) { SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, method, DBUS_TYPE_INVALID); } } @@ -712,7 +712,7 @@ void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) } focused_win = SDL_GetKeyboardFocus(); - if (focused_win == NULL) { + if (!focused_win) { return; } diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c index f40e83c5a..2296885fb 100644 --- a/src/core/linux/SDL_ime.c +++ b/src/core/linux/SDL_ime.c @@ -56,9 +56,9 @@ static void InitIME() /* See if fcitx IME support is being requested */ #ifdef HAVE_FCITX - if (SDL_IME_Init_Real == NULL && + if (!SDL_IME_Init_Real && ((im_module && SDL_strcmp(im_module, "fcitx") == 0) || - (im_module == NULL && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) { + (!im_module && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) { SDL_IME_Init_Real = SDL_Fcitx_Init; SDL_IME_Quit_Real = SDL_Fcitx_Quit; SDL_IME_SetFocus_Real = SDL_Fcitx_SetFocus; @@ -71,7 +71,7 @@ static void InitIME() /* default to IBus */ #ifdef HAVE_IBUS_IBUS_H - if (SDL_IME_Init_Real == NULL) { + if (!SDL_IME_Init_Real) { SDL_IME_Init_Real = SDL_IBus_Init; SDL_IME_Quit_Real = SDL_IBus_Quit; SDL_IME_SetFocus_Real = SDL_IBus_SetFocus; diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c index 57406c6df..9bbc7d54f 100644 --- a/src/core/linux/SDL_threadprio.c +++ b/src/core/linux/SDL_threadprio.c @@ -116,19 +116,19 @@ static void rtkit_initialize() dbus_conn = get_rtkit_dbus_connection(); /* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */ - if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel", + if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel", DBUS_TYPE_INT32, &rtkit_min_nice_level)) { rtkit_min_nice_level = -20; } /* Try getting maximum realtime priority: this can be less than the POSIX default (99). */ - if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority", + if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority", DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) { rtkit_max_realtime_priority = 99; } /* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */ - if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax", + if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax", DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) { rtkit_max_rttime_usec = 200000; } @@ -207,7 +207,7 @@ static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level) nice = rtkit_min_nice_level; } - if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn, + if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID", DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID, DBUS_TYPE_INVALID)) { @@ -238,7 +238,7 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority) // go through to determine whether it really needs to fail or not. rtkit_initialize_realtime_thread(); - if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn, + if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID", DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID, DBUS_TYPE_INVALID)) { diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index 39368c7e0..7eab8200c 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -52,7 +52,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(_this->udev_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return SDL_FALSE; } @@ -100,7 +100,7 @@ static int SDL_UDEV_load_syms(void) static SDL_bool SDL_UDEV_hotplug_update_available(void) { - if (_this->udev_mon != NULL) { + if (_this->udev_mon) { const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon); if (SDL_IOReady(fd, SDL_IOR_READ, 0)) { return SDL_TRUE; @@ -113,9 +113,9 @@ int SDL_UDEV_Init(void) { int retval = 0; - if (_this == NULL) { + if (!_this) { _this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); - if (_this == NULL) { + if (!_this) { return SDL_OutOfMemory(); } @@ -130,13 +130,13 @@ int SDL_UDEV_Init(void) */ _this->udev = _this->syms.udev_new(); - if (_this->udev == NULL) { + if (!_this->udev) { SDL_UDEV_Quit(); return SDL_SetError("udev_new() failed"); } _this->udev_mon = _this->syms.udev_monitor_new_from_netlink(_this->udev, "udev"); - if (_this->udev_mon == NULL) { + if (!_this->udev_mon) { SDL_UDEV_Quit(); return SDL_SetError("udev_monitor_new_from_netlink() failed"); } @@ -158,7 +158,7 @@ void SDL_UDEV_Quit(void) { SDL_UDEV_CallbackList *item; - if (_this == NULL) { + if (!_this) { return; } @@ -166,17 +166,17 @@ void SDL_UDEV_Quit(void) if (_this->ref_count < 1) { - if (_this->udev_mon != NULL) { + if (_this->udev_mon) { _this->syms.udev_monitor_unref(_this->udev_mon); _this->udev_mon = NULL; } - if (_this->udev != NULL) { + if (_this->udev) { _this->syms.udev_unref(_this->udev); _this->udev = NULL; } /* Remove existing devices */ - while (_this->first != NULL) { + while (_this->first) { item = _this->first; _this->first = _this->first->next; SDL_free(item); @@ -194,12 +194,12 @@ void SDL_UDEV_Scan(void) struct udev_list_entry *devs = NULL; struct udev_list_entry *item = NULL; - if (_this == NULL) { + if (!_this) { return; } enumerate = _this->syms.udev_enumerate_new(_this->udev); - if (enumerate == NULL) { + if (!enumerate) { SDL_UDEV_Quit(); SDL_SetError("udev_enumerate_new() failed"); return; @@ -213,7 +213,7 @@ void SDL_UDEV_Scan(void) for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) { const char *path = _this->syms.udev_list_entry_get_name(item); struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path); - if (dev != NULL) { + if (dev) { device_event(SDL_UDEV_DEVICEADDED, dev); _this->syms.udev_device_unref(dev); } @@ -229,12 +229,12 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 struct udev_list_entry *item = NULL; SDL_bool found = SDL_FALSE; - if (_this == NULL) { + if (!_this) { return SDL_FALSE; } enumerate = _this->syms.udev_enumerate_new(_this->udev); - if (enumerate == NULL) { + if (!enumerate) { SDL_SetError("udev_enumerate_new() failed"); return SDL_FALSE; } @@ -244,7 +244,7 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 for (item = devs; item && !found; item = _this->syms.udev_list_entry_get_next(item)) { const char *path = _this->syms.udev_list_entry_get_name(item); struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path); - if (dev != NULL) { + if (dev) { const char *val = NULL; const char *existing_path; @@ -253,17 +253,17 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 found = SDL_TRUE; val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID"); - if (val != NULL) { + if (val) { *vendor = (Uint16)SDL_strtol(val, NULL, 16); } val = _this->syms.udev_device_get_property_value(dev, "ID_MODEL_ID"); - if (val != NULL) { + if (val) { *product = (Uint16)SDL_strtol(val, NULL, 16); } val = _this->syms.udev_device_get_property_value(dev, "ID_REVISION"); - if (val != NULL) { + if (val) { *version = (Uint16)SDL_strtol(val, NULL, 16); } } @@ -277,11 +277,11 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 void SDL_UDEV_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { return; } - if (_this->udev_handle != NULL) { + if (_this->udev_handle) { SDL_UnloadObject(_this->udev_handle); _this->udev_handle = NULL; } @@ -291,7 +291,7 @@ int SDL_UDEV_LoadLibrary(void) { int retval = 0, i; - if (_this == NULL) { + if (!_this) { return SDL_SetError("UDEV not initialized"); } @@ -302,9 +302,9 @@ int SDL_UDEV_LoadLibrary(void) #ifdef SDL_UDEV_DYNAMIC /* Check for the build environment's libudev first */ - if (_this->udev_handle == NULL) { + if (!_this->udev_handle) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC); - if (_this->udev_handle != NULL) { + if (_this->udev_handle) { retval = SDL_UDEV_load_syms(); if (retval < 0) { SDL_UDEV_UnloadLibrary(); @@ -313,10 +313,10 @@ int SDL_UDEV_LoadLibrary(void) } #endif - if (_this->udev_handle == NULL) { + if (!_this->udev_handle) { for (i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]); - if (_this->udev_handle != NULL) { + if (_this->udev_handle) { retval = SDL_UDEV_load_syms(); if (retval < 0) { SDL_UDEV_UnloadLibrary(); @@ -326,7 +326,7 @@ int SDL_UDEV_LoadLibrary(void) } } - if (_this->udev_handle == NULL) { + if (!_this->udev_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } @@ -345,7 +345,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch SDL_memset(bitmask, 0, bitmask_len * sizeof(*bitmask)); value = _this->syms.udev_device_get_sysattr_value(pdev, attr); - if (value == NULL) { + if (!value) { return; } @@ -379,7 +379,7 @@ static int guess_device_class(struct udev_device *dev) while (pdev && !_this->syms.udev_device_get_sysattr_value(pdev, "capabilities/ev")) { pdev = _this->syms.udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL); } - if (pdev == NULL) { + if (!pdev) { return 0; } @@ -403,7 +403,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) SDL_UDEV_CallbackList *item; path = _this->syms.udev_device_get_devnode(dev); - if (path == NULL) { + if (!path) { return; } @@ -414,23 +414,23 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER"); if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) && - val != NULL && SDL_strcmp(val, "1") == 0) { + val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_MOUSE; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; } @@ -441,14 +441,14 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183 */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_KEYBOARD; } if (devclass == 0) { /* Fall back to old style input classes */ val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS"); - if (val != NULL) { + if (val) { if (SDL_strcmp(val, "joystick") == 0) { devclass = SDL_UDEV_DEVICE_JOYSTICK; } else if (SDL_strcmp(val, "mouse") == 0) { @@ -468,7 +468,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) } /* Process callbacks */ - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { item->callback(type, devclass, path); } } @@ -478,13 +478,13 @@ void SDL_UDEV_Poll(void) struct udev_device *dev = NULL; const char *action = NULL; - if (_this == NULL) { + if (!_this) { return; } while (SDL_UDEV_hotplug_update_available()) { dev = _this->syms.udev_monitor_receive_device(_this->udev_mon); - if (dev == NULL) { + if (!dev) { break; } action = _this->syms.udev_device_get_action(dev); @@ -505,13 +505,13 @@ int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) { SDL_UDEV_CallbackList *item; item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } item->callback = cb; - if (_this->last == NULL) { + if (!_this->last) { _this->first = _this->last = item; } else { _this->last->next = item; @@ -526,14 +526,14 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) SDL_UDEV_CallbackList *item; SDL_UDEV_CallbackList *prev = NULL; - if (_this == NULL) { + if (!_this) { return; } - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { /* found it, remove it. */ if (item->callback == cb) { - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(_this->first == item); diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index 583c42014..99d63a9f2 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -423,7 +423,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev) #endif SDL_WSCONS_input_data *input = (SDL_WSCONS_input_data *)SDL_calloc(1, sizeof(SDL_WSCONS_input_data)); - if (input == NULL) { + if (!input) { return input; } input->fd = open(dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); @@ -433,7 +433,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev) return NULL; } input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES); - if (input->keymap.map == NULL) { + if (!input->keymap.map) { free(input); return NULL; } @@ -583,7 +583,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input) keysym_t *group; keysym_t ksym, result; - if (input == NULL) { + if (!input) { return; } if ((n = read(input->fd, events, sizeof(events))) > 0) { @@ -927,7 +927,7 @@ void SDL_WSCONS_PumpEvents() for (i = 0; i < 4; i++) { updateKeyboard(inputs[i]); } - if (mouseInputData != NULL) { + if (mouseInputData) { updateMouse(mouseInputData); } } diff --git a/src/core/openbsd/SDL_wscons_mouse.c b/src/core/openbsd/SDL_wscons_mouse.c index 617cea7bc..6246956d8 100644 --- a/src/core/openbsd/SDL_wscons_mouse.c +++ b/src/core/openbsd/SDL_wscons_mouse.c @@ -42,7 +42,7 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse() #endif SDL_WSCONS_mouse_input_data *mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data)); - if (mouseInputData == NULL) { + if (!mouseInputData) { return NULL; } mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC); @@ -126,7 +126,7 @@ void updateMouse(SDL_WSCONS_mouse_input_data *inputData) void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *inputData) { - if (inputData == NULL) { + if (!inputData) { return; } close(inputData->fd); diff --git a/src/core/os2/geniconv/os2cp.c b/src/core/os2/geniconv/os2cp.c index ae8bec7b4..2d44860ff 100644 --- a/src/core/os2/geniconv/os2cp.c +++ b/src/core/os2/geniconv/os2cp.c @@ -357,7 +357,7 @@ unsigned long os2cpFromName(char *cp) PCHAR pcEnd; CHAR acBuf[64]; - if (cp == NULL) { + if (!cp) { ULONG aulCP[3]; ULONG cCP; return (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR)? 0 : aulCP[0]; @@ -368,7 +368,7 @@ unsigned long os2cpFromName(char *cp) } pcEnd = SDL_strchr(cp, ' '); - if (pcEnd == NULL) { + if (!pcEnd) { pcEnd = SDL_strchr(cp, '\0'); } ulNext = pcEnd - cp; diff --git a/src/core/os2/geniconv/os2iconv.c b/src/core/os2/geniconv/os2iconv.c index 0e75484cf..2e7d97a04 100644 --- a/src/core/os2/geniconv/os2iconv.c +++ b/src/core/os2/geniconv/os2iconv.c @@ -76,7 +76,7 @@ static int _createUconvObj(const char *code, UconvObject *uobj) const unsigned char *ch = (const unsigned char *)code; - if (code == NULL) + if (!code) uc_code[0] = 0; else { for (i = 0; i < MAX_CP_NAME_LEN; i++) { @@ -119,10 +119,10 @@ iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode) int rc; iuconv_obj *iuobj; - if (tocode == NULL) { + if (!tocode) { tocode = ""; } - if (fromcode == NULL) { + if (!fromcode) { fromcode = ""; } @@ -169,7 +169,7 @@ size_t _System os2_iconv(iconv_t cd, int rc; size_t ret = (size_t)(-1); - if (uo_tocode == NULL && uo_fromcode == NULL) { + if (!uo_tocode && !uo_fromcode) { uc_buf_len = SDL_min(*inbytesleft, *outbytesleft); SDL_memcpy(*outbuf, *inbuf, uc_buf_len); *inbytesleft -= uc_buf_len; diff --git a/src/core/os2/geniconv/sys2utf8.c b/src/core/os2/geniconv/sys2utf8.c index 1c8be8a17..1c3305c79 100644 --- a/src/core/os2/geniconv/sys2utf8.c +++ b/src/core/os2/geniconv/sys2utf8.c @@ -95,7 +95,7 @@ char *StrUTF8New(int to_utf8, char *str, int c_str) int c_newstr = (((c_str > 4) ? c_str : 4) + 1) * 2; char * newstr = (char *) SDL_malloc(c_newstr); - if (newstr == NULL) { + if (!newstr) { return NULL; } diff --git a/src/core/windows/SDL_hid.c b/src/core/windows/SDL_hid.c index 40829502e..9ebda7015 100644 --- a/src/core/windows/SDL_hid.c +++ b/src/core/windows/SDL_hid.c @@ -58,9 +58,9 @@ int WIN_LoadHIDDLL(void) SDL_HidP_GetValueCaps = (HidP_GetValueCaps_t)GetProcAddress(s_pHIDDLL, "HidP_GetValueCaps"); SDL_HidP_MaxDataListLength = (HidP_MaxDataListLength_t)GetProcAddress(s_pHIDDLL, "HidP_MaxDataListLength"); SDL_HidP_GetData = (HidP_GetData_t)GetProcAddress(s_pHIDDLL, "HidP_GetData"); - if (SDL_HidD_GetManufacturerString == NULL || SDL_HidD_GetProductString == NULL || - SDL_HidP_GetCaps == NULL || SDL_HidP_GetButtonCaps == NULL || - SDL_HidP_GetValueCaps == NULL || SDL_HidP_MaxDataListLength == NULL || SDL_HidP_GetData == NULL) { + if (!SDL_HidD_GetManufacturerString || !SDL_HidD_GetProductString || + !SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps || + !SDL_HidP_GetValueCaps || !SDL_HidP_MaxDataListLength || !SDL_HidP_GetData) { WIN_UnloadHIDDLL(); return -1; } diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index d2900f9cc..93ca729ab 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -136,7 +136,7 @@ static void SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAV } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); - if (devidlist == NULL) { + if (!devidlist) { return; /* oh well. */ } @@ -361,10 +361,10 @@ int SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture) const Uint64 timeout = SDL_GetTicks64() + 8000; /* intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep. */ HRESULT ret; - SDL_assert(device != NULL); + SDL_assert(device); while (SDL_TRUE) { - if (devid == NULL) { + if (!devid) { const EDataFlow dataflow = iscapture ? eCapture : eRender; ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_IMMDevice_role, device); } else { @@ -443,7 +443,7 @@ static void EnumerateEndpointsForFlow(const SDL_bool iscapture) } items = (EndpointItem *)SDL_calloc(total, sizeof(EndpointItem)); - if (items == NULL) { + if (!items) { return; /* oh well. */ } @@ -496,11 +496,11 @@ int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int isca HRESULT ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_IMMDevice_role, &device); if (FAILED(ret)) { - SDL_assert(device == NULL); + SDL_assert(!device); return WIN_SetErrorFromHRESULT("WASAPI can't find default audio endpoint", ret); } - if (name == NULL) { + if (!name) { name = &filler; } diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 350198eb7..807dedf6a 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -285,7 +285,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) } strw = (WCHAR *)SDL_malloc(len + sizeof(WCHAR)); - if (strw == NULL) { + if (!strw) { RegCloseKey(hkey); return WIN_StringToUTF8(name); /* oh well. */ } diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c index 1ebefcf2c..9f1317931 100644 --- a/src/core/windows/SDL_xinput.c +++ b/src/core/windows/SDL_xinput.c @@ -106,13 +106,13 @@ int WIN_LoadXInputDLL(void) /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */ SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, (LPCSTR)100); - if (SDL_XInputGetState == NULL) { + if (!SDL_XInputGetState) { SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, "XInputGetState"); } SDL_XInputSetState = (XInputSetState_t)GetProcAddress(s_pXInputDLL, "XInputSetState"); SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress(s_pXInputDLL, "XInputGetCapabilities"); SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation"); - if (SDL_XInputGetState == NULL || SDL_XInputSetState == NULL || SDL_XInputGetCapabilities == NULL) { + if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) { WIN_UnloadXInputDLL(); return -1; } diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp index 5fe6f3314..3b7280b3d 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -348,7 +348,7 @@ void SDL_WinRTApp::Run() // representation of command line arguments. int argc = 1; char **argv = (char **)SDL_malloc(2 * sizeof(*argv)); - if (argv == NULL) { + if (!argv) { return; } argv[0] = SDL_strdup("WinRTApp"); diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 337ae335a..bdc6b3e0b 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -1198,7 +1198,7 @@ void *SDL_SIMDRealloc(void *mem, const size_t len) ptr = (Uint8 *)SDL_realloc(mem, to_allocate); - if (ptr == NULL) { + if (!ptr) { return NULL; /* Out of memory, bail! */ } diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index 6151f0148..0cb6acf56 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -372,7 +372,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); } } @@ -385,9 +385,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/events/SDL_displayevents.c b/src/events/SDL_displayevents.c index ec5e158bb..d4dc2c2b2 100644 --- a/src/events/SDL_displayevents.c +++ b/src/events/SDL_displayevents.c @@ -29,7 +29,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data { int posted; - if (display == NULL) { + if (!display) { return 0; } switch (displayevent) { diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index cc18f84ed..960a12ffa 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -129,7 +129,7 @@ static unsigned long SDL_HashDollar(SDL_FloatPoint *points) static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) { - if (dst == NULL) { + if (!dst) { return 0; } @@ -200,7 +200,7 @@ static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *p (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate, (index + 1) * sizeof(SDL_DollarTemplate)); - if (dollarTemplate == NULL) { + if (!dollarTemplate) { return SDL_OutOfMemory(); } inTouch->dollarTemplate = dollarTemplate; @@ -217,7 +217,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path) { int index = -1; int i = 0; - if (inTouch == NULL) { + if (!inTouch) { if (SDL_numGestureTouches == 0) { return SDL_SetError("no gesture touch devices registered"); } @@ -238,7 +238,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) { int i, loaded = 0; SDL_GestureTouch *touch = NULL; - if (src == NULL) { + if (!src) { return 0; } if (touchId >= 0) { @@ -247,7 +247,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) touch = &SDL_gestureTouch[i]; } } - if (touch == NULL) { + if (!touch) { return SDL_SetError("given touch id not found"); } } @@ -475,7 +475,7 @@ int SDL_GestureAddTouch(SDL_TouchID touchId) (SDL_numGestureTouches + 1) * sizeof(SDL_GestureTouch)); - if (gestureTouch == NULL) { + if (!gestureTouch) { return SDL_OutOfMemory(); } @@ -589,7 +589,7 @@ void SDL_GestureProcessEvent(SDL_Event *event) SDL_GestureTouch *inTouch = SDL_GetGestureTouch(event->tfinger.touchId); /* Shouldn't be possible */ - if (inTouch == NULL) { + if (!inTouch) { return; } diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 5a14f85bf..a5ac86e3d 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -768,7 +768,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window) { SDL_Keyboard *keyboard = &SDL_keyboard; - if (keyboard->focus && window == NULL) { + if (keyboard->focus && !window) { /* We won't get anymore keyboard messages, so reset keyboard state */ SDL_ResetKeyboard(); } @@ -777,7 +777,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window) if (keyboard->focus && keyboard->focus != window) { /* new window shouldn't think it has mouse captured. */ - SDL_assert(window == NULL || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)); + SDL_assert(!window || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)); /* old window must lose an existing mouse capture. */ if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) { @@ -1183,7 +1183,7 @@ const char *SDL_GetScancodeName(SDL_Scancode scancode) } name = SDL_scancode_names[scancode]; - if (name != NULL) { + if (name) { return name; } @@ -1194,7 +1194,7 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name) { int i; - if (name == NULL || !*name) { + if (!name || !*name) { SDL_InvalidParamError("name"); return SDL_SCANCODE_UNKNOWN; } @@ -1254,7 +1254,7 @@ SDL_Keycode SDL_GetKeyFromName(const char *name) SDL_Keycode key; /* Check input */ - if (name == NULL) { + if (!name) { return SDLK_UNKNOWN; } diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index d609fdefd..1821cc029 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -491,7 +491,7 @@ int SDL_SetMouseSystemScale(int num_values, const float *values) } v = (float *)SDL_realloc(mouse->system_scale_values, num_values * sizeof(*values)); - if (v == NULL) { + if (!v) { return SDL_OutOfMemory(); } SDL_memcpy(v, values, num_values * sizeof(*values)); @@ -712,7 +712,7 @@ static SDL_MouseClickState *GetMouseClickState(SDL_Mouse *mouse, Uint8 button) if (button >= mouse->num_clickstates) { int i, count = button + 1; SDL_MouseClickState *clickstate = (SDL_MouseClickState *)SDL_realloc(mouse->clickstate, count * sizeof(*mouse->clickstate)); - if (clickstate == NULL) { + if (!clickstate) { return NULL; } mouse->clickstate = clickstate; @@ -734,7 +734,7 @@ static int SDL_PrivateSendMouseButton(SDL_Window *window, SDL_MouseID mouseID, U SDL_MouseInputSource *source; source = GetMouseInputSource(mouse, mouseID); - if (source == NULL) { + if (!source) { return 0; } buttonstate = source->buttonstate; @@ -1030,10 +1030,10 @@ Uint32 SDL_GetGlobalMouseState(int *x, int *y) int tmpx, tmpy; /* make sure these are never NULL for the backend implementations... */ - if (x == NULL) { + if (!x) { x = &tmpx; } - if (y == NULL) { + if (!y) { y = &tmpy; } @@ -1049,11 +1049,11 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ign { SDL_Mouse *mouse = SDL_GetMouse(); - if (window == NULL) { + if (!window) { window = mouse->focus; } - if (window == NULL) { + if (!window) { return; } @@ -1284,7 +1284,7 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, 0x0000FF00, 0x000000FF, 0xFF000000); - if (surface == NULL) { + if (!surface) { return NULL; } for (y = 0; y < h; ++y) { @@ -1317,7 +1317,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) SDL_Surface *temp = NULL; SDL_Cursor *cursor; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } @@ -1331,7 +1331,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) { temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (temp == NULL) { + if (!temp) { return NULL; } surface = temp; @@ -1398,7 +1398,7 @@ void SDL_SetCursor(SDL_Cursor *cursor) break; } } - if (found == NULL) { + if (!found) { SDL_SetError("Cursor not associated with the current mouse"); return; } @@ -1427,7 +1427,7 @@ SDL_Cursor *SDL_GetCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return NULL; } return mouse->cur_cursor; @@ -1437,7 +1437,7 @@ SDL_Cursor *SDL_GetDefaultCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return NULL; } return mouse->def_cursor; @@ -1448,7 +1448,7 @@ void SDL_FreeCursor(SDL_Cursor *cursor) SDL_Mouse *mouse = SDL_GetMouse(); SDL_Cursor *curr, *prev; - if (cursor == NULL) { + if (!cursor) { return; } @@ -1483,7 +1483,7 @@ int SDL_ShowCursor(int toggle) SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool shown; - if (mouse == NULL) { + if (!mouse) { return 0; } diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index cff41b056..c8f8dc110 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -138,7 +138,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID) SDL_Finger *SDL_GetTouchFinger(SDL_TouchID touchID, int index) { SDL_Touch *touch = SDL_GetTouch(touchID); - if (touch == NULL) { + if (!touch) { return NULL; } if (index < 0 || index >= touch->num_fingers) { @@ -161,7 +161,7 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name /* Add the touch to the list of touch */ touchDevices = (SDL_Touch **)SDL_realloc(SDL_touchDevices, (SDL_num_touch + 1) * sizeof(*touchDevices)); - if (touchDevices == NULL) { + if (!touchDevices) { return SDL_OutOfMemory(); } @@ -198,7 +198,7 @@ static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float if (touch->num_fingers == touch->max_fingers) { SDL_Finger **new_fingers; new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers + 1) * sizeof(*touch->fingers)); - if (new_fingers == NULL) { + if (!new_fingers) { return SDL_OutOfMemory(); } touch->fingers = new_fingers; @@ -241,7 +241,7 @@ int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_Mouse *mouse; SDL_Touch *touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return -1; } @@ -334,7 +334,7 @@ int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, posted = (SDL_PushEvent(&event) > 0); } } else { - if (finger == NULL) { + if (!finger) { /* This finger is already up */ return 0; } @@ -370,7 +370,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *windo float xrel, yrel, prel; touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return -1; } @@ -413,7 +413,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *windo } finger = SDL_GetFinger(touch, fingerid); - if (finger == NULL) { + if (!finger) { return SDL_SendTouch(id, fingerid, window, SDL_TRUE, x, y, pressure); } @@ -464,7 +464,7 @@ void SDL_DelTouch(SDL_TouchID id) index = SDL_GetTouchIndex(id); touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return; } diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 800c8aae5..9e3e791e7 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -84,7 +84,7 @@ int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, { int posted; - if (window == NULL) { + if (!window) { return 0; } switch (windowevent) { diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 2f66dcf41..ac345a93d 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -86,7 +86,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c DWORD must_exist, truncate; int a_mode; - if (context == NULL) { + if (!context) { return -1; /* failed (invalid call) */ } @@ -154,7 +154,7 @@ static Sint64 SDLCALL windows_file_size(SDL_RWops *context) { LARGE_INTEGER size; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_size: invalid context/file not opened"); } @@ -170,7 +170,7 @@ static Sint64 SDLCALL windows_file_seek(SDL_RWops *context, Sint64 offset, int w DWORD windowswhence; LARGE_INTEGER windowsoffset; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_seek: invalid context/file not opened"); } @@ -211,7 +211,7 @@ windows_file_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum) total_need = size * maxnum; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) { return 0; } @@ -264,7 +264,7 @@ windows_file_write(SDL_RWops *context, const void *ptr, size_t size, total_bytes = size * num; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) { return 0; } @@ -526,7 +526,7 @@ static int SDLCALL mem_close(SDL_RWops *context) SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) { SDL_RWops *rwops = NULL; - if (file == NULL || !*file || mode == NULL || !*mode) { + if (!file || !*file || !mode || !*mode) { SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); return NULL; } @@ -559,7 +559,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) /* Try to open the file from the asset system */ rwops = SDL_AllocRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ } @@ -576,7 +576,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) #elif defined(__WIN32__) || defined(__GDK__) rwops = SDL_AllocRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ } @@ -602,7 +602,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) #else FILE *fp = fopen(file, mode); #endif - if (fp == NULL) { + if (!fp) { SDL_SetError("Couldn't open %s", file); } else { rwops = SDL_RWFromFP(fp, SDL_TRUE); @@ -621,7 +621,7 @@ SDL_RWops *SDL_RWFromFP(FILE * fp, SDL_bool autoclose) SDL_RWops *rwops = NULL; rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = stdio_size; rwops->seek = stdio_seek; rwops->read = stdio_read; @@ -644,7 +644,7 @@ SDL_RWops *SDL_RWFromFP(void * fp, SDL_bool autoclose) SDL_RWops *SDL_RWFromMem(void *mem, int size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return rwops; } @@ -654,7 +654,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size) } rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -671,7 +671,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size) SDL_RWops *SDL_RWFromConstMem(const void *mem, int size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return rwops; } @@ -681,7 +681,7 @@ SDL_RWops *SDL_RWFromConstMem(const void *mem, int size) } rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -700,7 +700,7 @@ SDL_RWops *SDL_AllocRW(void) SDL_RWops *area; area = (SDL_RWops *)SDL_malloc(sizeof(*area)); - if (area == NULL) { + if (!area) { SDL_OutOfMemory(); } else { area->type = SDL_RWOPS_UNKNOWN; @@ -721,7 +721,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc) size_t size_read, size_total; void *data = NULL, *newdata; - if (src == NULL) { + if (!src) { SDL_InvalidParamError("src"); return NULL; } @@ -737,7 +737,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc) if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) { size = (size_total + FILE_CHUNK_SIZE); newdata = SDL_realloc(data, (size_t)(size + 1)); - if (newdata == NULL) { + if (!newdata) { SDL_free(data); data = NULL; SDL_OutOfMemory(); diff --git a/src/file/n3ds/SDL_rwopsromfs.c b/src/file/n3ds/SDL_rwopsromfs.c index 467bae3c4..11d148748 100644 --- a/src/file/n3ds/SDL_rwopsromfs.c +++ b/src/file/n3ds/SDL_rwopsromfs.c @@ -66,7 +66,7 @@ static FILE *TryOpenFile(const char *file, const char *mode) FILE *fp = NULL; fp = TryOpenInRomfs(file, mode); - if (fp == NULL) { + if (!fp) { fp = fopen(file, mode); } diff --git a/src/filesystem/android/SDL_sysfilesystem.c b/src/filesystem/android/SDL_sysfilesystem.c index 9df679013..1d7034430 100644 --- a/src/filesystem/android/SDL_sysfilesystem.c +++ b/src/filesystem/android/SDL_sysfilesystem.c @@ -45,7 +45,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) if (path) { size_t pathlen = SDL_strlen(path) + 2; char *fullpath = (char *)SDL_malloc(pathlen); - if (fullpath == NULL) { + if (!fullpath) { SDL_OutOfMemory(); return NULL; } diff --git a/src/filesystem/emscripten/SDL_sysfilesystem.c b/src/filesystem/emscripten/SDL_sysfilesystem.c index af39e3626..0216d0496 100644 --- a/src/filesystem/emscripten/SDL_sysfilesystem.c +++ b/src/filesystem/emscripten/SDL_sysfilesystem.c @@ -45,17 +45,17 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *ptr = NULL; size_t len = 0; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *)SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } diff --git a/src/filesystem/gdk/SDL_sysfilesystem.cpp b/src/filesystem/gdk/SDL_sysfilesystem.cpp index 517524bdb..3bbfca311 100644 --- a/src/filesystem/gdk/SDL_sysfilesystem.cpp +++ b/src/filesystem/gdk/SDL_sysfilesystem.cpp @@ -44,7 +44,7 @@ SDL_GetBasePath(void) while (SDL_TRUE) { void *ptr = SDL_realloc(path, buflen * sizeof(CHAR)); - if (ptr == NULL) { + if (!ptr) { SDL_free(path); SDL_OutOfMemory(); return NULL; @@ -90,13 +90,13 @@ SDL_GetPrefPath(const char *org, const char *app) HRESULT result; const char *csid = SDL_GetHint("SDL_GDK_SERVICE_CONFIGURATION_ID"); - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } /* This should be set before calling SDL_GetPrefPath! */ - if (csid == NULL) { + if (!csid) { SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Set SDL_GDK_SERVICE_CONFIGURATION_ID before calling SDL_GetPrefPath!"); return SDL_strdup("T:\\"); } diff --git a/src/filesystem/haiku/SDL_sysfilesystem.cc b/src/filesystem/haiku/SDL_sysfilesystem.cc index b6dc7d136..af039d5b3 100644 --- a/src/filesystem/haiku/SDL_sysfilesystem.cc +++ b/src/filesystem/haiku/SDL_sysfilesystem.cc @@ -52,11 +52,11 @@ char *SDL_GetBasePath(void) rc = path.GetParent(&path); /* chop filename, keep directory. */ SDL_assert(rc == B_OK); const char *str = path.Path(); - SDL_assert(str != NULL); + SDL_assert(str); const size_t len = SDL_strlen(str); char *retval = (char *) SDL_malloc(len + 2); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -75,11 +75,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) const char *append = "/config/settings/"; size_t len = SDL_strlen(home); - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } @@ -88,7 +88,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) } len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; char *retval = (char *) SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); } else { if (*org) { diff --git a/src/filesystem/n3ds/SDL_sysfilesystem.c b/src/filesystem/n3ds/SDL_sysfilesystem.c index fe2fd3ff8..dc47e558f 100644 --- a/src/filesystem/n3ds/SDL_sysfilesystem.c +++ b/src/filesystem/n3ds/SDL_sysfilesystem.c @@ -44,13 +44,13 @@ char *SDL_GetBasePath(void) char *SDL_GetPrefPath(const char *org, const char *app) { char *pref_path = NULL; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } pref_path = MakePrefPath(app); - if (pref_path == NULL) { + if (!pref_path) { return NULL; } diff --git a/src/filesystem/ps2/SDL_sysfilesystem.c b/src/filesystem/ps2/SDL_sysfilesystem.c index 86dcb14b6..0d560d000 100644 --- a/src/filesystem/ps2/SDL_sysfilesystem.c +++ b/src/filesystem/ps2/SDL_sysfilesystem.c @@ -82,11 +82,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *retval = NULL; size_t len; char *base = SDL_GetBasePath(); - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } diff --git a/src/filesystem/psp/SDL_sysfilesystem.c b/src/filesystem/psp/SDL_sysfilesystem.c index c163fa146..f348d3935 100644 --- a/src/filesystem/psp/SDL_sysfilesystem.c +++ b/src/filesystem/psp/SDL_sysfilesystem.c @@ -50,11 +50,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *retval = NULL; size_t len; char *base = SDL_GetBasePath(); - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } diff --git a/src/filesystem/riscos/SDL_sysfilesystem.c b/src/filesystem/riscos/SDL_sysfilesystem.c index 253734065..ff047d456 100644 --- a/src/filesystem/riscos/SDL_sysfilesystem.c +++ b/src/filesystem/riscos/SDL_sysfilesystem.c @@ -38,21 +38,21 @@ static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, { const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */ - if (buffer == NULL) { + if (!buffer) { /* This matches the logic in __unixify, with an additional byte for the * extra path separator. */ buf_len = SDL_strlen(ro_path) + 14 + 1; buffer = SDL_malloc(buf_len); - if (buffer == NULL) { + if (!buffer) { SDL_OutOfMemory(); return NULL; } } if (!__unixify_std(ro_path, buffer, buf_len, filetype)) { - if (in_buf == NULL) { + if (!in_buf) { SDL_free(buffer); } @@ -92,7 +92,7 @@ static char *canonicalisePath(const char *path, const char *pathVar) regs.r[5] = 1 - regs.r[5]; buf = SDL_malloc(regs.r[5]); - if (buf == NULL) { + if (!buf) { SDL_OutOfMemory(); return NULL; } @@ -121,7 +121,7 @@ static _kernel_oserror *createDirectoryRecursive(char *path) *ptr = '\0'; error = _kernel_swi(OS_File, ®s, ®s); *ptr = '.'; - if (error != NULL) { + if (error) { return error; } } @@ -141,13 +141,13 @@ char *SDL_GetBasePath(void) } canon = canonicalisePath((const char *)regs.r[0], "Run$Path"); - if (canon == NULL) { + if (!canon) { return NULL; } /* chop off filename. */ ptr = SDL_strrchr(canon, '.'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } @@ -162,22 +162,22 @@ char *SDL_GetPrefPath(const char *org, const char *app) size_t len; _kernel_oserror *error; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } canon = canonicalisePath("", "Run$Path"); - if (canon == NULL) { + if (!canon) { return NULL; } len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4; dir = (char *)SDL_malloc(len); - if (dir == NULL) { + if (!dir) { SDL_OutOfMemory(); SDL_free(canon); return NULL; @@ -192,7 +192,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) SDL_free(canon); error = createDirectoryRecursive(dir); - if (error != NULL) { + if (error) { SDL_SetError("Couldn't create directory: %s", error->errmess); SDL_free(dir); return NULL; diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 42e6e48ae..96a10396a 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -53,7 +53,7 @@ static char *readSymLink(const char *path) while (1) { char *ptr = (char *)SDL_realloc(retval, (size_t)len); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); break; } @@ -86,18 +86,18 @@ static char *search_path_for_binary(const char *bin) char *start = envr; char *ptr; - if (envr == NULL) { + if (!envr) { SDL_SetError("No $PATH set"); return NULL; } envr = SDL_strdup(envr); - if (envr == NULL) { + if (!envr) { SDL_OutOfMemory(); return NULL; } - SDL_assert(bin != NULL); + SDL_assert(bin); alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2; exe = (char *)SDL_malloc(alloc_size); @@ -118,7 +118,7 @@ static char *search_path_for_binary(const char *bin) } } start = ptr + 1; /* start points to beginning of next element. */ - } while (ptr != NULL); + } while (ptr); SDL_free(envr); SDL_free(exe); @@ -138,7 +138,7 @@ char *SDL_GetBasePath(void) const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) { retval = SDL_strdup(fullpath); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -152,13 +152,13 @@ char *SDL_GetBasePath(void) if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) { char *exe, *pwddst; char *realpathbuf = (char *)SDL_malloc(PATH_MAX + 1); - if (realpathbuf == NULL) { + if (!realpathbuf) { SDL_OutOfMemory(); return NULL; } cmdline = SDL_malloc(len); - if (cmdline == NULL) { + if (!cmdline) { SDL_free(realpathbuf); SDL_OutOfMemory(); return NULL; @@ -180,7 +180,7 @@ char *SDL_GetBasePath(void) } if (exe) { - if (pwddst == NULL) { + if (!pwddst) { if (realpath(exe, realpathbuf) != NULL) { retval = realpathbuf; } @@ -196,7 +196,7 @@ char *SDL_GetBasePath(void) } } - if (retval == NULL) { + if (!retval) { SDL_free(realpathbuf); } @@ -205,7 +205,7 @@ char *SDL_GetBasePath(void) #endif /* is a Linux-style /proc filesystem available? */ - if (retval == NULL && (access("/proc", F_OK) == 0)) { + if (!retval && (access("/proc", F_OK) == 0)) { /* !!! FIXME: after 2.0.6 ships, let's delete this code and just use the /proc/%llu version. There's no reason to have two copies of this plus all the #ifdefs. --ryan. */ @@ -219,7 +219,7 @@ char *SDL_GetBasePath(void) retval = SDL_LoadFile("/proc/self/exefile", NULL); #else retval = readSymLink("/proc/self/exe"); /* linux. */ - if (retval == NULL) { + if (!retval) { /* older kernels don't have /proc/self ... try PID version... */ char path[64]; const int rc = SDL_snprintf(path, sizeof(path), @@ -248,9 +248,9 @@ char *SDL_GetBasePath(void) /* If we had access to argv[0] here, we could check it for a path, or troll through $PATH looking for it, too. */ - if (retval != NULL) { /* chop off filename. */ + if (retval) { /* chop off filename. */ char *ptr = SDL_strrchr(retval, '/'); - if (ptr != NULL) { + if (ptr) { *(ptr + 1) = '\0'; } else { /* shouldn't happen, but just in case... */ SDL_free(retval); @@ -258,10 +258,10 @@ char *SDL_GetBasePath(void) } } - if (retval != NULL) { + if (retval) { /* try to shrink buffer... */ char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1); - if (ptr != NULL) { + if (ptr) { retval = ptr; /* oh well if it failed. */ } } @@ -284,18 +284,18 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *ptr = NULL; size_t len = 0; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } - if (envr == NULL) { + if (!envr) { /* You end up with "$HOME/.local/share/Game Name 2" */ envr = SDL_getenv("HOME"); - if (envr == NULL) { + if (!envr) { /* we could take heroic measures with /etc/passwd, but oh well. */ SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); return NULL; @@ -312,7 +312,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *)SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } diff --git a/src/filesystem/vita/SDL_sysfilesystem.c b/src/filesystem/vita/SDL_sysfilesystem.c index bb572708a..179cce254 100644 --- a/src/filesystem/vita/SDL_sysfilesystem.c +++ b/src/filesystem/vita/SDL_sysfilesystem.c @@ -53,11 +53,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *ptr = NULL; size_t len = 0; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } @@ -65,7 +65,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) len += SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *)SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index 8f512b7dc..fb72d1d91 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -42,7 +42,7 @@ char *SDL_GetBasePath(void) while (SDL_TRUE) { void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR)); - if (ptr == NULL) { + if (!ptr) { SDL_free(path); SDL_OutOfMemory(); return NULL; @@ -99,11 +99,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) size_t new_wpath_len = 0; BOOL api_result = FALSE; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } @@ -113,13 +113,13 @@ char *SDL_GetPrefPath(const char *org, const char *app) } worg = WIN_UTF8ToStringW(org); - if (worg == NULL) { + if (!worg) { SDL_OutOfMemory(); return NULL; } wapp = WIN_UTF8ToStringW(app); - if (wapp == NULL) { + if (!wapp) { SDL_free(worg); SDL_OutOfMemory(); return NULL; diff --git a/src/filesystem/winrt/SDL_sysfilesystem.cpp b/src/filesystem/winrt/SDL_sysfilesystem.cpp index b8ba6fdec..9fa6dc57d 100644 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -111,7 +111,7 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType) } const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType); - if (ucs2Path == NULL) { + if (!ucs2Path) { return NULL; } @@ -128,14 +128,14 @@ SDL_GetBasePath(void) size_t destPathLen; char *destPath = NULL; - if (srcPath == NULL) { + if (!srcPath) { SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError()); return NULL; } destPathLen = SDL_strlen(srcPath) + 2; destPath = (char *)SDL_malloc(destPathLen); - if (destPath == NULL) { + if (!destPath) { SDL_OutOfMemory(); return NULL; } @@ -161,16 +161,16 @@ SDL_GetPrefPath(const char *org, const char *app) size_t new_wpath_len = 0; BOOL api_result = FALSE; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER); - if (srcPath == NULL) { + if (!srcPath) { SDL_SetError("Unable to find a source path"); return NULL; } @@ -182,13 +182,13 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_wcslcpy(path, srcPath, SDL_arraysize(path)); worg = WIN_UTF8ToString(org); - if (worg == NULL) { + if (!worg) { SDL_OutOfMemory(); return NULL; } wapp = WIN_UTF8ToString(app); - if (wapp == NULL) { + if (!wapp) { SDL_free(worg); SDL_OutOfMemory(); return NULL; diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index ee64bcbd2..84472c040 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -55,7 +55,7 @@ static int ValidHaptic(SDL_Haptic *haptic) SDL_Haptic *hapticlist; valid = 0; - if (haptic != NULL) { + if (haptic) { hapticlist = SDL_haptics; while (hapticlist) { if (hapticlist == haptic) { @@ -124,7 +124,7 @@ SDL_Haptic *SDL_HapticOpen(int device_index) /* Create the haptic device */ haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic)); - if (haptic == NULL) { + if (!haptic) { SDL_OutOfMemory(); return NULL; } @@ -296,7 +296,7 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick) /* Create the haptic device */ haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic)); - if (haptic == NULL) { + if (!haptic) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -609,7 +609,7 @@ int SDL_HapticSetGain(SDL_Haptic *haptic, int gain) /* We use the envvar to get the maximum gain. */ env = SDL_getenv("SDL_HAPTIC_GAIN_MAX"); - if (env != NULL) { + if (env) { max_gain = SDL_atoi(env); /* Check for sanity. */ diff --git a/src/haptic/android/SDL_syshaptic.c b/src/haptic/android/SDL_syshaptic.c index 111c43c0b..a673532ac 100644 --- a/src/haptic/android/SDL_syshaptic.c +++ b/src/haptic/android/SDL_syshaptic.c @@ -70,7 +70,7 @@ static SDL_hapticlist_item *HapticByOrder(int index) return NULL; } while (index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); --index; item = item->next; } @@ -80,7 +80,7 @@ static SDL_hapticlist_item *HapticByOrder(int index) static SDL_hapticlist_item *HapticByDevId(int device_id) { SDL_hapticlist_item *item; - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (device_id == item->device_id) { /*SDL_Log("=+=+=+=+=+= HapticByDevId id [%d]", device_id);*/ return item; @@ -92,7 +92,7 @@ static SDL_hapticlist_item *HapticByDevId(int device_id) const char *SDL_SYS_HapticName(int index) { SDL_hapticlist_item *item = HapticByOrder(index); - if (item == NULL) { + if (!item) { SDL_SetError("No such device"); return NULL; } @@ -101,11 +101,11 @@ const char *SDL_SYS_HapticName(int index) static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item) { - if (item == NULL) { + if (!item) { SDL_SetError("No such device"); return NULL; } - if (item->haptic != NULL) { + if (item->haptic) { SDL_SetError("Haptic already opened"); return NULL; } @@ -117,7 +117,7 @@ static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item * haptic->neffects = 1; haptic->nplaying = haptic->neffects; haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); return NULL; } @@ -149,7 +149,7 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { SDL_hapticlist_item *item; item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id); - return (item != NULL) ? 1 : 0; + return (item) ? 1 : 0; } int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) @@ -257,18 +257,18 @@ int Android_AddHaptic(int device_id, const char *name) { SDL_hapticlist_item *item; item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return -1; } item->device_id = device_id; item->name = SDL_strdup(name); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); return -1; } - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -284,12 +284,12 @@ int Android_RemoveHaptic(int device_id) SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { /* found it, remove it. */ if (device_id == item->device_id) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index dea1ee7c2..3e4021ba7 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -157,7 +157,7 @@ int SDL_SYS_HapticInit(void) /* Get HID devices. */ match = IOServiceMatching(kIOHIDDeviceKey); - if (match == NULL) { + if (!match) { return SDL_SetError("Haptic: Failed to get IOServiceMatching."); } @@ -196,7 +196,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); --device_index; item = item->next; } @@ -229,7 +229,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device) } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return SDL_SetError("Could not allocate haptic storage"); } @@ -265,7 +265,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device) CFRelease(hidProperties); } - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -287,12 +287,12 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device) return -1; /* not initialized. ignore this. */ } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { /* found it, remove it. */ if (IOObjectIsEqualTo((io_object_t)item->dev, device)) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); @@ -478,7 +478,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { SDL_OutOfMemory(); goto creat_err; } @@ -516,7 +516,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic /* Allocate effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); goto open_err; } @@ -530,7 +530,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic open_err: FFReleaseDevice(haptic->hwdata->device); creat_err: - if (haptic->hwdata != NULL) { + if (haptic->hwdata) { SDL_free(haptic->hwdata); haptic->hwdata = NULL; } @@ -703,7 +703,7 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, SDL_HapticDirection *dir, int /* Has axes. */ rglDir = SDL_malloc(sizeof(LONG) * naxes); - if (rglDir == NULL) { + if (!rglDir) { return SDL_OutOfMemory(); } SDL_memset(rglDir, 0, sizeof(LONG) * naxes); @@ -776,7 +776,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe /* Envelope. */ envelope = SDL_malloc(sizeof(FFENVELOPE)); - if (envelope == NULL) { + if (!envelope) { return SDL_OutOfMemory(); } SDL_memset(envelope, 0, sizeof(FFENVELOPE)); @@ -791,7 +791,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe } if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); - if (axes == NULL) { + if (!axes) { return SDL_OutOfMemory(); } axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ @@ -809,7 +809,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; constant = SDL_malloc(sizeof(FFCONSTANTFORCE)); - if (constant == NULL) { + if (!constant) { return SDL_OutOfMemory(); } SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE)); @@ -851,7 +851,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_SAWTOOTHDOWN: hap_periodic = &src->periodic; periodic = SDL_malloc(sizeof(FFPERIODIC)); - if (periodic == NULL) { + if (!periodic) { return SDL_OutOfMemory(); } SDL_memset(periodic, 0, sizeof(FFPERIODIC)); @@ -896,7 +896,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe hap_condition = &src->condition; if (dest->cAxes > 0) { condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes); - if (condition == NULL) { + if (!condition) { return SDL_OutOfMemory(); } SDL_memset(condition, 0, sizeof(FFCONDITION)); @@ -939,7 +939,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_RAMP: hap_ramp = &src->ramp; ramp = SDL_malloc(sizeof(FFRAMPFORCE)); - if (ramp == NULL) { + if (!ramp) { return SDL_OutOfMemory(); } SDL_memset(ramp, 0, sizeof(FFRAMPFORCE)); @@ -977,7 +977,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_CUSTOM: hap_custom = &src->custom; custom = SDL_malloc(sizeof(FFCUSTOMFORCE)); - if (custom == NULL) { + if (!custom) { return SDL_OutOfMemory(); } SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE)); @@ -1037,7 +1037,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type) effect->lpEnvelope = NULL; SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; - if (effect->lpvTypeSpecificParams != NULL) { + if (effect->lpvTypeSpecificParams) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (FFCUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); @@ -1112,14 +1112,14 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, /* Alloc the effect. */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); - if (effect->hweffect == NULL) { + if (!effect->hweffect) { SDL_OutOfMemory(); goto err_hweffect; } /* Get the type. */ type = SDL_SYS_HapticEffectType(base->type); - if (type == NULL) { + if (!type) { goto err_hweffect; } diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 093f1b0a5..a9b4c2737 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -195,7 +195,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); --device_index; item = item->next; } @@ -206,7 +206,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) #if SDL_USE_LIBUDEV static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { - if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { + if (!devpath || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { return; } @@ -232,7 +232,7 @@ static int MaybeAddDevice(const char *path) int success; SDL_hapticlist_item *item; - if (path == NULL) { + if (!path) { return -1; } @@ -242,7 +242,7 @@ static int MaybeAddDevice(const char *path) } /* check for duplicates */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->dev_num == sb.st_rdev) { return -1; /* duplicate. */ } @@ -266,12 +266,12 @@ static int MaybeAddDevice(const char *path) } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return -1; } item->fname = SDL_strdup(path); - if (item->fname == NULL) { + if (!item->fname) { SDL_free(item); return -1; } @@ -279,7 +279,7 @@ static int MaybeAddDevice(const char *path) item->dev_num = sb.st_rdev; /* TODO: should we add instance IDs? */ - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -299,16 +299,16 @@ static int MaybeRemoveDevice(const char *path) SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; - if (path == NULL) { + if (!path) { return -1; } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(path, item->fname) == 0) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); @@ -365,7 +365,7 @@ const char *SDL_SYS_HapticName(int index) if (fd >= 0) { name = SDL_SYS_HapticNameFromFD(fd); - if (name == NULL) { + if (!name) { /* No name found, return device character device */ name = item->fname; } @@ -383,7 +383,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { SDL_OutOfMemory(); goto open_err; } @@ -403,7 +403,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); goto open_err; } @@ -416,7 +416,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) /* Error handling */ open_err: close(fd); - if (haptic->hwdata != NULL) { + if (haptic->hwdata) { SDL_free(haptic->hwdata); haptic->hwdata = NULL; } @@ -911,7 +911,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, /* Allocate the hardware effect */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); - if (effect->hweffect == NULL) { + if (!effect->hweffect) { return SDL_OutOfMemory(); } diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 5a096be9d..68cd110eb 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -98,7 +98,7 @@ int SDL_DINPUT_HapticInit(void) /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); - if (instance == NULL) { + if (!instance) { SDL_SYS_HapticQuit(); return SDL_SetError("GetModuleHandle() failed with error code %lu.", GetLastError()); @@ -139,7 +139,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) DIDEVCAPS capabilities; SDL_hapticlist_item *item = NULL; - if (dinput == NULL) { + if (!dinput) { return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ } @@ -172,7 +172,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } @@ -194,11 +194,11 @@ int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance) SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; - if (dinput == NULL) { + if (!dinput) { return -1; /* not initialized, ignore this. */ } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (!item->bXInputHaptic && SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0) { /* found it, remove it. */ return SDL_SYS_RemoveHapticDevice(prev, item); @@ -293,7 +293,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { return SDL_OutOfMemory(); } SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); @@ -407,7 +407,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); goto acquire_err; } @@ -480,7 +480,7 @@ int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick } /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (!item->bXInputHaptic && WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) { haptic->index = index; return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE); @@ -546,7 +546,7 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, SDL_HapticDirection *dir, int /* Has axes. */ rglDir = SDL_malloc(sizeof(LONG) * naxes); - if (rglDir == NULL) { + if (!rglDir) { return SDL_OutOfMemory(); } SDL_memset(rglDir, 0, sizeof(LONG) * naxes); @@ -620,7 +620,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, /* Envelope. */ envelope = SDL_malloc(sizeof(DIENVELOPE)); - if (envelope == NULL) { + if (!envelope) { return SDL_OutOfMemory(); } SDL_memset(envelope, 0, sizeof(DIENVELOPE)); @@ -635,7 +635,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, } if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); - if (axes == NULL) { + if (!axes) { return SDL_OutOfMemory(); } axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ @@ -653,7 +653,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; constant = SDL_malloc(sizeof(DICONSTANTFORCE)); - if (constant == NULL) { + if (!constant) { return SDL_OutOfMemory(); } SDL_memset(constant, 0, sizeof(DICONSTANTFORCE)); @@ -695,7 +695,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_SAWTOOTHDOWN: hap_periodic = &src->periodic; periodic = SDL_malloc(sizeof(DIPERIODIC)); - if (periodic == NULL) { + if (!periodic) { return SDL_OutOfMemory(); } SDL_memset(periodic, 0, sizeof(DIPERIODIC)); @@ -739,7 +739,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_FRICTION: hap_condition = &src->condition; condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes); - if (condition == NULL) { + if (!condition) { return SDL_OutOfMemory(); } SDL_memset(condition, 0, sizeof(DICONDITION)); @@ -780,7 +780,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_RAMP: hap_ramp = &src->ramp; ramp = SDL_malloc(sizeof(DIRAMPFORCE)); - if (ramp == NULL) { + if (!ramp) { return SDL_OutOfMemory(); } SDL_memset(ramp, 0, sizeof(DIRAMPFORCE)); @@ -818,7 +818,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_CUSTOM: hap_custom = &src->custom; custom = SDL_malloc(sizeof(DICUSTOMFORCE)); - if (custom == NULL) { + if (!custom) { return SDL_OutOfMemory(); } SDL_memset(custom, 0, sizeof(DICUSTOMFORCE)); @@ -877,7 +877,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type) effect->lpEnvelope = NULL; SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; - if (effect->lpvTypeSpecificParams != NULL) { + if (effect->lpvTypeSpecificParams) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (DICUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); @@ -943,7 +943,7 @@ int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, HRESULT ret; REFGUID type = SDL_SYS_HapticEffectType(base); - if (type == NULL) { + if (!type) { return SDL_SetError("Haptic: Unknown effect type."); } diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c index 01a4a7ec9..a70c33212 100644 --- a/src/haptic/windows/SDL_windowshaptic.c +++ b/src/haptic/windows/SDL_windowshaptic.c @@ -81,7 +81,7 @@ int SDL_SYS_HapticInit(void) int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) { - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -97,7 +97,7 @@ int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); @@ -126,7 +126,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); --device_index; item = item->next; } @@ -165,7 +165,7 @@ int SDL_SYS_HapticMouse(void) int index = 0; /* Grab the first mouse haptic device we find. */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) { return index; } @@ -299,7 +299,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, /* Alloc the effect. */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); - if (effect->hweffect == NULL) { + if (!effect->hweffect) { SDL_OutOfMemory(); return -1; } diff --git a/src/haptic/windows/SDL_xinputhaptic.c b/src/haptic/windows/SDL_xinputhaptic.c index 6c77163e1..0eaf356bb 100644 --- a/src/haptic/windows/SDL_xinputhaptic.c +++ b/src/haptic/windows/SDL_xinputhaptic.c @@ -84,7 +84,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) } item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } @@ -119,7 +119,7 @@ int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) return -1; } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->bXInputHaptic && item->userid == userid) { /* found it, remove it. */ return SDL_SYS_RemoveHapticDevice(prev, item); @@ -178,7 +178,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { return SDL_OutOfMemory(); } /* Clear the memory */ @@ -186,7 +186,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us sizeof(struct haptic_effect) * haptic->neffects); haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { SDL_free(haptic->effects); haptic->effects = NULL; return SDL_OutOfMemory(); @@ -197,7 +197,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us haptic->hwdata->userid = userid; haptic->hwdata->mutex = SDL_CreateMutex(); - if (haptic->hwdata->mutex == NULL) { + if (!haptic->hwdata->mutex) { SDL_free(haptic->effects); SDL_free(haptic->hwdata); haptic->effects = NULL; @@ -207,7 +207,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us (void)SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", userid); haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata); - if (haptic->hwdata->thread == NULL) { + if (!haptic->hwdata->thread) { SDL_DestroyMutex(haptic->hwdata->mutex); SDL_free(haptic->effects); SDL_free(haptic->hwdata); @@ -234,7 +234,7 @@ int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick int index = 0; /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->bXInputHaptic && item->userid == joystick->hwdata->userid) { haptic->index = index; return SDL_XINPUT_HapticOpenFromUserIndex(haptic, joystick->hwdata->userid); diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index 6c3e43fb6..0a6bd0754 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -29,11 +29,11 @@ */ #include "../SDL_internal.h" -#include "SDL_loadso.h" #include "SDL_hidapi.h" +#include "SDL_hidapi_c.h" +#include "SDL_loadso.h" #include "SDL_thread.h" #include "SDL_timer.h" -#include "SDL_hidapi_c.h" #if !SDL_HIDAPI_DISABLED @@ -42,12 +42,12 @@ #endif #if defined(__MACOSX__) +#include #include -#include #include #include #include -#include +#include /* Things named "Master" were renamed to "Main" in macOS 12.0's SDK. */ #if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 #define kIOMainPortDefault kIOMasterPortDefault @@ -56,16 +56,16 @@ #include "../core/linux/SDL_udev.h" #ifdef SDL_USE_LIBUDEV -#include #include "../core/linux/SDL_sandbox.h" +#include #endif #ifdef HAVE_INOTIFY -#include /* just in case we didn't use that SDL_USE_LIBUDEV block... */ -#include /* errno, strerror */ +#include /* errno, strerror */ #include #include /* For the definition of NAME_MAX */ #include +#include /* just in case we didn't use that SDL_USE_LIBUDEV block... */ #endif #if defined(SDL_USE_LIBUDEV) || defined(HAVE_INOTIFY) @@ -166,7 +166,6 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam } #endif /* defined(__WIN32__) || defined(__WINGDK__) */ - #if defined(__MACOSX__) static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator) { @@ -594,7 +593,7 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; /* The implementation for Android is in a separate .cpp file */ #include "hidapi/hidapi.h" #define HAVE_PLATFORM_BACKEND 1 -#define udev_ctx 1 +#define udev_ctx 1 #elif __IPHONEOS__ || __TVOS__ /* The implementation for iOS and tvOS is in a separate .m file */ #include "hidapi/hidapi.h" @@ -809,8 +808,8 @@ static struct /* this is awkwardly inlined, so we need to re-implement it here * so we can override the libusb_control_transfer call */ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, - uint8_t descriptor_index, uint16_t lang_id, - unsigned char *data, int length) + uint8_t descriptor_index, uint16_t lang_id, + unsigned char *data, int length) { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN | 0x0, LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | descriptor_index, lang_id, data, (uint16_t)length, 1000); /* Endpoint 0 IN */ diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 035176b37..0ba336bda 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -177,7 +177,7 @@ static void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) spot = (char *)hint; } - if (spot == NULL) { + if (!spot) { return; } @@ -185,7 +185,7 @@ static void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) entry = (Uint16)SDL_strtol(spot, &spot, 0); entry <<= 16; spot = SDL_strstr(spot, "0x"); - if (spot == NULL) { + if (!spot) { break; } entry |= (Uint16)SDL_strtol(spot, &spot, 0); @@ -193,7 +193,7 @@ static void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) if (list->num_entries == list->max_entries) { int max_entries = list->max_entries + 16; Uint32 *entries = (Uint32 *)SDL_realloc(list->entries, max_entries * sizeof(*list->entries)); - if (entries == NULL) { + if (!entries) { /* Out of memory, go with what we have already */ break; } @@ -273,7 +273,7 @@ static void HandleJoystickAxis(SDL_GameController *gamecontroller, int axis, int } } - if (last_match && (match == NULL || !HasSameOutput(last_match, match))) { + if (last_match && (!match || !HasSameOutput(last_match, match))) { /* Clear the last input that this axis generated */ ResetOutput(gamecontroller, last_match); } @@ -1105,7 +1105,7 @@ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, Con gamecontroller->name = pControllerMapping->name; gamecontroller->num_bindings = 0; gamecontroller->mapping = pControllerMapping; - if (gamecontroller->joystick->naxes != 0 && gamecontroller->last_match_axis != NULL) { + if (gamecontroller->joystick->naxes != 0 && gamecontroller->last_match_axis) { SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis)); } @@ -1134,7 +1134,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping) const char *pFirstComma = SDL_strchr(pMapping, ','); if (pFirstComma) { char *pchGUID = SDL_malloc(pFirstComma - pMapping + 1); - if (pchGUID == NULL) { + if (!pchGUID) { SDL_OutOfMemory(); return NULL; } @@ -1173,17 +1173,17 @@ static char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping) char *pchName; pFirstComma = SDL_strchr(pMapping, ','); - if (pFirstComma == NULL) { + if (!pFirstComma) { return NULL; } pSecondComma = SDL_strchr(pFirstComma + 1, ','); - if (pSecondComma == NULL) { + if (!pSecondComma) { return NULL; } pchName = SDL_malloc(pSecondComma - pFirstComma); - if (pchName == NULL) { + if (!pchName) { SDL_OutOfMemory(); return NULL; } @@ -1200,12 +1200,12 @@ static char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMappi const char *pFirstComma, *pSecondComma; pFirstComma = SDL_strchr(pMapping, ','); - if (pFirstComma == NULL) { + if (!pFirstComma) { return NULL; } pSecondComma = SDL_strchr(pFirstComma + 1, ','); - if (pSecondComma == NULL) { + if (!pSecondComma) { return NULL; } @@ -1248,13 +1248,13 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, SDL_AssertJoysticksLocked(); pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString); - if (pchName == NULL) { + if (!pchName) { SDL_SetError("Couldn't parse name from %s", mappingString); return NULL; } pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString); - if (pchMapping == NULL) { + if (!pchMapping) { SDL_free(pchName); SDL_SetError("Couldn't parse %s", mappingString); return NULL; @@ -1311,7 +1311,7 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, *existing = SDL_TRUE; } else { pControllerMapping = SDL_malloc(sizeof(*pControllerMapping)); - if (pControllerMapping == NULL) { + if (!pControllerMapping) { SDL_free(pchName); SDL_free(pchMapping); SDL_OutOfMemory(); @@ -1356,7 +1356,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const mapping = SDL_PrivateGetControllerMappingForGUID(guid, SDL_FALSE); #ifdef __LINUX__ - if (mapping == NULL && name) { + if (!mapping && name) { if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) { /* The Linux driver xpad.c maps the wireless dpad to buttons */ SDL_bool existing; @@ -1367,7 +1367,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const } #endif /* __LINUX__ */ - if (mapping == NULL) { + if (!mapping) { mapping = s_pDefaultMapping; } return mapping; @@ -1468,7 +1468,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) name = SDL_JoystickNameForIndex(device_index); guid = SDL_JoystickGetDeviceGUID(device_index); mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid); - if (mapping == NULL) { + if (!mapping) { SDL_GamepadMapping raw_map; SDL_zero(raw_map); @@ -1490,13 +1490,13 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) char *buf, *line, *line_end, *tmp, *comma, line_platform[64]; size_t db_size, platform_len; - if (rw == NULL) { + if (!rw) { return SDL_SetError("Invalid RWops"); } db_size = (size_t)SDL_RWsize(rw); buf = (char *)SDL_malloc(db_size + 1); - if (buf == NULL) { + if (!buf) { if (freerw) { SDL_RWclose(rw); } @@ -1520,7 +1520,7 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) while (line < buf + db_size) { line_end = SDL_strchr(line, '\n'); - if (line_end != NULL) { + if (line_end) { *line_end = '\0'; } else { line_end = buf + db_size; @@ -1528,10 +1528,10 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) /* Extract and verify the platform */ tmp = SDL_strstr(line, SDL_CONTROLLER_PLATFORM_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_PLATFORM_FIELD_SIZE; comma = SDL_strchr(tmp, ','); - if (comma != NULL) { + if (comma) { platform_len = comma - tmp + 1; if (platform_len + 1 < SDL_arraysize(line_platform)) { SDL_strlcpy(line_platform, tmp, platform_len); @@ -1564,7 +1564,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co SDL_AssertJoysticksLocked(); - if (mappingString == NULL) { + if (!mappingString) { return SDL_InvalidParamError("mappingString"); } @@ -1572,7 +1572,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co const char *tmp; tmp = SDL_strstr(mappingString, SDL_CONTROLLER_HINT_FIELD); - if (tmp != NULL) { + if (tmp) { SDL_bool default_value, value, negate; int len; char hint[128]; @@ -1614,14 +1614,14 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co const char *tmp; tmp = SDL_strstr(mappingString, SDL_CONTROLLER_SDKGE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_SDKGE_FIELD_SIZE; if (!(SDL_GetAndroidSDKVersion() >= SDL_atoi(tmp))) { return SDL_SetError("SDK version %d < minimum version %d", SDL_GetAndroidSDKVersion(), SDL_atoi(tmp)); } } tmp = SDL_strstr(mappingString, SDL_CONTROLLER_SDKLE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_SDKLE_FIELD_SIZE; if (!(SDL_GetAndroidSDKVersion() <= SDL_atoi(tmp))) { return SDL_SetError("SDK version %d > maximum version %d", SDL_GetAndroidSDKVersion(), SDL_atoi(tmp)); @@ -1631,7 +1631,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co #endif pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString); - if (pchGUID == NULL) { + if (!pchGUID) { return SDL_SetError("Couldn't parse GUID from %s", mappingString); } if (!SDL_strcasecmp(pchGUID, "default")) { @@ -1643,7 +1643,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co SDL_free(pchGUID); pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority); - if (pControllerMapping == NULL) { + if (!pControllerMapping) { return -1; } @@ -1724,7 +1724,7 @@ static char *CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID } pMappingString = SDL_malloc(needed); - if (pMappingString == NULL) { + if (!pMappingString) { SDL_OutOfMemory(); return NULL; } @@ -1774,7 +1774,7 @@ char *SDL_GameControllerMappingForIndex(int mapping_index) } SDL_UnlockJoysticks(); - if (retval == NULL) { + if (!retval) { SDL_SetError("Mapping not available"); } return retval; @@ -1932,7 +1932,7 @@ const char *SDL_GameControllerNameForIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { if (SDL_strcmp(mapping->name, "*") == 0) { retval = SDL_JoystickNameForIndex(joystick_index); } else { @@ -1955,7 +1955,7 @@ const char *SDL_GameControllerPathForIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { retval = SDL_JoystickPathForIndex(joystick_index); } } @@ -1984,7 +1984,7 @@ char *SDL_GameControllerMappingForDeviceIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { SDL_JoystickGUID guid; char pchGUID[33]; size_t needed; @@ -1993,7 +1993,7 @@ char *SDL_GameControllerMappingForDeviceIndex(int joystick_index) /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; retval = (char *)SDL_malloc(needed); - if (retval != NULL) { + if (retval) { (void)SDL_snprintf(retval, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); } else { SDL_OutOfMemory(); @@ -2155,7 +2155,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) gamecontrollerlist = SDL_gamecontrollers; /* If the controller is already open, return it */ instance_id = SDL_JoystickGetDeviceInstanceID(joystick_index); - while (gamecontrollerlist != NULL) { + while (gamecontrollerlist) { if (instance_id == gamecontrollerlist->joystick->instance_id) { gamecontroller = gamecontrollerlist; ++gamecontroller->ref_count; @@ -2167,7 +2167,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) /* Find a controller mapping */ pSupportedController = SDL_PrivateGetControllerMapping(joystick_index); - if (pSupportedController == NULL) { + if (!pSupportedController) { SDL_SetError("Couldn't find mapping for device (%d)", joystick_index); SDL_UnlockJoysticks(); return NULL; @@ -2175,7 +2175,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) /* Create and initialize the controller */ gamecontroller = (SDL_GameController *)SDL_calloc(1, sizeof(*gamecontroller)); - if (gamecontroller == NULL) { + if (!gamecontroller) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -2183,7 +2183,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) gamecontroller->magic = &gamecontroller_magic; gamecontroller->joystick = SDL_JoystickOpen(joystick_index); - if (gamecontroller->joystick == NULL) { + if (!gamecontroller->joystick) { SDL_free(gamecontroller); SDL_UnlockJoysticks(); return NULL; @@ -2655,7 +2655,7 @@ const char *SDL_GameControllerPath(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_JoystickPath(joystick); @@ -2665,7 +2665,7 @@ SDL_GameControllerType SDL_GameControllerGetType(SDL_GameController *gamecontrol { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_CONTROLLER_TYPE_UNKNOWN; } return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(joystick), SDL_JoystickName(joystick)); @@ -2675,7 +2675,7 @@ int SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickGetPlayerIndex(joystick); @@ -2688,7 +2688,7 @@ void SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int pl { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return; } SDL_JoystickSetPlayerIndex(joystick, player_index); @@ -2698,7 +2698,7 @@ Uint16 SDL_GameControllerGetVendor(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetVendor(joystick); @@ -2708,7 +2708,7 @@ Uint16 SDL_GameControllerGetProduct(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetProduct(joystick); @@ -2718,7 +2718,7 @@ Uint16 SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetProductVersion(joystick); @@ -2728,7 +2728,7 @@ Uint16 SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetFirmwareVersion(joystick); @@ -2738,7 +2738,7 @@ const char * SDL_GameControllerGetSerial(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_JoystickGetSerial(joystick); @@ -2752,7 +2752,7 @@ SDL_bool SDL_GameControllerGetAttached(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickGetAttached(joystick); @@ -2894,7 +2894,7 @@ int SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_freq { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms); @@ -2904,7 +2904,7 @@ int SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickRumbleTriggers(joystick, left_rumble, right_rumble, duration_ms); @@ -2914,7 +2914,7 @@ SDL_bool SDL_GameControllerHasLED(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasLED(joystick); @@ -2924,7 +2924,7 @@ SDL_bool SDL_GameControllerHasRumble(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumble(joystick); @@ -2934,7 +2934,7 @@ SDL_bool SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumbleTriggers(joystick); @@ -2944,7 +2944,7 @@ int SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickSetLED(joystick, red, green, blue); @@ -2954,7 +2954,7 @@ int SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickSendEffect(joystick, data, size); @@ -2966,7 +2966,7 @@ void SDL_GameControllerClose(SDL_GameController *gamecontroller) SDL_LockJoysticks(); - if (gamecontroller == NULL || gamecontroller->magic != &gamecontroller_magic) { + if (!gamecontroller || gamecontroller->magic != &gamecontroller_magic) { SDL_UnlockJoysticks(); return; } diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index c08a20421..3d4488b65 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -265,7 +265,7 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID if (player_index >= SDL_joystick_player_count) { SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1) * sizeof(*SDL_joystick_players)); - if (new_players == NULL) { + if (!new_players) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -406,7 +406,7 @@ const char *SDL_JoystickPathForIndex(int device_index) SDL_UnlockJoysticks(); /* FIXME: Really we should reference count this path so it doesn't go away after unlock */ - if (path == NULL) { + if (!path) { SDL_Unsupported(); } return path; @@ -509,7 +509,7 @@ SDL_Joystick *SDL_JoystickOpen(int device_index) /* Create and initialize the joystick */ joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); - if (joystick == NULL) { + if (!joystick) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -1474,7 +1474,7 @@ static void UpdateEventsForDeviceRemoval(int device_index, Uint32 type) } events = SDL_small_alloc(SDL_Event, num_events, &isstack); - if (events == NULL) { + if (!events) { return; } @@ -1980,10 +1980,10 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n return SDL_strdup(custom_name); } - if (vendor_name == NULL) { + if (!vendor_name) { vendor_name = ""; } - if (product_name == NULL) { + if (!product_name) { product_name = ""; } @@ -2026,7 +2026,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n default: len = (6 + 1 + 6 + 1); name = (char *)SDL_malloc(len); - if (name != NULL) { + if (name) { (void)SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product); } break; @@ -2035,7 +2035,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n name = SDL_strdup("Controller"); } - if (name == NULL) { + if (!name) { return NULL; } @@ -2099,7 +2099,7 @@ SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 produc SDL_zero(guid); - if (name == NULL) { + if (!name) { name = ""; } diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index 84822e4de..96488f36b 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -320,7 +320,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v } } - if (JoystickByDeviceId(device_id) != NULL || name == NULL) { + if (JoystickByDeviceId(device_id) != NULL || !name) { goto done; } @@ -354,7 +354,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v } item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { goto done; } @@ -362,7 +362,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v item->guid = guid; item->device_id = device_id; item->name = SDL_CreateJoystickName(vendor_id, product_id, NULL, name); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); goto done; } @@ -381,7 +381,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v item->nhats = nhats; item->nballs = nballs; item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -414,7 +414,7 @@ int Android_RemoveJoystick(int device_id) SDL_LockJoysticks(); /* Don't call JoystickByDeviceId here or there'll be an infinite loop! */ - while (item != NULL) { + while (item) { if (item->device_id == device_id) { break; } @@ -422,7 +422,7 @@ int Android_RemoveJoystick(int device_id) item = item->next; } - if (item == NULL) { + if (!item) { goto done; } @@ -430,7 +430,7 @@ int Android_RemoveJoystick(int device_id) item->joystick->hwdata = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -500,7 +500,7 @@ static SDL_joylist_item *JoystickByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); device_index--; item = item->next; } @@ -512,7 +512,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id) { SDL_joylist_item *item = SDL_joylist; - while (item != NULL) { + while (item) { if (item->device_id == device_id) { return item; } @@ -522,7 +522,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id) /* Joystick not found, try adding it */ ANDROID_JoystickDetect(); - while (item != NULL) { + while (item) { if (item->device_id == device_id) { return item; } @@ -565,11 +565,11 @@ static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDevIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } - if (item->joystick != NULL) { + if (item->joystick) { return SDL_SetError("Joystick already opened"); } @@ -618,7 +618,7 @@ static void ANDROID_JoystickUpdate(SDL_Joystick *joystick) { SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; - if (item == NULL) { + if (!item) { return; } diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index 90a7f3959..d380f68f2 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -298,7 +298,7 @@ CreateHwData(const char *path) hw = (struct joystick_hwdata *) SDL_calloc(1, sizeof(struct joystick_hwdata)); - if (hw == NULL) { + if (!hw) { close(fd); SDL_OutOfMemory(); return NULL; @@ -321,7 +321,7 @@ CreateHwData(const char *path) } } hw->repdesc = hid_get_report_desc(fd); - if (hw->repdesc == NULL) { + if (!hw->repdesc) { SDL_SetError("%s: USB_GET_REPORT_DESC: %s", path, strerror(errno)); goto usberr; @@ -348,7 +348,7 @@ CreateHwData(const char *path) #else hdata = hid_start_parse(hw->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { + if (!hdata) { SDL_SetError("%s: Cannot start HID parser", path); goto usberr; } @@ -428,7 +428,7 @@ static int MaybeAddDevice(const char *path) SDL_joylist_item *item; struct joystick_hwdata *hw; - if (path == NULL) { + if (!path) { return -1; } @@ -437,14 +437,14 @@ static int MaybeAddDevice(const char *path) } /* Check to make sure it's not already in list. */ - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { return -1; /* already have this one */ } } hw = CreateHwData(path); - if (hw == NULL) { + if (!hw) { return -1; } @@ -474,14 +474,14 @@ static int MaybeAddDevice(const char *path) } #endif /* USB_GET_DEVICEINFO */ } - if (name == NULL) { + if (!name) { name = SDL_strdup(path); guid = SDL_CreateJoystickGUIDForName(name); } FreeHwData(hw); item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { SDL_free(name); return -1; } @@ -491,13 +491,13 @@ static int MaybeAddDevice(const char *path) item->name = name; item->guid = guid; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); return -1; } item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -556,7 +556,7 @@ static SDL_joylist_item *JoystickByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); device_index--; item = item->next; } @@ -613,12 +613,12 @@ static int BSD_JoystickOpen(SDL_Joystick *joy, int device_index) SDL_joylist_item *item = JoystickByDevIndex(device_index); struct joystick_hwdata *hw; - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } hw = CreateHwData(item->path); - if (hw == NULL) { + if (!hw) { return -1; } @@ -693,7 +693,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) #else hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { + if (!hdata) { /*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/ continue; } @@ -812,7 +812,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind) r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + r->size); #endif - if (r->buf == NULL) { + if (!r->buf) { return SDL_OutOfMemory(); } } else { diff --git a/src/joystick/darwin/SDL_iokitjoystick.c b/src/joystick/darwin/SDL_iokitjoystick.c index 0ac9b5061..f5cd7151e 100644 --- a/src/joystick/darwin/SDL_iokitjoystick.c +++ b/src/joystick/darwin/SDL_iokitjoystick.c @@ -42,7 +42,7 @@ static recDevice *gpDeviceList = NULL; void FreeRumbleEffectData(FFEFFECT *effect) { - if (effect == NULL) { + if (!effect) { return; } SDL_free(effect->rgdwAxes); @@ -58,7 +58,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) /* Create the effect */ effect = (FFEFFECT *)SDL_calloc(1, sizeof(*effect)); - if (effect == NULL) { + if (!effect) { return NULL; } effect->dwSize = sizeof(*effect); @@ -82,7 +82,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwFlags |= FFEFF_CARTESIAN; periodic = (FFPERIODIC *)SDL_calloc(1, sizeof(*periodic)); - if (periodic == NULL) { + if (!periodic) { FreeRumbleEffectData(effect); return NULL; } @@ -508,7 +508,7 @@ static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) } #endif - for (i = gpDeviceList; i != NULL; i = i->pNext) { + for (i = gpDeviceList; i; i = i->pNext) { if (i->deviceRef == ioHIDDeviceObject) { return SDL_TRUE; } @@ -530,7 +530,7 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender } device = (recDevice *)SDL_calloc(1, sizeof(recDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return; } @@ -563,13 +563,13 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender } /* Add device to the end of the list */ - if (gpDeviceList == NULL) { + if (!gpDeviceList) { gpDeviceList = device; } else { recDevice *curdevice; curdevice = gpDeviceList; - while (curdevice->pNext != NULL) { + while (curdevice->pNext) { curdevice = curdevice->pNext; } curdevice->pNext = device; @@ -854,7 +854,7 @@ static int DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ru /* Scale and average the two rumble strengths */ Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); - if (device == NULL) { + if (!device) { return SDL_SetError("Rumble failed, device disconnected"); } @@ -895,7 +895,7 @@ static Uint32 DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick) recDevice *device = joystick->hwdata; Uint32 result = 0; - if (device == NULL) { + if (!device) { return 0; } @@ -928,7 +928,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick) SInt32 value, range; int i, goodRead = SDL_FALSE; - if (device == NULL) { + if (!device) { return; } diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index a22e905c3..11209d766 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -49,7 +49,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep } item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { return 1; } @@ -57,13 +57,13 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep item->index = gamepadEvent->index; item->name = SDL_CreateJoystickName(0, 0, NULL, gamepadEvent->id); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); return 1; } item->mapping = SDL_strdup(gamepadEvent->mapping); - if (item->mapping == NULL) { + if (!item->mapping) { SDL_free(item->name); SDL_free(item); return 1; @@ -84,7 +84,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep item->digitalButton[i] = gamepadEvent->digitalButton[i]; } - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -111,7 +111,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa SDL_joylist_item *item = SDL_joylist; SDL_joylist_item *prev = NULL; - while (item != NULL) { + while (item) { if (item->index == gamepadEvent->index) { break; } @@ -119,7 +119,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa item = item->next; } - if (item == NULL) { + if (!item) { return 1; } @@ -127,7 +127,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa item->joystick->hwdata = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -245,7 +245,7 @@ static SDL_joylist_item *JoystickByIndex(int index) return NULL; } - while (item != NULL) { + while (item) { if (item->index == index) { break; } @@ -297,11 +297,11 @@ static int EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDeviceIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } - if (item->joystick != NULL) { + if (item->joystick) { return SDL_SetError("Joystick already opened"); } diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index b4c7e694c..228ec78f5 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -140,7 +140,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) #endif ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -249,7 +249,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device } joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); - if (joystick == NULL) { + if (!joystick) { /* Hasn't been opened yet, skip */ return; } @@ -323,7 +323,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); /* Hasn't been opened yet, skip */ - if (joystick == NULL) { + if (!joystick) { continue; } } else { diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c index 7eb44c72a..a45bb8c20 100644 --- a/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/src/joystick/hidapi/SDL_hidapi_luna.c @@ -75,7 +75,7 @@ static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverLuna_Context *ctx; ctx = (SDL_DriverLuna_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -393,7 +393,7 @@ static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_LUNA_PROTOCOL HIDAPI_DumpPacket("Amazon Luna packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index d5e00babc..3eef854ef 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -139,7 +139,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) } ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -220,7 +220,7 @@ static void HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; - if (ctx == NULL) { + if (!ctx) { return; } @@ -494,7 +494,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } @@ -606,7 +606,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverPS3_Context *ctx; ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -924,7 +924,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *devic #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c index 2a428094f..a03e35eda 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -243,7 +243,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1145,7 +1145,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->last_packet = now; - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index 0b0a906bf..d47635850 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -355,7 +355,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1415,7 +1415,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->last_packet = now; - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index d04507949..3584540ec 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -216,7 +216,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const } request = (SDL_HIDAPI_RumbleRequest *)SDL_calloc(1, sizeof(*request)); - if (request == NULL) { + if (!request) { SDL_HIDAPI_UnlockRumble(); return SDL_OutOfMemory(); } diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c index 33a206627..5109846ea 100644 --- a/src/joystick/hidapi/SDL_hidapi_shield.c +++ b/src/joystick/hidapi/SDL_hidapi_shield.c @@ -118,7 +118,7 @@ static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverShield_Context *ctx; ctx = (SDL_DriverShield_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -489,7 +489,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) /* Byte 0 is HID report ID */ switch (data[0]) { case k_ShieldReportIdControllerState: - if (joystick == NULL) { + if (!joystick) { break; } if (size == 16) { @@ -499,7 +499,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) } break; case k_ShieldReportIdControllerTouch: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size); diff --git a/src/joystick/hidapi/SDL_hidapi_stadia.c b/src/joystick/hidapi/SDL_hidapi_stadia.c index 0cdb4f41c..5356e3094 100644 --- a/src/joystick/hidapi/SDL_hidapi_stadia.c +++ b/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -72,7 +72,7 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverStadia_Context *ctx; ctx = (SDL_DriverStadia_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -288,7 +288,7 @@ static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_STADIA_PROTOCOL HIDAPI_DumpPacket("Google Stadia packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 046c0ce81..40cad685f 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -977,7 +977,7 @@ static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverSteam_Context *ctx; ctx = (SDL_DriverSteam_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1109,7 +1109,7 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) break; } - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 6a983c896..f3bf906de 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -444,7 +444,7 @@ static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommand SwitchSubcommandInputPacket_t *reply = NULL; int nTries; - for (nTries = 1; reply == NULL && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { + for (nTries = 1; !reply && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { SwitchSubcommandOutputPacket_t commandPacket; ConstructSubcommand(ctx, ucCommandID, pBuf, ucLen, &commandPacket); @@ -468,7 +468,7 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta for (nTries = 1; nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { SwitchProprietaryOutputPacket_t packet; - if ((pBuf == NULL && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) { + if ((!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) { return SDL_FALSE; } @@ -1278,7 +1278,7 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverSwitch_Context *ctx; ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -2168,7 +2168,7 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->m_unLastInput = now; - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index 3471b777a..9d397ece8 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -236,7 +236,7 @@ static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs exp int nRead = 0; while ((nRead = ReadInput(ctx)) != -1) { if (nRead > 0) { - if (ctx->m_rgucReadBuffer[0] == expectedID && (isMine == NULL || isMine(ctx->m_rgucReadBuffer))) { + if (ctx->m_rgucReadBuffer[0] == expectedID && (!isMine || isMine(ctx->m_rgucReadBuffer))) { return SDL_TRUE; } } else { @@ -733,7 +733,7 @@ static SDL_bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverWii_Context *ctx; ctx = (SDL_DriverWii_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index 843819f37..3eebb79c5 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -143,7 +143,7 @@ static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverXbox360_Context *ctx; ctx = (SDL_DriverXbox360_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -332,7 +332,7 @@ static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_XBOX_PROTOCOL HIDAPI_DumpPacket("Xbox 360 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/src/joystick/hidapi/SDL_hidapi_xbox360w.c index 5223d1a5b..e65695c73 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -135,7 +135,7 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_SetDeviceName(device, "Xbox 360 Wireless Controller"); ctx = (SDL_DriverXbox360W_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -162,7 +162,7 @@ static void HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; - if (ctx == NULL) { + if (!ctx) { return; } diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index 755daa5dd..869726396 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -368,7 +368,7 @@ static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverXboxOne_Context *ctx; ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1159,7 +1159,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) if (ctx->bluetooth) { switch (data[0]) { case 0x01: - if (joystick == NULL) { + if (!joystick) { break; } if (size >= 16) { @@ -1171,13 +1171,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) } break; case 0x02: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(joystick, ctx, data, size); break; case 0x04: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(joystick, ctx, data, size); @@ -1225,7 +1225,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) break; case 0x03: /* Controller status update */ - if (joystick == NULL) { + if (!joystick) { /* We actually want to handle this packet any time it arrives */ /*break;*/ } @@ -1238,13 +1238,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) /* Unknown chatty controller information, sent by both sides */ break; case 0x07: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleModePacket(joystick, ctx, data, size); break; case 0x0C: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(joystick, ctx, data, size); @@ -1259,7 +1259,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) The controller sends that in response to this request: 0x1E 0x30 0x07 0x01 0x04 */ - if (joystick == NULL) { + if (!joystick) { break; } #ifdef SET_SERIAL_AFTER_OPEN @@ -1278,7 +1278,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) #endif break; } - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleStatePacket(joystick, ctx, data, size); diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 201db43e8..c9d2d23a0 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -104,7 +104,7 @@ static char *HIDAPI_ConvertString(const wchar_t *wide_string) if (wide_string) { string = SDL_iconv_string("UTF-8", "WCHAR_T", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); - if (string == NULL) { + if (!string) { switch (sizeof(wchar_t)) { case 2: string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); @@ -612,7 +612,7 @@ static int HIDAPI_JoystickInit(void) static SDL_bool HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { SDL_JoystickID *joysticks = (SDL_JoystickID *)SDL_realloc(device->joysticks, (device->num_joysticks + 1) * sizeof(*device->joysticks)); - if (joysticks == NULL) { + if (!joysticks) { return SDL_FALSE; } @@ -732,7 +732,7 @@ SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial) SDL_AssertJoysticksLocked(); - if (serial == NULL) { + if (!serial) { return SDL_FALSE; } @@ -758,7 +758,7 @@ void HIDAPI_DisconnectBluetoothDevice(const char *serial) SDL_AssertJoysticksLocked(); - if (serial == NULL) { + if (!serial) { return; } @@ -867,7 +867,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } device = (SDL_HIDAPI_Device *)SDL_calloc(1, sizeof(*device)); - if (device == NULL) { + if (!device) { return NULL; } device->magic = &SDL_HIDAPI_device_magic; @@ -946,7 +946,9 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } #ifdef DEBUG_HIDAPI - SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); + SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, + device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, + device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); #endif return device; @@ -960,7 +962,9 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) SDL_AssertJoysticksLocked(); #ifdef DEBUG_HIDAPI - SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); + SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, + device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, + device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); #endif for (curr = SDL_HIDAPI_devices, last = NULL; curr; last = curr, curr = curr->next) { @@ -1034,7 +1038,7 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons() if (joycons[0] && joycons[1]) { SDL_hid_device_info info; SDL_HIDAPI_Device **children = (SDL_HIDAPI_Device **)SDL_malloc(2 * sizeof(SDL_HIDAPI_Device *)); - if (children == NULL) { + if (!children) { return SDL_FALSE; } children[0] = joycons[0]; @@ -1419,13 +1423,13 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); - if (device == NULL || !device->driver) { + if (!device || !device->driver) { /* This should never happen - validated before being called */ return SDL_SetError("Couldn't find HIDAPI device at index %d\n", device_index); } hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } hwdata->device = device; diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 9652351c1..b849dfed2 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -282,7 +282,7 @@ static int IsJoystick(const char *path, int fd, char **name_return, SDL_Joystick } name = SDL_CreateJoystickName(inpid.vendor, inpid.product, NULL, product_string); - if (name == NULL) { + if (!name) { return 0; } @@ -331,7 +331,7 @@ static int IsSensor(const char *path, int fd) #if SDL_USE_LIBUDEV static void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { - if (devpath == NULL) { + if (!devpath) { return; } @@ -389,7 +389,7 @@ static void MaybeAddDevice(const char *path) SDL_joylist_item *item; SDL_sensorlist_item *item_sensor; - if (path == NULL) { + if (!path) { return; } @@ -400,12 +400,12 @@ static void MaybeAddDevice(const char *path) SDL_LockJoysticks(); /* Check to make sure it's not already in list. */ - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { goto done; /* already have this one */ } } - for (item_sensor = SDL_sensorlist; item_sensor != NULL; item_sensor = item_sensor->next) { + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { if (sb.st_rdev == item_sensor->devnum) { goto done; /* already have this one */ } @@ -426,7 +426,7 @@ static void MaybeAddDevice(const char *path) #endif close(fd); item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { SDL_free(name); goto done; } @@ -436,13 +436,13 @@ static void MaybeAddDevice(const char *path) item->name = name; item->guid = guid; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); goto done; } item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -462,13 +462,13 @@ static void MaybeAddDevice(const char *path) #endif close(fd); item_sensor = (SDL_sensorlist_item *)SDL_calloc(1, sizeof(SDL_sensorlist_item)); - if (item_sensor == NULL) { + if (!item_sensor) { goto done; } item_sensor->devnum = sb.st_rdev; item_sensor->path = SDL_strdup(path); - if (item_sensor->path == NULL) { + if (!item_sensor->path) { FreeSensorlistItem(item_sensor); goto done; } @@ -491,7 +491,7 @@ static void RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) item->hwdata->item = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -517,7 +517,7 @@ static void RemoveSensorlistItem(SDL_sensorlist_item *item, SDL_sensorlist_item item->hwdata->item_sensor = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_sensorlist == item); @@ -536,12 +536,12 @@ static void MaybeRemoveDevice(const char *path) SDL_sensorlist_item *item_sensor; SDL_sensorlist_item *prev_sensor = NULL; - if (path == NULL) { + if (!path) { return; } SDL_LockJoysticks(); - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(path, item->path) == 0) { RemoveJoylistItem(item, prev); @@ -549,7 +549,7 @@ static void MaybeRemoveDevice(const char *path) } prev = item; } - for (item_sensor = SDL_sensorlist; item_sensor != NULL; item_sensor = item_sensor->next) { + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { /* found it, remove it. */ if (SDL_strcmp(path, item_sensor->path) == 0) { RemoveSensorlistItem(item_sensor, prev_sensor); @@ -571,11 +571,11 @@ static void HandlePendingRemovals(void) SDL_AssertJoysticksLocked(); item = SDL_joylist; - while (item != NULL) { + while (item) { if (item->hwdata && item->hwdata->gone) { RemoveJoylistItem(item, prev); - if (prev != NULL) { + if (prev) { item = prev->next; } else { item = SDL_joylist; @@ -587,11 +587,11 @@ static void HandlePendingRemovals(void) } item_sensor = SDL_sensorlist; - while (item_sensor != NULL) { + while (item_sensor) { if (item_sensor->hwdata && item_sensor->hwdata->sensor_gone) { RemoveSensorlistItem(item_sensor, prev_sensor); - if (prev_sensor != NULL) { + if (prev_sensor) { item_sensor = prev_sensor->next; } else { item_sensor = SDL_sensorlist; @@ -608,7 +608,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG SDL_joylist_item *item; item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { return SDL_FALSE; } @@ -617,14 +617,14 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG item->guid = guid; item->m_bSteamController = SDL_TRUE; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); return SDL_FALSE; } *device_instance = item->device_instance = SDL_GetNextJoystickInstanceID(); SDL_LockJoysticks(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -646,7 +646,7 @@ static void SteamControllerDisconnectedCallback(int device_instance) SDL_joylist_item *prev = NULL; SDL_LockJoysticks(); - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { /* found it, remove it. */ if (item->device_instance == device_instance) { RemoveJoylistItem(item, prev); @@ -891,13 +891,13 @@ static int LINUX_JoystickInit(void) enumeration_method = ENUMERATION_UNSET; /* First see if the user specified one or more joysticks to use */ - if (devices != NULL) { + if (devices) { char *envcopy, *envpath, *delim; envcopy = SDL_strdup(devices); envpath = envcopy; - while (envpath != NULL) { + while (envpath) { delim = SDL_strchr(envpath, ':'); - if (delim != NULL) { + if (delim) { *delim++ = '\0'; } MaybeAddDevice(envpath); @@ -997,7 +997,7 @@ static SDL_joylist_item *JoystickByDevIndex(int device_index) item = SDL_joylist; while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); device_index--; item = item->next; } @@ -1044,7 +1044,7 @@ static int allocate_hatdata(SDL_Joystick *joystick) joystick->hwdata->hats = (struct hwdata_hat *)SDL_malloc(joystick->nhats * sizeof(struct hwdata_hat)); - if (joystick->hwdata->hats == NULL) { + if (!joystick->hwdata->hats) { return -1; } for (i = 0; i < joystick->nhats; ++i) { @@ -1063,7 +1063,7 @@ static int allocate_balldata(SDL_Joystick *joystick) joystick->hwdata->balls = (struct hwdata_ball *)SDL_malloc(joystick->nballs * sizeof(struct hwdata_ball)); - if (joystick->hwdata->balls == NULL) { + if (!joystick->hwdata->balls) { return -1; } for (i = 0; i < joystick->nballs; ++i) { @@ -1082,7 +1082,7 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct * other continuous analog axis, so we have to guess. */ /* If both axes are missing, they're not anything. */ - if (absinfo_x == NULL && absinfo_y == NULL) { + if (!absinfo_x && !absinfo_y) { return SDL_FALSE; } @@ -1092,12 +1092,12 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct } /* If both axes have ranges constrained between -1 and 1, they're definitely digital. */ - if ((absinfo_x == NULL || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (absinfo_y == NULL || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { + if ((!absinfo_x || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (!absinfo_y || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { return SDL_TRUE; } /* If both axes lack fuzz, flat, and resolution values, they're probably digital. */ - if ((absinfo_x == NULL || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (absinfo_y == NULL || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { + if ((!absinfo_x || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (!absinfo_y || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { return SDL_TRUE; } @@ -1392,14 +1392,14 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item, return SDL_SetError("Unable to open %s", item->path); } /* If opening sensor fail, continue with buttons and axes only */ - if (item_sensor != NULL) { + if (item_sensor) { fd_sensor = open(item_sensor->path, O_RDONLY | O_CLOEXEC, 0); } joystick->hwdata->fd = fd; joystick->hwdata->fd_sensor = fd_sensor; joystick->hwdata->fname = SDL_strdup(item->path); - if (joystick->hwdata->fname == NULL) { + if (!joystick->hwdata->fname) { close(fd); if (fd_sensor >= 0) { close(fd_sensor); @@ -1427,7 +1427,7 @@ static SDL_sensorlist_item *GetSensor(SDL_joylist_item *item) SDL_AssertJoysticksLocked(); - if (item == NULL || SDL_sensorlist == NULL) { + if (!item || !SDL_sensorlist) { return NULL; } @@ -1444,10 +1444,10 @@ static SDL_sensorlist_item *GetSensor(SDL_joylist_item *item) SDL_Log("Joystick UNIQ: %s\n", uniq_item); #endif /* DEBUG_INPUT_EVENTS */ - for (item_sensor = SDL_sensorlist; item_sensor != NULL; item_sensor = item_sensor->next) { + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { char uniq_sensor[128]; int fd_sensor = -1; - if (item_sensor->hwdata != NULL) { + if (item_sensor->hwdata) { /* already associated with another joystick */ continue; } @@ -1486,14 +1486,14 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); item = JoystickByDevIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } joystick->instance_id = item->device_instance; joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { return SDL_OutOfMemory(); } @@ -1504,10 +1504,10 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) return -1; /* SDL_SetError will already have been called */ } - SDL_assert(item->hwdata == NULL); - SDL_assert(!item_sensor || item_sensor->hwdata == NULL); + SDL_assert(!item->hwdata); + SDL_assert(!item_sensor || !item_sensor->hwdata); item->hwdata = joystick->hwdata; - if (item_sensor != NULL) { + if (item_sensor) { item_sensor->hwdata = joystick->hwdata; } @@ -1612,7 +1612,7 @@ static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enab } if (enabled) { - if (joystick->hwdata->item_sensor == NULL) { + if (!joystick->hwdata->item_sensor) { return SDL_SetError("Sensors unplugged."); } joystick->hwdata->fd_sensor = open(joystick->hwdata->item_sensor->path, O_RDONLY | O_CLOEXEC, 0); @@ -2191,7 +2191,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap /* We temporarily open the device to check how it's configured. Make a fake SDL_Joystick object to do so. */ joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); - if (joystick == NULL) { + if (!joystick) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -2200,7 +2200,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { SDL_free(joystick); SDL_OutOfMemory(); return SDL_FALSE; diff --git a/src/joystick/os2/SDL_os2joystick.c b/src/joystick/os2/SDL_os2joystick.c index b7e0376b3..49cb67d01 100644 --- a/src/joystick/os2/SDL_os2joystick.c +++ b/src/joystick/os2/SDL_os2joystick.c @@ -731,7 +731,7 @@ static int joyGetEnv(struct _joycfg * joydata) char tempnumber[5]; /* Temporary place to put numeric texts */ joyenv = SDL_getenv("SDL_OS2_JOYSTICK"); - if (joyenv == NULL) { + if (!joyenv) { return 0; } diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index 71095e81d..8706bb3d3 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -53,7 +53,7 @@ static void VIRTUAL_FreeHWData(joystick_hwdata *hwdata) SDL_AssertJoysticksLocked(); - if (hwdata == NULL) { + if (!hwdata) { return; } @@ -102,7 +102,7 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) SDL_AssertJoysticksLocked(); - if (desc == NULL) { + if (!desc) { return SDL_InvalidParamError("desc"); } if (desc->version != SDL_VIRTUAL_JOYSTICK_DESC_VERSION) { @@ -111,7 +111,7 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) } hwdata = SDL_calloc(1, sizeof(joystick_hwdata)); - if (hwdata == NULL) { + if (!hwdata) { VIRTUAL_FreeHWData(hwdata); return SDL_OutOfMemory(); } @@ -248,7 +248,7 @@ int SDL_JoystickDetachVirtualInner(int device_index) { SDL_JoystickID instance_id; joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return SDL_SetError("Virtual joystick data not found"); } instance_id = hwdata->instance_id; @@ -263,7 +263,7 @@ int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 val SDL_LockJoysticks(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -286,7 +286,7 @@ int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 SDL_LockJoysticks(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -309,7 +309,7 @@ int SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value) SDL_LockJoysticks(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -351,7 +351,7 @@ static void VIRTUAL_JoystickDetect(void) static const char *VIRTUAL_JoystickGetDeviceName(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return NULL; } return hwdata->name; @@ -379,7 +379,7 @@ static void VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_in static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { SDL_JoystickGUID guid; SDL_zero(guid); return guid; @@ -390,7 +390,7 @@ static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) static SDL_JoystickID VIRTUAL_JoystickGetDeviceInstanceID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return -1; } return hwdata->instance_id; @@ -403,7 +403,7 @@ static int VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return SDL_SetError("No such device"); } joystick->instance_id = hwdata->instance_id; @@ -529,7 +529,7 @@ static void VIRTUAL_JoystickUpdate(SDL_Joystick *joystick) SDL_AssertJoysticksLocked(); - if (joystick == NULL) { + if (!joystick) { return; } if (!joystick->hwdata) { diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index 92996192f..c86b103ab 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -273,7 +273,7 @@ static SDL_bool QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char **device_name) { DIPROPSTRING dipstr; - if (!device || device_name == NULL) { + if (!device || !device_name) { return SDL_FALSE; } @@ -295,7 +295,7 @@ static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) { DIPROPGUIDANDPATH dippath; - if (!device || device_path == NULL) { + if (!device || !device_path) { return SDL_FALSE; } @@ -320,7 +320,7 @@ static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, { DIPROPDWORD dipdw; - if (!device || vendor_id == NULL || product_id == NULL) { + if (!device || !vendor_id || !product_id) { return SDL_FALSE; } @@ -342,7 +342,7 @@ static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, void FreeRumbleEffectData(DIEFFECT *effect) { - if (effect == NULL) { + if (!effect) { return; } SDL_free(effect->rgdwAxes); @@ -358,7 +358,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) /* Create the effect */ effect = (DIEFFECT *)SDL_calloc(1, sizeof(*effect)); - if (effect == NULL) { + if (!effect) { return NULL; } effect->dwSize = sizeof(*effect); @@ -382,7 +382,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwFlags |= DIEFF_CARTESIAN; periodic = (DIPERIODIC *)SDL_calloc(1, sizeof(*periodic)); - if (periodic == NULL) { + if (!periodic) { FreeRumbleEffectData(effect); return NULL; } @@ -422,7 +422,7 @@ int SDL_DINPUT_JoystickInit(void) /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); - if (instance == NULL) { + if (!instance) { IDirectInput8_Release(dinput); dinput = NULL; return SDL_SetError("GetModuleHandle() failed with error code %lu.", GetLastError()); @@ -545,7 +545,7 @@ err: void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { - if (dinput == NULL) { + if (!dinput) { return; } @@ -597,7 +597,7 @@ SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor_id, Uint16 product_id, Uint16 { Joystick_PresentData data; - if (dinput == NULL) { + if (!dinput) { return SDL_FALSE; } diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 7741129ce..03bcdb78a 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -477,7 +477,7 @@ static const IID IID_IEventHandler_Gamepad = { 0x8a7639ee, 0x624a, 0x501a, { 0xb static HRESULT STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CGamepad *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -619,7 +619,7 @@ static void RAWINPUT_UpdateWindowsGamingInput() return; } gamepad_state = SDL_calloc(1, sizeof(*gamepad_state)); - if (gamepad_state == NULL) { + if (!gamepad_state) { SDL_OutOfMemory(); return; } @@ -1221,7 +1221,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) ULONG i; ctx = (RAWINPUT_DeviceContext *)SDL_calloc(1, sizeof(RAWINPUT_DeviceContext)); - if (ctx == NULL) { + if (!ctx) { return SDL_OutOfMemory(); } joystick->hwdata = ctx; @@ -1234,7 +1234,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT xinput_device_change = SDL_TRUE; ctx->xinput_enabled = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, SDL_TRUE); - if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || XINPUTGETSTATE == NULL)) { + if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || !XINPUTGETSTATE)) { ctx->xinput_enabled = SDL_FALSE; } ctx->xinput_slot = XUSER_INDEX_ANY; @@ -1420,7 +1420,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ if (!rumbled && ctx->xinput_correlated) { XINPUT_VIBRATION XVibration; - if (XINPUTSETSTATE == NULL) { + if (!XINPUTSETSTATE) { return SDL_Unsupported(); } diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index d3369860c..4a1172a79 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -131,7 +131,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) } raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count); - if (raw_devices == NULL) { + if (!raw_devices) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -353,7 +353,7 @@ typedef struct RawGameControllerDelegate static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -443,7 +443,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde } __x_ABI_CWindows_CGaming_CInput_CIRawGameController2_Release(controller2); } - if (name == NULL) { + if (!name) { name = SDL_strdup(""); } @@ -714,7 +714,7 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) boolean wireless = SDL_FALSE; hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } joystick->hwdata = hwdata; diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index d94b314cd..f49bc61ac 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -182,7 +182,7 @@ static DWORD CALLBACK SDL_DeviceNotificationFunc(HCMNOTIFICATION hNotify, PVOID static void SDL_CleanupDeviceNotificationFunc(void) { if (cfgmgr32_lib_handle) { - if (s_DeviceNotificationFuncHandle != NULL && CM_Unregister_Notification != NULL) { + if (s_DeviceNotificationFuncHandle != NULL && CM_Unregister_Notification) { CM_Unregister_Notification(s_DeviceNotificationFuncHandle); s_DeviceNotificationFuncHandle = NULL; } @@ -300,7 +300,7 @@ static int SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) } data->messageWindow = CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); - if (data->messageWindow == NULL) { + if (!data->messageWindow) { WIN_SetError("Failed to create message window for joystick autodetect"); SDL_CleanupDeviceNotification(data); return -1; @@ -410,18 +410,18 @@ static int SDLCALL SDL_JoystickThread(void *_data) static int SDL_StartJoystickThread(void) { s_mutexJoyStickEnum = SDL_CreateMutex(); - if (s_mutexJoyStickEnum == NULL) { + if (!s_mutexJoyStickEnum) { return -1; } s_condJoystickThread = SDL_CreateCond(); - if (s_condJoystickThread == NULL) { + if (!s_condJoystickThread) { return -1; } s_bJoystickThreadQuit = SDL_FALSE; s_joystickThread = SDL_CreateThreadInternal(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL); - if (s_joystickThread == NULL) { + if (!s_joystickThread) { return -1; } return 0; @@ -429,7 +429,7 @@ static int SDL_StartJoystickThread(void) static void SDL_StopJoystickThread(void) { - if (s_joystickThread == NULL) { + if (!s_joystickThread) { return; } @@ -678,7 +678,7 @@ static int WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->instance_id = device->nInstanceID; joystick->hwdata = (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { return SDL_OutOfMemory(); } SDL_zerop(joystick->hwdata); diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 0b288f091..48cbdb021 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -130,7 +130,7 @@ static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 * } devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count); - if (devices == NULL) { + if (!devices) { return; } @@ -277,7 +277,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC } pNewJoystick = (JoyStick_DeviceData *)SDL_calloc(1, sizeof(JoyStick_DeviceData)); - if (pNewJoystick == NULL) { + if (!pNewJoystick) { return; /* better luck next time? */ } diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c index 7e80cbfbe..c4babc4d3 100644 --- a/src/loadso/dlopen/SDL_sysloadso.c +++ b/src/loadso/dlopen/SDL_sysloadso.c @@ -48,7 +48,7 @@ void *SDL_LoadObject(const char *sofile) handle = dlopen(sofile, RTLD_NOW | RTLD_LOCAL); loaderror = dlerror(); - if (handle == NULL) { + if (!handle) { SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return handle; @@ -57,7 +57,7 @@ void *SDL_LoadObject(const char *sofile) void *SDL_LoadFunction(void *handle, const char *name) { void *symbol = dlsym(handle, name); - if (symbol == NULL) { + if (!symbol) { /* prepend an underscore for platforms that need that. */ SDL_bool isstack; size_t len = SDL_strlen(name) + 1; @@ -66,7 +66,7 @@ void *SDL_LoadFunction(void *handle, const char *name) SDL_memcpy(&_name[1], name, len); symbol = dlsym(handle, _name); SDL_small_free(_name, isstack); - if (symbol == NULL) { + if (!symbol) { SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror()); } @@ -76,7 +76,7 @@ void *SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { dlclose(handle); } } diff --git a/src/loadso/os2/SDL_sysloadso.c b/src/loadso/os2/SDL_sysloadso.c index c5c8b3b32..998ffc449 100644 --- a/src/loadso/os2/SDL_sysloadso.c +++ b/src/loadso/os2/SDL_sysloadso.c @@ -90,7 +90,7 @@ void *SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { DosFreeModule((HMODULE)handle); } } diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index ca43370c8..481e4187e 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -34,7 +34,7 @@ void *SDL_LoadObject(const char *sofile) void *handle; LPTSTR tstr; - if (sofile == NULL) { + if (!sofile) { SDL_InvalidParamError("sofile"); return NULL; } @@ -51,7 +51,7 @@ void *SDL_LoadObject(const char *sofile) SDL_free(tstr); /* Generate an error message if all loads failed */ - if (handle == NULL) { + if (!handle) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf)); @@ -63,7 +63,7 @@ void *SDL_LoadObject(const char *sofile) void *SDL_LoadFunction(void *handle, const char *name) { void *symbol = (void *)GetProcAddress((HMODULE)handle, name); - if (symbol == NULL) { + if (!symbol) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); SDL_strlcat(errbuf, name, SDL_arraysize(errbuf)); @@ -74,7 +74,7 @@ void *SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { FreeLibrary((HMODULE)handle); } } diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c index 0c8f611ac..3ca88edcc 100644 --- a/src/locale/SDL_locale.c +++ b/src/locale/SDL_locale.c @@ -32,7 +32,7 @@ static SDL_Locale *build_locales_from_csv_string(char *csv) SDL_Locale *loc; SDL_Locale *retval; - if (csv == NULL || !csv[0]) { + if (!csv || !csv[0]) { return NULL; /* nothing to report */ } @@ -48,7 +48,7 @@ static SDL_Locale *build_locales_from_csv_string(char *csv) alloclen = slen + (num_locales * sizeof(SDL_Locale)); loc = retval = (SDL_Locale *)SDL_calloc(1, alloclen); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; /* oh well */ } diff --git a/src/locale/unix/SDL_syslocale.c b/src/locale/unix/SDL_syslocale.c index 2b9f877fc..9c0e7c06e 100644 --- a/src/locale/unix/SDL_syslocale.c +++ b/src/locale/unix/SDL_syslocale.c @@ -27,12 +27,12 @@ static void normalize_locale_str(char *dst, char *str, size_t buflen) char *ptr; ptr = SDL_strchr(str, '.'); /* chop off encoding if specified. */ - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } ptr = SDL_strchr(str, '@'); /* chop off extra bits if specified. */ - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } @@ -71,7 +71,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) SDL_assert(buflen > 0); tmp = SDL_small_alloc(char, buflen, &isstack); - if (tmp == NULL) { + if (!tmp) { SDL_OutOfMemory(); return; } diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c index 169df915a..3a0472b47 100644 --- a/src/locale/windows/SDL_syslocale.c +++ b/src/locale/windows/SDL_syslocale.c @@ -61,11 +61,11 @@ static void SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) ULONG wbuflen = 0; SDL_bool isstack; - SDL_assert(pGetUserPreferredUILanguages != NULL); + SDL_assert(pGetUserPreferredUILanguages); pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, NULL, &wbuflen); wbuf = SDL_small_alloc(WCHAR, wbuflen, &isstack); - if (wbuf == NULL) { + if (!wbuf) { SDL_OutOfMemory(); return; } @@ -102,7 +102,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) } } - if (pGetUserPreferredUILanguages == NULL) { + if (!pGetUserPreferredUILanguages) { SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* this is always available */ } else { SDL_SYS_GetPreferredLocales_vista(buf, buflen); /* available on Vista and later. */ diff --git a/src/main/haiku/SDL_BeApp.cc b/src/main/haiku/SDL_BeApp.cc index 63af36bdb..bb9904127 100644 --- a/src/main/haiku/SDL_BeApp.cc +++ b/src/main/haiku/SDL_BeApp.cc @@ -109,13 +109,13 @@ static int StartBeLooper() { if (!be_app) { SDL_AppThread = SDL_CreateThreadInternal(StartBeApp, "SDLApplication", 0, NULL); - if (SDL_AppThread == NULL) { + if (!SDL_AppThread) { return SDL_SetError("Couldn't create BApplication thread"); } do { SDL_Delay(10); - } while ((be_app == NULL) || be_app->IsLaunching()); + } while ((!be_app) || be_app->IsLaunching()); } /* Change working directory to that of executable */ @@ -168,7 +168,7 @@ void SDL_QuitBeApp(void) SDL_Looper->Lock(); SDL_Looper->Quit(); SDL_Looper = NULL; - if (SDL_AppThread != NULL) { + if (SDL_AppThread) { if (be_app != NULL) { /* Not tested */ be_app->PostMessage(B_QUIT_REQUESTED); } diff --git a/src/main/ngage/SDL_ngage_main.cpp b/src/main/ngage/SDL_ngage_main.cpp index 10d848870..7439a2fd1 100644 --- a/src/main/ngage/SDL_ngage_main.cpp +++ b/src/main/ngage/SDL_ngage_main.cpp @@ -58,7 +58,7 @@ TInt E32Main() newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy); - if (newHeap == NULL) { + if (!newHeap) { ret = 3; goto cleanup; } else { diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index 189b95420..bad49b0ca 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -43,7 +43,7 @@ static int main_getcmdline(void) int i, argc, result; argvw = CommandLineToArgvW(GetCommandLineW(), &argc); - if (argvw == NULL) { + if (!argvw) { return OutOfMemory(); } @@ -54,13 +54,13 @@ static int main_getcmdline(void) /* Parse it into argv and argc */ argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); - if (argv == NULL) { + if (!argv) { return OutOfMemory(); } for (i = 0; i < argc; ++i) { DWORD len; char *arg = WIN_StringToUTF8W(argvw[i]); - if (arg == NULL) { + if (!arg) { return OutOfMemory(); } len = (DWORD)SDL_strlen(arg); diff --git a/src/misc/SDL_url.c b/src/misc/SDL_url.c index 22faa8417..cfb3ca76c 100644 --- a/src/misc/SDL_url.c +++ b/src/misc/SDL_url.c @@ -23,7 +23,7 @@ int SDL_OpenURL(const char *url) { - if (url == NULL) { + if (!url) { return SDL_InvalidParamError("url"); } return SDL_SYS_OpenURL(url); diff --git a/src/misc/windows/SDL_sysurl.c b/src/misc/windows/SDL_sysurl.c index 6f9c46d4f..eccba63ec 100644 --- a/src/misc/windows/SDL_sysurl.c +++ b/src/misc/windows/SDL_sysurl.c @@ -44,7 +44,7 @@ int SDL_SYS_OpenURL(const char *url) } wurl = WIN_UTF8ToStringW(url); - if (wurl == NULL) { + if (!wurl) { WIN_CoUninitialize(); return SDL_OutOfMemory(); } diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index 63ba38221..8f340c802 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -95,10 +95,10 @@ SDL_PowerState SDL_GetPowerInfo(int *seconds, int *percent) int _seconds, _percent; /* Make these never NULL for platform-specific implementations. */ - if (seconds == NULL) { + if (!seconds) { seconds = &_seconds; } - if (percent == NULL) { + if (!percent) { percent = &_percent; } diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index 84100e856..0e17c9dd2 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -46,7 +46,7 @@ static int open_power_file(const char *base, const char *node, const char *key) int fd; const size_t pathlen = SDL_strlen(base) + SDL_strlen(node) + SDL_strlen(key) + 3; char *path = SDL_stack_alloc(char, pathlen); - if (path == NULL) { + if (!path) { return -1; /* oh well. */ } @@ -242,7 +242,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i *state = SDL_POWERSTATE_UNKNOWN; dirp = opendir(proc_acpi_battery_path); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { @@ -254,7 +254,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i } dirp = opendir(proc_acpi_ac_adapter_path); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { @@ -425,7 +425,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in DIR *dirp; dirp = opendir(base); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; } @@ -616,7 +616,7 @@ SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, in char **paths = NULL; int i, numpaths = 0; - if (dbus == NULL || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", + if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", DBUS_TYPE_INVALID, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &paths, &numpaths, DBUS_TYPE_INVALID)) { return SDL_FALSE; /* try a different approach than UPower. */ diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index b650c6ac4..b67b353bf 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -237,9 +237,9 @@ static int FlushRenderCommands(SDL_Renderer *renderer) { int retval; - SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); + SDL_assert((!renderer->render_commands) == (!renderer->render_commands_tail)); - if (renderer->render_commands == NULL) { /* nothing to do! */ + if (!renderer->render_commands) { /* nothing to do! */ SDL_assert(renderer->vertex_data_used == 0); return 0; } @@ -249,7 +249,7 @@ static int FlushRenderCommands(SDL_Renderer *renderer) retval = renderer->RunCommandQueue(renderer, renderer->render_commands, renderer->vertex_data, renderer->vertex_data_used); /* Move the whole render command queue to the unused pool so we can reuse them next time. */ - if (renderer->render_commands_tail != NULL) { + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = renderer->render_commands_pool; renderer->render_commands_pool = renderer->render_commands; renderer->render_commands_tail = NULL; @@ -301,7 +301,7 @@ void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, ptr = SDL_realloc(renderer->vertex_data, newsize); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); return NULL; } @@ -324,19 +324,19 @@ static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer) /* !!! FIXME: are there threading limitations in SDL's render API? If not, we need to mutex this. */ retval = renderer->render_commands_pool; - if (retval != NULL) { + if (retval) { renderer->render_commands_pool = retval->next; retval->next = NULL; } else { retval = SDL_calloc(1, sizeof(*retval)); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } } - SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); - if (renderer->render_commands_tail != NULL) { + SDL_assert((!renderer->render_commands) == (!renderer->render_commands_tail)); + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = retval; } else { renderer->render_commands = retval; @@ -352,7 +352,7 @@ static int QueueCmdSetViewport(SDL_Renderer *renderer) if (!renderer->viewport_queued || (SDL_memcmp(&renderer->viewport, &renderer->last_queued_viewport, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETVIEWPORT; cmd->data.viewport.first = 0; /* render backend will fill this in. */ /* Convert SDL_DRect to SDL_Rect */ @@ -379,7 +379,7 @@ static int QueueCmdSetClipRect(SDL_Renderer *renderer) (renderer->clipping_enabled != renderer->last_queued_cliprect_enabled) || (SDL_memcmp(&renderer->clip_rect, &renderer->last_queued_cliprect, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd == NULL) { + if (!cmd) { retval = -1; } else { cmd->command = SDL_RENDERCMD_SETCLIPRECT; @@ -406,7 +406,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETDRAWCOLOR; cmd->data.color.first = 0; /* render backend will fill this in. */ cmd->data.color.r = col->r; @@ -428,7 +428,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) static int QueueCmdClear(SDL_Renderer *renderer) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd == NULL) { + if (!cmd) { return -1; } @@ -472,7 +472,7 @@ static SDL_RenderCommand *PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_Ren if (retval == 0) { cmd = AllocateRenderCommand(renderer); - if (cmd != NULL) { + if (cmd) { cmd->command = cmdtype; cmd->data.draw.first = 0; /* render backend will fill this in. */ cmd->data.draw.count = 0; /* render backend will fill this in. */ @@ -491,7 +491,7 @@ static int QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_POINTS, NULL); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueDrawPoints(renderer, cmd, points, count); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -504,7 +504,7 @@ static int QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, c { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_LINES, NULL); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueDrawLines(renderer, cmd, points, count); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -517,11 +517,11 @@ static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, con { SDL_RenderCommand *cmd; int retval = -1; - const int use_rendergeometry = (renderer->QueueFillRects == NULL); + const int use_rendergeometry = (!renderer->QueueFillRects); cmd = PrepQueueCmdDraw(renderer, (use_rendergeometry ? SDL_RENDERCMD_GEOMETRY : SDL_RENDERCMD_FILL_RECTS), NULL); - if (cmd != NULL) { + if (cmd) { if (use_rendergeometry) { SDL_bool isstack1; SDL_bool isstack2; @@ -591,7 +591,7 @@ static int QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_ { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY, texture); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueCopy(renderer, cmd, texture, srcrect, dstrect); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -606,7 +606,7 @@ static int QueueCmdCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY_EX, texture); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueCopyEx(renderer, cmd, texture, srcquad, dstrect, angle, center, flip, scale_x, scale_y); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -626,7 +626,7 @@ static int QueueCmdGeometry(SDL_Renderer *renderer, SDL_Texture *texture, SDL_RenderCommand *cmd; int retval = -1; cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_GEOMETRY, texture); - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueGeometry(renderer, cmd, texture, xy, xy_stride, color, color_stride, uv, uv_stride, @@ -883,13 +883,13 @@ static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer) { /* all of these functions are required to be implemented, even as no-ops, so we don't have to check that they aren't NULL over and over. */ - SDL_assert(renderer->QueueSetViewport != NULL); - SDL_assert(renderer->QueueSetDrawColor != NULL); - SDL_assert(renderer->QueueDrawPoints != NULL); - SDL_assert(renderer->QueueDrawLines != NULL || renderer->QueueGeometry != NULL); - SDL_assert(renderer->QueueFillRects != NULL || renderer->QueueGeometry != NULL); - SDL_assert(renderer->QueueCopy != NULL || renderer->QueueGeometry != NULL); - SDL_assert(renderer->RunCommandQueue != NULL); + SDL_assert(renderer->QueueSetViewport); + SDL_assert(renderer->QueueSetDrawColor); + SDL_assert(renderer->QueueDrawPoints); + SDL_assert(renderer->QueueDrawLines || renderer->QueueGeometry); + SDL_assert(renderer->QueueFillRects || renderer->QueueGeometry); + SDL_assert(renderer->QueueCopy || renderer->QueueGeometry); + SDL_assert(renderer->RunCommandQueue); } static SDL_RenderLineMethod SDL_GetRenderLineMethod() @@ -945,7 +945,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) Android_ActivityMutex_Lock_Running(); #endif - if (window == NULL) { + if (!window) { SDL_InvalidParamError("window"); goto error; } @@ -986,7 +986,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) } } - if (renderer == NULL) { + if (!renderer) { for (index = 0; index < n; ++index) { const SDL_RenderDriver *driver = render_drivers[index]; @@ -1000,7 +1000,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) } } } - if (renderer == NULL) { + if (!renderer) { SDL_SetError("Couldn't find matching render driver"); goto error; } @@ -1013,7 +1013,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) /* Create a new renderer instance */ renderer = render_drivers[index]->CreateRenderer(window, flags); batching = SDL_FALSE; - if (renderer == NULL) { + if (!renderer) { goto error; } } @@ -1228,7 +1228,7 @@ static SDL_ScaleMode SDL_GetScaleMode(void) { const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); - if (hint == NULL || SDL_strcasecmp(hint, "nearest") == 0) { + if (!hint || SDL_strcasecmp(hint, "nearest") == 0) { return SDL_ScaleModeNearest; } else if (SDL_strcasecmp(hint, "linear") == 0) { return SDL_ScaleModeLinear; @@ -1269,7 +1269,7 @@ SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access return NULL; } texture = (SDL_Texture *)SDL_calloc(1, sizeof(*texture)); - if (texture == NULL) { + if (!texture) { SDL_OutOfMemory(); return NULL; } @@ -1360,7 +1360,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s CHECK_RENDERER_MAGIC(renderer, NULL); - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("SDL_CreateTextureFromSurface(): surface"); return NULL; } @@ -1424,7 +1424,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC, surface->w, surface->h); - if (texture == NULL) { + if (!texture) { return NULL; } @@ -1468,7 +1468,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); - if (dst_fmt == NULL) { + if (!dst_fmt) { SDL_DestroyTexture(texture); return NULL; } @@ -1687,7 +1687,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1727,7 +1727,7 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_ConvertPixels(rect->w, rect->h, @@ -1747,7 +1747,7 @@ int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (pixels == NULL) { + if (!pixels) { return SDL_InvalidParamError("pixels"); } if (!pitch) { @@ -1821,7 +1821,7 @@ static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1871,7 +1871,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1896,19 +1896,19 @@ int SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (Yplane == NULL) { + if (!Yplane) { return SDL_InvalidParamError("Yplane"); } if (!Ypitch) { return SDL_InvalidParamError("Ypitch"); } - if (Uplane == NULL) { + if (!Uplane) { return SDL_InvalidParamError("Uplane"); } if (!Upitch) { return SDL_InvalidParamError("Upitch"); } - if (Vplane == NULL) { + if (!Vplane) { return SDL_InvalidParamError("Vplane"); } if (!Vpitch) { @@ -1962,13 +1962,13 @@ int SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (Yplane == NULL) { + if (!Yplane) { return SDL_InvalidParamError("Yplane"); } if (!Ypitch) { return SDL_InvalidParamError("Ypitch"); } - if (UVplane == NULL) { + if (!UVplane) { return SDL_InvalidParamError("UVplane"); } if (!UVpitch) { @@ -2042,7 +2042,7 @@ int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, return SDL_SetError("SDL_LockTexture(): texture must be streaming"); } - if (rect == NULL) { + if (!rect) { full_rect.x = 0; full_rect.y = 0; full_rect.w = texture->w; @@ -2078,7 +2078,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, int pitch = 0; /* fix static analysis */ int ret; - if (texture == NULL || surface == NULL) { + if (!texture || !surface) { return -1; } @@ -2096,7 +2096,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, } texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, 0, pitch, texture->format); - if (texture->locked_surface == NULL) { + if (!texture->locked_surface) { SDL_UnlockTexture(texture); return -1; } @@ -2172,7 +2172,7 @@ void SDL_UnlockTexture(SDL_Texture *texture) SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer) { - if (renderer == NULL || !renderer->SetRenderTarget) { + if (!renderer || !renderer->SetRenderTarget) { return SDL_FALSE; } return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0; @@ -2660,7 +2660,7 @@ static int RenderDrawPointsWithRects(SDL_Renderer *renderer, } frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2688,7 +2688,7 @@ int SDL_RenderDrawPoints(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawPoints(): points"); } if (count < 1) { @@ -2706,7 +2706,7 @@ int SDL_RenderDrawPoints(SDL_Renderer *renderer, retval = RenderDrawPointsWithRects(renderer, points, count); } else { fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack); - if (fpoints == NULL) { + if (!fpoints) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -2734,7 +2734,7 @@ static int RenderDrawPointsWithRectsF(SDL_Renderer *renderer, } frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2759,7 +2759,7 @@ int SDL_RenderDrawPointsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawPointsF(): points"); } if (count < 1) { @@ -2851,7 +2851,7 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x } points = SDL_small_alloc(SDL_FPoint, numpixels, &isstack); - if (points == NULL) { + if (!points) { return SDL_OutOfMemory(); } for (i = 0; i < numpixels; ++i) { @@ -2894,7 +2894,7 @@ static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer, SDL_bool draw_last = SDL_FALSE; frects = SDL_small_alloc(SDL_FRect, count - 1, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2964,7 +2964,7 @@ int SDL_RenderDrawLines(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawLines(): points"); } if (count < 2) { @@ -2979,7 +2979,7 @@ int SDL_RenderDrawLines(SDL_Renderer *renderer, #endif fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack); - if (fpoints == NULL) { + if (!fpoints) { return SDL_OutOfMemory(); } @@ -3002,7 +3002,7 @@ int SDL_RenderDrawLinesF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawLinesF(): points"); } if (count < 2) { @@ -3171,7 +3171,7 @@ int SDL_RenderDrawRectF(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); /* If 'rect' == NULL, then outline the whole surface */ - if (rect == NULL) { + if (!rect) { RenderGetViewportSize(renderer, &frect); rect = &frect; } @@ -3196,7 +3196,7 @@ int SDL_RenderDrawRects(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderDrawRects(): rects"); } if (count < 1) { @@ -3225,7 +3225,7 @@ int SDL_RenderDrawRectsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderDrawRectsF(): rects"); } if (count < 1) { @@ -3272,7 +3272,7 @@ int SDL_RenderFillRectF(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); /* If 'rect' == NULL, then outline the whole surface */ - if (rect == NULL) { + if (!rect) { RenderGetViewportSize(renderer, &frect); rect = &frect; } @@ -3289,7 +3289,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderFillRects(): rects"); } if (count < 1) { @@ -3304,7 +3304,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, #endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -3331,7 +3331,7 @@ int SDL_RenderFillRectsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderFillRectsF(): rects"); } if (count < 1) { @@ -3346,7 +3346,7 @@ int SDL_RenderFillRectsF(SDL_Renderer *renderer, #endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -3400,7 +3400,7 @@ int SDL_RenderCopyF(SDL_Renderer *renderer, SDL_Texture *texture, } #endif - use_rendergeometry = (renderer->QueueCopy == NULL); + use_rendergeometry = (!renderer->QueueCopy); real_srcrect.x = 0; real_srcrect.y = 0; @@ -3540,7 +3540,7 @@ int SDL_RenderCopyExF(SDL_Renderer *renderer, SDL_Texture *texture, } #endif - use_rendergeometry = (renderer->QueueCopyEx == NULL); + use_rendergeometry = (!renderer->QueueCopyEx); real_srcrect.x = 0; real_srcrect.y = 0; @@ -4071,15 +4071,15 @@ int SDL_RenderGeometryRaw(SDL_Renderer *renderer, } } - if (xy == NULL) { + if (!xy) { return SDL_InvalidParamError("xy"); } - if (color == NULL) { + if (!color) { return SDL_InvalidParamError("color"); } - if (texture && uv == NULL) { + if (texture && !uv) { return SDL_InvalidParamError("uv"); } @@ -4171,7 +4171,7 @@ int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, FlushRenderCommands(renderer); /* we need to render before we read the results. */ if (!format) { - if (renderer->target == NULL) { + if (!renderer->target) { format = SDL_GetWindowPixelFormat(renderer->window); } else { format = renderer->target->format; @@ -4300,7 +4300,7 @@ void SDL_DestroyRenderer(SDL_Renderer *renderer) SDL_DelEventWatch(SDL_RendererEventWatch, renderer); - if (renderer->render_commands_tail != NULL) { + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = renderer->render_commands_pool; cmd = renderer->render_commands; } else { @@ -4311,7 +4311,7 @@ void SDL_DestroyRenderer(SDL_Renderer *renderer) renderer->render_commands_tail = NULL; renderer->render_commands = NULL; - while (cmd != NULL) { + while (cmd) { SDL_RenderCommand *next = cmd->next; SDL_free(cmd); cmd = next; diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index c4385e288..45f5b88aa 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -47,7 +47,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) } swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata)); - if (swdata == NULL) { + if (!swdata) { SDL_OutOfMemory(); return NULL; } diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 5470a7d40..03e407030 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -443,7 +443,7 @@ static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *te { HRESULT result; - if (texture->staging == NULL) { + if (!texture->staging) { result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0, texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL); if (FAILED(result)) { @@ -535,7 +535,7 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) DWORD usage; texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata)); - if (texturedata == NULL) { + if (!texturedata) { return SDL_OutOfMemory(); } texturedata->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR; @@ -573,7 +573,7 @@ static int D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return 0; } @@ -600,7 +600,7 @@ static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -636,7 +636,7 @@ static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -660,7 +660,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; IDirect3DDevice9 *device = data->device; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -710,7 +710,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return; } #if SDL_HAVE_YUV @@ -738,7 +738,7 @@ static void D3D_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return; } @@ -754,18 +754,18 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text IDirect3DDevice9 *device = data->device; /* Release the previous render target if it wasn't the default one */ - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } - if (texture == NULL) { + if (!texture) { IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget); return 0; } texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -820,7 +820,7 @@ static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -845,7 +845,7 @@ static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL int count = indices ? num_indices : num_vertices; Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(Vertex), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -939,9 +939,9 @@ static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, LPDIREC { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - SDL_assert(*shader == NULL); + SDL_assert(!*shader); - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -993,11 +993,11 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) LPDIRECT3DPIXELSHADER9 shader = NULL; /* disable any enabled textures we aren't going to use, let SetupTextureState() do the rest. */ - if (texture == NULL) { + if (!texture) { IDirect3DDevice9_SetTexture(data->device, 0, NULL); } #if SDL_HAVE_YUV - if ((newtexturedata == NULL || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) { + if ((!newtexturedata || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) { IDirect3DDevice9_SetTexture(data->device, 1, NULL); IDirect3DDevice9_SetTexture(data->device, 2, NULL); } @@ -1391,7 +1391,7 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) #endif } - if (data == NULL) { + if (!data) { return; } @@ -1417,7 +1417,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer) IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; } - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } @@ -1468,7 +1468,7 @@ static int D3D_Reset(SDL_Renderer *renderer) IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; } - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } @@ -1562,13 +1562,13 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) int displayIndex; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 2d8ee3c0a..002b7629b 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -385,7 +385,7 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen } blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes)); - if (blendModes == NULL) { + if (!blendModes) { SAFE_RELEASE(blendState); SDL_OutOfMemory(); return NULL; @@ -442,7 +442,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory"); - if (CreateDXGIFactoryFunc == NULL) { + if (!CreateDXGIFactoryFunc) { result = E_FAIL; goto done; } @@ -740,7 +740,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; #ifdef __WINRT__ IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer); - const BOOL usingXAML = (coreWindow == NULL); + const BOOL usingXAML = (!coreWindow); #else IUnknown *coreWindow = NULL; const BOOL usingXAML = FALSE; @@ -929,7 +929,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) #endif } else { result = D3D11_CreateSwapChain(renderer, w, h); - if (FAILED(result) || data->swapChain == NULL) { + if (FAILED(result) || !data->swapChain) { goto done; } } @@ -1071,7 +1071,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData)); - if (textureData == NULL) { + if (!textureData) { SDL_OutOfMemory(); return -1; } @@ -1232,7 +1232,7 @@ static void D3D11_DestroyTexture(SDL_Renderer *renderer, { D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata; - if (data == NULL) { + if (!data) { return; } @@ -1339,7 +1339,7 @@ static int D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1384,7 +1384,7 @@ static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1408,7 +1408,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1432,7 +1432,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_TEXTURE2D_DESC stagingTextureDesc; D3D11_MAPPED_SUBRESOURCE textureMemory; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -1511,7 +1511,7 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } #if SDL_HAVE_YUV @@ -1547,7 +1547,7 @@ static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu { D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -1559,7 +1559,7 @@ static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = NULL; - if (texture == NULL) { + if (!texture) { rendererData->currentOffscreenRenderTargetView = NULL; return 0; } @@ -1590,7 +1590,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -1617,7 +1617,7 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -1889,9 +1889,9 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c break; } } - if (blendState == NULL) { + if (!blendState) { blendState = D3D11_CreateBlendState(renderer, blendMode); - if (blendState == NULL) { + if (!blendState) { return -1; } } @@ -2144,13 +2144,13 @@ static int D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, D3D11_MAPPED_SUBRESOURCE textureMemory; renderTargetView = D3D11_GetCurrentRenderTargetView(renderer); - if (renderTargetView == NULL) { + if (!renderTargetView) { SDL_SetError("%s, ID3D11DeviceContext::OMGetRenderTargets failed", __FUNCTION__); goto done; } ID3D11View_GetResource(renderTargetView, (ID3D11Resource **)&backBuffer); - if (backBuffer == NULL) { + if (!backBuffer) { SDL_SetError("%s, ID3D11View::GetResource failed", __FUNCTION__); goto done; } @@ -2305,13 +2305,13 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, Uint32 flags) D3D11_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/direct3d11/SDL_render_winrt.cpp b/src/render/direct3d11/SDL_render_winrt.cpp index 3f24d0f21..4633e11f7 100644 --- a/src/render/direct3d11/SDL_render_winrt.cpp +++ b/src/render/direct3d11/SDL_render_winrt.cpp @@ -46,7 +46,7 @@ extern "C" void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer) { SDL_Window *sdlWindow = renderer->window; - if (renderer->window == NULL) { + if (!renderer->window) { return NULL; } diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index cf49020ab..bfce68043 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -633,7 +633,7 @@ static D3D12_PipelineState *D3D12_CreatePipelineState(SDL_Renderer *renderer, } pipelineStates = (D3D12_PipelineState *)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates)); - if (pipelineStates == NULL) { + if (!pipelineStates) { SAFE_RELEASE(pipelineState); SDL_OutOfMemory(); return NULL; @@ -748,7 +748,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } } #endif - if (CreateEventExFunc == NULL) { + if (!CreateEventExFunc) { result = E_FAIL; goto done; } @@ -761,7 +761,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2"); - if (CreateDXGIFactoryFunc == NULL) { + if (!CreateDXGIFactoryFunc) { result = E_FAIL; goto done; } @@ -805,7 +805,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) /* If the debug hint is set, also create the DXGI factory in debug mode */ DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1"); - if (DXGIGetDebugInterfaceFunc == NULL) { + if (!DXGIGetDebugInterfaceFunc) { result = E_FAIL; goto done; } @@ -1438,7 +1438,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } textureData = (D3D12_TextureData *)SDL_calloc(1, sizeof(*textureData)); - if (textureData == NULL) { + if (!textureData) { SDL_OutOfMemory(); return -1; } @@ -1616,7 +1616,7 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -1794,7 +1794,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1839,7 +1839,7 @@ static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1863,7 +1863,7 @@ static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1892,7 +1892,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, BYTE *textureMemory; int bpp; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -2011,7 +2011,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D12_TEXTURE_COPY_LOCATION dstLocation; int bpp; - if (textureData == NULL) { + if (!textureData) { return; } #if SDL_HAVE_YUV @@ -2082,7 +2082,7 @@ static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu { D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -2094,7 +2094,7 @@ static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = NULL; - if (texture == NULL) { + if (!texture) { if (rendererData->textureRenderTarget) { D3D12_TransitionResource(rendererData, rendererData->textureRenderTarget->mainTexture, @@ -2137,7 +2137,7 @@ static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -2164,7 +2164,7 @@ static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -2965,13 +2965,13 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, Uint32 flags) D3D12_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 291afba5d..c7dc3fc27 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -186,7 +186,7 @@ GL_ClearErrors(SDL_Renderer *renderer) data->errors = 0; data->error_messages = NULL; } - } else if (data->glGetError != NULL) { + } else if (data->glGetError) { while (data->glGetError() != GL_NO_ERROR) { /* continue; */ } @@ -306,7 +306,7 @@ static GL_FBOList *GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h) result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GL_FBOList)); if (result) { result->w = w; @@ -471,7 +471,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } data = (GL_TextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -888,7 +888,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); return 0; } @@ -918,7 +918,7 @@ static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -938,7 +938,7 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con const size_t vertlen = (sizeof(GLfloat) * 2) * count; GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } cmd->data.draw.count = count; @@ -983,7 +983,7 @@ static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_ size_t sz = 2 * sizeof(GLfloat) + 4 * sizeof(Uint8) + (texture ? 2 : 0) * sizeof(GLfloat); verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -1089,7 +1089,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const } if ((cmd->data.draw.texture != NULL) != data->drawstate.texturing) { - if (cmd->data.draw.texture == NULL) { + if (!cmd->data.draw.texture) { data->glDisable(data->textype); data->drawstate.texturing = SDL_FALSE; } else { @@ -1294,7 +1294,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1328,7 +1328,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1437,7 +1437,7 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); temp_pixels = SDL_malloc((size_t)rect->h * temp_pitch); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -1502,7 +1502,7 @@ static void GL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderdata->drawstate.target = NULL; } - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -1524,7 +1524,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer) GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (data) { - if (data->context != NULL) { + if (data->context) { /* make sure we delete the right resources! */ GL_ActivateRenderer(renderer); } @@ -1730,13 +1730,13 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) #endif renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GL_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); goto error; @@ -1831,7 +1831,7 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) } hint = SDL_getenv("GL_ARB_texture_non_power_of_two"); - if (hint == NULL || *hint != '0') { + if (!hint || *hint != '0') { SDL_bool isGL2 = SDL_FALSE; const char *verstr = (const char *)data->glGetString(GL_VERSION); if (verstr) { diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 82b04cea8..db2095455 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -497,7 +497,7 @@ GL_ShaderContext *GL_CreateShaderContext(void) int i; ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { return NULL; } diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 962acba52..0b60de8e2 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -187,7 +187,7 @@ static GLES_FBOList *GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h) while ((result) && ((result->w != w) || (result->h != h))) { result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GLES_FBOList)); result->w = w; result->h = h; @@ -332,7 +332,7 @@ static int GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } data = (GLES_TextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -424,7 +424,7 @@ static int GLES_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, src = (Uint8 *)pixels; if (pitch != srcPitch) { blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); - if (blob == NULL) { + if (!blob) { return SDL_OutOfMemory(); } src = blob; @@ -510,7 +510,7 @@ static int GLES_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer); return 0; } @@ -537,7 +537,7 @@ static int GLES_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -557,7 +557,7 @@ static int GLES_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c const size_t vertlen = (sizeof(GLfloat) * 2) * count; GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } cmd->data.draw.count = count; @@ -602,7 +602,7 @@ static int GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD int sz = 2 + 4 + (texture ? 2 : 0); verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz * sizeof(GLfloat), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -911,7 +911,7 @@ static int GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); temp_pixels = SDL_malloc(rect->h * temp_pitch); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -970,7 +970,7 @@ static void GLES_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderdata->drawstate.target = NULL; } - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -1082,13 +1082,13 @@ static SDL_Renderer *GLES_CreateRenderer(SDL_Window *window, Uint32 flags) } renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GLES_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { GLES_DestroyRenderer(renderer); SDL_OutOfMemory(); goto error; diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index c5f53af2d..1ce23920c 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -220,7 +220,7 @@ GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, for (;;) { GLenum error = data->glGetError(); if (error != GL_NO_ERROR) { - if (prefix == NULL || prefix[0] == '\0') { + if (!prefix || prefix[0] == '\0') { prefix = "generic"; } SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error); @@ -275,7 +275,7 @@ static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h) while ((result) && ((result->w != w) || (result->h != h))) { result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GLES2_FBOList)); result->w = w; result->h = h; @@ -427,7 +427,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin /* Create a program cache entry */ entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return NULL; } @@ -488,7 +488,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { data->glDeleteProgram(data->program_cache.tail->id); data->program_cache.tail = data->program_cache.tail->prev; - if (data->program_cache.tail != NULL) { + if (data->program_cache.tail) { SDL_free(data->program_cache.tail->next); data->program_cache.tail->next = NULL; } @@ -505,7 +505,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G const GLchar *shader_src_list[3]; const GLchar *shader_body = GLES2_GetShader(type); - if (shader_body == NULL) { + if (!shader_body) { SDL_SetError("No shader body src"); return 0; } @@ -715,7 +715,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, /* Generate a matching program */ program = GLES2_CacheProgram(data, vertex, fragment); - if (program == NULL) { + if (!program) { goto fault; } @@ -748,7 +748,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -781,7 +781,7 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -839,7 +839,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S if (texture) { SDL_Vertex *verts = (SDL_Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -879,7 +879,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S } else { SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -959,7 +959,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co } if ((texture != NULL) != data->drawstate.texturing) { - if (texture == NULL) { + if (!texture) { data->glDisableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); data->drawstate.texturing = SDL_FALSE; } else { @@ -1282,7 +1282,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1316,7 +1316,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1455,7 +1455,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Allocate a texture struct */ data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->texture = 0; @@ -1590,7 +1590,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff src = (Uint8 *)pixels; if (pitch != src_pitch) { blob = (Uint8 *)SDL_malloc(src_pitch * height); - if (blob == NULL) { + if (!blob) { return SDL_OutOfMemory(); } src = blob; @@ -1607,7 +1607,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff int i; Uint32 *src32 = (Uint32 *)src; blob2 = (Uint32 *)SDL_malloc(src_pitch * height); - if (blob2 == NULL) { + if (!blob2) { if (blob) { SDL_free(blob); } @@ -1868,7 +1868,7 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer); } else { texturedata = (GLES2_TextureData *)texture->driverdata; @@ -1934,7 +1934,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, } temp_pixels = SDL_malloc(buflen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -2093,13 +2093,13 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) /* Create the renderer struct */ renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GLES2_RenderData *)SDL_calloc(1, sizeof(GLES2_RenderData)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); goto error; diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c index dc4bafaab..f88eac9f3 100644 --- a/src/render/ps2/SDL_render_ps2.c +++ b/src/render/ps2/SDL_render_ps2.c @@ -105,7 +105,7 @@ static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE)); - if (ps2_tex == NULL) { + if (!ps2_tex) { return SDL_OutOfMemory(); } @@ -202,7 +202,7 @@ static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c gs_rgbaq rgbaq; int i; - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -237,7 +237,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL GSPRIMUVPOINT *vertices = (GSPRIMUVPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMUVPOINT), 4, &cmd->data.draw.first); GSTEXTURE *ps2_tex = (GSTEXTURE *) texture->driverdata; - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -270,7 +270,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL } else { GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -531,11 +531,11 @@ static void PS2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - if (data == NULL) { + if (!data) { return; } - if (ps2_texture == NULL) { + if (!ps2_texture) { return; } @@ -584,13 +584,13 @@ static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_bool dynamicVsync; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { PS2_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 95a48d9ff..892e02820 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -282,11 +282,11 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst) src = (unsigned int *)psp_texture->data; data = dst; - if (data == NULL) { + if (!data) { data = SDL_malloc(psp_texture->size); } - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -344,11 +344,11 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst) data = dst; - if (data == NULL) { + if (!data) { data = SDL_malloc(psp_texture->size); } - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -392,7 +392,7 @@ static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture if (psp_texture->swizzled) { // Texture was swizzled in vram, just copy to system memory void *sdata = SDL_malloc(psp_texture->size); - if (sdata == NULL) { + if (!sdata) { return SDL_OutOfMemory(); } @@ -484,7 +484,7 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) PSP_RenderData *data = renderer->driverdata; PSP_TextureData *psp_texture = (PSP_TextureData *)SDL_calloc(1, sizeof(*psp_texture)); - if (psp_texture == NULL) { + if (!psp_texture) { return SDL_OutOfMemory(); } @@ -630,7 +630,7 @@ static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertV), 4, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -656,10 +656,10 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL cmd->data.draw.count = count; size_indices = indices ? size_indices : 0; - if (texture == NULL) { + if (!texture) { VertCV *verts; verts = (VertCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertCV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -692,7 +692,7 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; VertTCV *verts; verts = (VertTCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertTCV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -737,7 +737,7 @@ static int PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertV), 4, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -773,7 +773,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex if ((MathAbs(u1) - MathAbs(u0)) < 64.0f) { verts = (VertTV *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(VertTV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -809,7 +809,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex cmd->data.draw.count = count; verts = (VertTV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertTV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -860,7 +860,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T float u1 = srcrect->x + srcrect->w; float v1 = srcrect->y + srcrect->h; - if (verts == NULL) { + if (!verts) { return -1; } @@ -1011,7 +1011,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state) } if (state->texture != current->texture) { - if (state->texture != NULL) { + if (state->texture) { TextureActivate(state->texture); sceGuEnable(GU_TEXTURE_2D); } else { @@ -1035,7 +1035,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v rendering backends report a reasonable maximum, so the higher level can flush if we appear to be exceeding that. */ gpumem = (Uint8 *)sceGuGetMemory(vertsize); - if (gpumem == NULL) { + if (!gpumem) { return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int)vertsize); } SDL_memcpy(gpumem, vertices, vertsize); @@ -1177,7 +1177,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v case SDL_RENDERCMD_GEOMETRY: { const size_t count = cmd->data.draw.count; - if (cmd->data.draw.texture == NULL) { + if (!cmd->data.draw.texture) { const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first); sceGuDisable(GU_TEXTURE_2D); /* In GU_SMOOTH mode */ @@ -1245,11 +1245,11 @@ static void PSP_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) PSP_RenderData *renderdata = (PSP_RenderData *)renderer->driverdata; PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; - if (renderdata == NULL) { + if (!renderdata) { return; } - if (psp_texture == NULL) { + if (!psp_texture) { return; } @@ -1300,13 +1300,13 @@ SDL_Renderer *PSP_CreateRenderer(SDL_Window *window, Uint32 flags) void *doublebuffer = NULL; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (PSP_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { PSP_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/software/SDL_blendfillrect.c b/src/render/software/SDL_blendfillrect.c index 2489eb11a..876c94d66 100644 --- a/src/render/software/SDL_blendfillrect.c +++ b/src/render/software/SDL_blendfillrect.c @@ -211,7 +211,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, { SDL_Rect clipped; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendFillRect(): dst"); } @@ -281,7 +281,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; int status = 0; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendFillRects(): dst"); } @@ -325,7 +325,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, break; } - if (func == NULL) { + if (!func) { if (!dst->format->Amask) { func = SDL_BlendFillRect_RGB; } else { diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c index 0d6365619..1a17a1b56 100644 --- a/src/render/software/SDL_blendline.c +++ b/src/render/software/SDL_blendline.c @@ -798,12 +798,12 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, { BlendLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendLine(): dst"); } func = SDL_CalculateBlendLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_BlendLine(): Unsupported surface format"); } @@ -826,12 +826,12 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_bool draw_end; BlendLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface"); } func = SDL_CalculateBlendLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_BlendLines(): Unsupported surface format"); } diff --git a/src/render/software/SDL_blendpoint.c b/src/render/software/SDL_blendpoint.c index 3fc68f45e..5c781cc06 100644 --- a/src/render/software/SDL_blendpoint.c +++ b/src/render/software/SDL_blendpoint.c @@ -209,7 +209,7 @@ static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode ble int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendPoint(): dst"); } @@ -277,7 +277,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; int status = 0; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendPoints(): dst"); } @@ -323,7 +323,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, break; } - if (func == NULL) { + if (!func) { if (!dst->format->Amask) { func = SDL_BlendPoint_RGB; } else { diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c index 8acf5ee89..77baf59ed 100644 --- a/src/render/software/SDL_drawline.c +++ b/src/render/software/SDL_drawline.c @@ -137,12 +137,12 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color) { DrawLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawLine(): dst"); } func = SDL_CalculateDrawLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_DrawLine(): Unsupported surface format"); } @@ -165,12 +165,12 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_bool draw_end; DrawLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawLines(): dst"); } func = SDL_CalculateDrawLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_DrawLines(): Unsupported surface format"); } diff --git a/src/render/software/SDL_drawpoint.c b/src/render/software/SDL_drawpoint.c index 77404421a..bc7763c29 100644 --- a/src/render/software/SDL_drawpoint.c +++ b/src/render/software/SDL_drawpoint.c @@ -27,7 +27,7 @@ int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawPoint(): dst"); } @@ -67,7 +67,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, int i; int x, y; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawPoints(): dst"); } diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 7ba51a8e2..6420b108a 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -196,7 +196,7 @@ static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -215,7 +215,7 @@ static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -236,7 +236,7 @@ static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Text { SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -270,7 +270,7 @@ static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Te { CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -324,7 +324,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex int blitRequired = SDL_FALSE; int isOpaque = SDL_FALSE; - if (surface == NULL) { + if (!surface) { return -1; } @@ -346,7 +346,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_clone = SDL_CreateRGBSurfaceFrom(src->pixels, src->w, src->h, src->format->BitsPerPixel, src->pitch, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); - if (src_clone == NULL) { + if (!src_clone) { if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } @@ -390,7 +390,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) { mask = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); - if (mask == NULL) { + if (!mask) { retval = -1; } else { SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD); @@ -404,7 +404,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex SDL_Rect scale_rect = tmp_rect; src_scaled = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); - if (src_scaled == NULL) { + if (!src_scaled) { retval = -1; } else { SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE); @@ -427,15 +427,15 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_rotated = SDLgfx_rotateSurface(src_clone, angle, (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, &rect_dest, cangle, sangle, center); - if (src_rotated == NULL) { + if (!src_rotated) { retval = -1; } - if (!retval && mask != NULL) { + if (!retval && mask) { /* The mask needed for the NONE blend mode gets rotated with the same parameters. */ mask_rotated = SDLgfx_rotateSurface(mask, angle, SDL_FALSE, 0, 0, &rect_dest, cangle, sangle, center); - if (mask_rotated == NULL) { + if (!mask_rotated) { retval = -1; } } @@ -487,7 +487,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_rotated->format->BitsPerPixel, src_rotated->pitch, src_rotated->format->Rmask, src_rotated->format->Gmask, src_rotated->format->Bmask, 0); - if (src_rotated_rgb == NULL) { + if (!src_rotated_rgb) { retval = -1; } else { SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD); @@ -499,7 +499,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex } SDL_FreeSurface(mask_rotated); } - if (src_rotated != NULL) { + if (src_rotated) { SDL_FreeSurface(src_rotated); } } @@ -508,10 +508,10 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } - if (mask != NULL) { + if (mask) { SDL_FreeSurface(mask); } - if (src_clone != NULL) { + if (src_clone) { SDL_FreeSurface(src_clone); } return retval; @@ -538,10 +538,10 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_ int i; int count = indices ? num_indices : num_vertices; void *verts; - size_t sz = texture != NULL ? sizeof(GeometryCopyData) : sizeof(GeometryFillData); + size_t sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData); verts = SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -641,9 +641,9 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) if (drawstate->surface_cliprect_dirty) { const SDL_Rect *viewport = drawstate->viewport; const SDL_Rect *cliprect = drawstate->cliprect; - SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ + SDL_assert_release(viewport); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ - if (cliprect != NULL) { + if (cliprect) { SDL_Rect clip_rect; clip_rect.x = cliprect->x + viewport->x; clip_rect.y = cliprect->y + viewport->y; @@ -663,7 +663,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_Surface *surface = SW_ActivateRenderer(renderer); SW_DrawStateCache drawstate; - if (surface == NULL) { + if (!surface) { return -1; } @@ -712,7 +712,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -739,7 +739,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -766,7 +766,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -794,7 +794,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { dstrect->x += drawstate.viewport->x; dstrect->y += drawstate.viewport->y; } @@ -852,7 +852,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { copydata->dstrect.x += drawstate.viewport->x; copydata->dstrect.y += drawstate.viewport->y; } @@ -880,7 +880,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; vp.y = drawstate.viewport->y; @@ -903,7 +903,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo GeometryFillData *ptr = (GeometryFillData *) verts; /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; vp.y = drawstate.viewport->y; @@ -938,7 +938,7 @@ static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 src_format; void *src_pixels; - if (surface == NULL) { + if (!surface) { return -1; } @@ -965,7 +965,7 @@ static int SW_RenderPresent(SDL_Renderer *renderer) { SDL_Window *window = renderer->window; - if (window == NULL) { + if (!window) { return -1; } return SDL_UpdateWindowSurface(window); @@ -995,19 +995,19 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface) SDL_Renderer *renderer; SW_RenderData *data; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (SW_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SW_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; @@ -1050,7 +1050,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags) /* Set the vsync hint based on our flags, if it's not already set */ hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); - if (hint == NULL || !*hint) { + if (!hint || !*hint) { no_hint_set = SDL_TRUE; } else { no_hint_set = SDL_FALSE; @@ -1067,7 +1067,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_SetHint(SDL_HINT_RENDER_VSYNC, ""); } - if (surface == NULL) { + if (!surface) { return NULL; } return SW_CreateRendererForSurface(surface); diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index d51df2f1f..f1c12f7c4 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -500,7 +500,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in double sangleinv, cangleinv; /* Sanity check */ - if (src == NULL) { + if (!src) { return NULL; } @@ -524,7 +524,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in if (is8bit) { /* Target surface is 8 bit */ rz_dst = SDL_CreateRGBSurfaceWithFormat(0, rect_dest->w, rect_dest->h + GUARD_ROWS, 8, src->format->format); - if (rz_dst != NULL) { + if (rz_dst) { if (src->format->palette) { for (i = 0; i < src->format->palette->ncolors; i++) { rz_dst->format->palette->colors[i] = src->format->palette->colors[i]; @@ -540,7 +540,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in } /* Check target */ - if (rz_dst == NULL) { + if (!rz_dst) { return NULL; } diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c index 04dcf4ed9..c1b44abfc 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -220,7 +220,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin SDL_Surface *tmp = NULL; - if (dst == NULL) { + if (!dst) { return -1; } @@ -272,7 +272,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin /* Use an intermediate surface */ tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect.w, dstrect.h, 0, format); - if (tmp == NULL) { + if (!tmp) { ret = -1; goto end; } @@ -460,7 +460,7 @@ int SDL_SW_BlitTriangle( int has_modulation; - if (src == NULL || dst == NULL) { + if (!src || !dst) { return -1; } diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c index 434a7e425..256d0ef1b 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/src/render/vitagxm/SDL_render_vita_gxm.c @@ -169,7 +169,7 @@ void StartDrawing(SDL_Renderer *renderer) // data->colorFragmentProgram = in->color; // data->textureFragmentProgram = in->texture; - if (renderer->target == NULL) { + if (!renderer->target) { sceGxmBeginScene( data->gxm_context, 0, @@ -217,13 +217,13 @@ SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) VITA_GXM_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (VITA_GXM_RenderData *)SDL_calloc(1, sizeof(VITA_GXM_RenderData)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; @@ -295,7 +295,7 @@ static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)SDL_calloc(1, sizeof(VITA_GXM_TextureData)); - if (vita_texture == NULL) { + if (!vita_texture) { return SDL_OutOfMemory(); } @@ -583,7 +583,7 @@ static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, *pitch = vita_texture->pitch; // make sure that rendering is finished on render target textures - if (vita_texture->tex->gxm_rendertarget != NULL) { + if (vita_texture->tex->gxm_rendertarget) { sceGxmFinish(data->gxm_context); } @@ -733,7 +733,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd data, count * sizeof(texture_vertex)); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -772,7 +772,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd data, count * sizeof(color_vertex)); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -1006,7 +1006,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1103,7 +1103,7 @@ static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rec } temp_pixels = SDL_malloc(buflen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -1186,15 +1186,15 @@ static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; - if (data == NULL) { + if (!data) { return; } - if (vita_texture == NULL) { + if (!vita_texture) { return; } - if (vita_texture->tex == NULL) { + if (!vita_texture->tex) { return; } diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/src/render/vitagxm/SDL_render_vita_gxm_memory.c index a5a4aacfe..82b771dcd 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_memory.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.c @@ -66,7 +66,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) { void *mem; - if (data->texturePool == NULL) { + if (!data->texturePool) { int poolsize; int ret; SceKernelFreeMemorySizeInfo info; @@ -88,7 +88,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) } data->texturePool = sceClibMspaceCreate(mem, poolsize); - if (data->texturePool == NULL) { + if (!data->texturePool) { return NULL; } ret = sceGxmMapMemory(mem, poolsize, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE); @@ -101,7 +101,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr) { - if (data->texturePool != NULL) { + if (data->texturePool) { sceClibMspaceFree(data->texturePool, ptr); } } @@ -109,7 +109,7 @@ void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr) void vita_gpu_mem_destroy(VITA_GXM_RenderData *data) { void *mem = NULL; - if (data->texturePool != NULL) { + if (data->texturePool) { sceClibMspaceDestroy(data->texturePool); data->texturePool = NULL; if (sceKernelGetMemBlockBase(data->texturePoolUID, &mem) < 0) { diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c index 772a703f3..bb8f6f48f 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -1003,7 +1003,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig tex_size += (((aligned_w + 1) / 2) * ((h + 1) / 2)) * 2; } - if (texture == NULL) { + if (!texture) { return NULL; } @@ -1017,7 +1017,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig tex_size); /* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */ - if (texture_data == NULL) { + if (!texture_data) { SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n"); texture_data = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, @@ -1030,7 +1030,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig texture->cdram = 1; } - if (texture_data == NULL) { + if (!texture_data) { SDL_free(texture); return NULL; } diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index 6e978ac9e..15fb7d0d6 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -237,7 +237,7 @@ SDL_Sensor *SDL_SensorOpen(int device_index) /* Create and initialize the sensor */ sensor = (SDL_Sensor *)SDL_calloc(sizeof(*sensor), 1); - if (sensor == NULL) { + if (!sensor) { SDL_OutOfMemory(); SDL_UnlockSensors(); return NULL; @@ -297,7 +297,7 @@ static int SDL_PrivateSensorValid(SDL_Sensor *sensor) { int valid; - if (sensor == NULL) { + if (!sensor) { SDL_SetError("Sensor hasn't been opened yet"); valid = 0; } else { diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index 1b1979184..41e117382 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -54,14 +54,14 @@ static int SDL_ANDROID_SensorInit(void) ASensorList sensors; SDL_sensor_manager = ASensorManager_getInstance(); - if (SDL_sensor_manager == NULL) { + if (!SDL_sensor_manager) { return SDL_SetError("Couldn't create sensor manager"); } SDL_sensor_looper = ALooper_forThread(); - if (SDL_sensor_looper == NULL) { + if (!SDL_sensor_looper) { SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); - if (SDL_sensor_looper == NULL) { + if (!SDL_sensor_looper) { return SDL_SetError("Couldn't create sensor event loop"); } } @@ -70,7 +70,7 @@ static int SDL_ANDROID_SensorInit(void) sensors_count = ASensorManager_getSensorList(SDL_sensor_manager, &sensors); if (sensors_count > 0) { SDL_sensors = (SDL_AndroidSensor *)SDL_calloc(sensors_count, sizeof(*SDL_sensors)); - if (SDL_sensors == NULL) { + if (!SDL_sensors) { return SDL_OutOfMemory(); } @@ -125,7 +125,7 @@ static int SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) int delay_us, min_delay_us; hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } diff --git a/src/sensor/vita/SDL_vitasensor.c b/src/sensor/vita/SDL_vitasensor.c index 6513f9e08..c6e96759d 100644 --- a/src/sensor/vita/SDL_vitasensor.c +++ b/src/sensor/vita/SDL_vitasensor.c @@ -54,7 +54,7 @@ static int SDL_VITA_SensorInit(void) SDL_sensors_count = 2; SDL_sensors = (SDL_VitaSensor *)SDL_calloc(SDL_sensors_count, sizeof(*SDL_sensors)); - if (SDL_sensors == NULL) { + if (!SDL_sensors) { return SDL_OutOfMemory(); } @@ -121,7 +121,7 @@ static int SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index) struct sensor_hwdata *hwdata; hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } sensor->hwdata = hwdata; diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c index 29195a03a..238087885 100644 --- a/src/sensor/windows/SDL_windowssensor.c +++ b/src/sensor/windows/SDL_windowssensor.c @@ -67,7 +67,7 @@ static int DisconnectSensor(ISensor *sensor); static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_QueryInterface(ISensorManagerEvents *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -107,7 +107,7 @@ static ISensorManagerEvents sensor_manager_events = { static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_QueryInterface(ISensorEvents *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -286,13 +286,13 @@ static int ConnectSensor(ISensor *sensor) if (bstr_name != NULL) { SysFreeString(bstr_name); } - if (name == NULL) { + if (!name) { return SDL_OutOfMemory(); } SDL_LockSensors(); new_sensors = (SDL_Windows_Sensor *)SDL_realloc(SDL_sensors, (SDL_num_sensors + 1) * sizeof(SDL_Windows_Sensor)); - if (new_sensors == NULL) { + if (!new_sensors) { SDL_UnlockSensors(); SDL_free(name); return SDL_OutOfMemory(); diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 466867ac8..0825c1ff4 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -47,7 +47,7 @@ static size_t SDL_envmemlen = 0; int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -57,7 +57,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -79,7 +79,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) char *new_variable; /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -94,7 +94,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) /* This leaks. Sorry. Get a better OS so we don't have to do this. */ len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *)SDL_malloc(len); - if (new_variable == NULL) { + if (!new_variable) { return -1; } @@ -111,7 +111,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) char *new_variable; /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -123,7 +123,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) /* Allocate memory for the variable */ len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *)SDL_malloc(len); - if (new_variable == NULL) { + if (!new_variable) { return -1; } @@ -176,7 +176,7 @@ char *SDL_getenv(const char *name) #endif /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } @@ -188,7 +188,7 @@ char *SDL_getenv(const char *name) size_t bufferlen; /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } @@ -199,7 +199,7 @@ char *SDL_getenv(const char *name) } if (bufferlen > SDL_envmemlen) { char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); - if (newmem == NULL) { + if (!newmem) { return NULL; } SDL_envmem = newmem; @@ -215,14 +215,14 @@ char *SDL_getenv(const char *name) char *value; /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } value = (char *)0; if (SDL_env) { len = SDL_strlen(name); - for (i = 0; SDL_env[i] && value == NULL; ++i) { + for (i = 0; SDL_env[i] && !value; ++i) { if ((SDL_strncmp(SDL_env[i], name, len) == 0) && (SDL_env[i][len] == '=')) { value = &SDL_env[i][len + 1]; diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index 30a611e59..91e496cf9 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -166,28 +166,28 @@ static const char *getlocale(char *buffer, size_t bufsize) char *ptr; lang = SDL_getenv("LC_ALL"); - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LC_CTYPE"); } - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LC_MESSAGES"); } - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LANG"); } - if (lang == NULL || !*lang || SDL_strcmp(lang, "C") == 0) { + if (!lang || !*lang || SDL_strcmp(lang, "C") == 0) { lang = "ASCII"; } /* We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8" */ ptr = SDL_strchr(lang, '.'); - if (ptr != NULL) { + if (ptr) { lang = ptr + 1; } SDL_strlcpy(buffer, lang, bufsize); ptr = SDL_strchr(buffer, '@'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; /* chop end of string. */ } @@ -202,10 +202,10 @@ SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode) char fromcode_buffer[64]; char tocode_buffer[64]; - if (fromcode == NULL || !*fromcode) { + if (!fromcode || !*fromcode) { fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer)); } - if (tocode == NULL || !*tocode) { + if (!tocode || !*tocode) { tocode = getlocale(tocode_buffer, sizeof(tocode_buffer)); } for (i = 0; i < SDL_arraysize(encodings); ++i) { @@ -245,11 +245,11 @@ SDL_iconv(SDL_iconv_t cd, Uint32 ch = 0; size_t total; - if (inbuf == NULL || !*inbuf) { + if (!inbuf || !*inbuf) { /* Reset the context */ return 0; } - if (outbuf == NULL || !*outbuf || outbytesleft == NULL || !*outbytesleft) { + if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) { return SDL_ICONV_E2BIG; } src = *inbuf; @@ -795,10 +795,10 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb size_t outbytesleft; size_t retCode = 0; - if (tocode == NULL || !*tocode) { + if (!tocode || !*tocode) { tocode = "UTF-8"; } - if (fromcode == NULL || !*fromcode) { + if (!fromcode || !*fromcode) { fromcode = "UTF-8"; } cd = SDL_iconv_open(tocode, fromcode); @@ -808,7 +808,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb stringsize = inbytesleft; string = (char *)SDL_malloc(stringsize + sizeof(Uint32)); - if (string == NULL) { + if (!string) { SDL_iconv_close(cd); return NULL; } @@ -825,7 +825,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb char *oldstring = string; stringsize *= 2; string = (char *)SDL_realloc(string, stringsize + sizeof(Uint32)); - if (string == NULL) { + if (!string) { SDL_free(oldstring); SDL_iconv_close(cd); return NULL; diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 8edd9334a..e90ce7634 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -1152,7 +1152,7 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) { int retval = 0; - if (text == NULL || !*text) { + if (!text || !*text) { return -1; } @@ -1544,7 +1544,7 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, c size_t length = 0; size_t slen, sz; - if (string == NULL) { + if (!string) { string = "(null)"; } @@ -1604,7 +1604,7 @@ static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *inf { /* left-pad num with zeroes. */ size_t sz, pad, have_sign; - if (info == NULL) { + if (!info) { return; } @@ -1992,7 +1992,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) *strp = NULL; p = (char *)SDL_malloc(size); - if (p == NULL) { + if (!p) { return -1; } @@ -2018,7 +2018,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) size = retval + 1; /* Precisely what is needed */ np = (char *)SDL_realloc(p, size); - if (np == NULL) { + if (!np) { SDL_free(p); return -1; } else { diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index c046f7c3b..a7187195a 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 b84088026..d55d37a5a 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 453124b07..4ad097fcc 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 d3bdad6dd..57998fb20 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 9e2e757e4..a26ca647c 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 614151302..8f05c6ddd 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 8e8cd490c..2b7b50587 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 bb773a6bc..8f737ec12 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; @@ -171,7 +171,7 @@ static void *SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size) { void *mem; - SDL_assert(ptr == NULL || SDL_IsAllocationTracked(ptr)); + SDL_assert(!ptr || 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 == NULL) { + if (!ptr) { return; } diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c index ab3fec54c..d74dc652a 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/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index aa8e2b188..791035abb 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -39,7 +39,7 @@ void *SDL_TLSGet(SDL_TLSID id) SDL_TLSData *storage; storage = SDL_SYS_GetTLSData(); - if (storage == NULL || id == 0 || id > storage->limit) { + if (!storage || id == 0 || id > storage->limit) { return NULL; } return storage->array[id - 1].data; @@ -54,13 +54,13 @@ int SDL_TLSSet(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void * } storage = SDL_SYS_GetTLSData(); - if (storage == NULL || (id > storage->limit)) { + if (!storage || (id > storage->limit)) { unsigned int i, oldlimit, newlimit; oldlimit = storage ? storage->limit : 0; newlimit = (id + TLS_ALLOC_CHUNKSIZE); storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage) + (newlimit - 1) * sizeof(storage->array[0])); - if (storage == NULL) { + if (!storage) { return SDL_OutOfMemory(); } storage->limit = newlimit; @@ -120,14 +120,14 @@ SDL_TLSData *SDL_Generic_GetTLSData(void) SDL_TLSData *storage = NULL; #if !SDL_THREADS_DISABLED - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { static SDL_SpinLock tls_lock; SDL_AtomicLock(&tls_lock); - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { SDL_mutex *mutex = SDL_CreateMutex(); SDL_MemoryBarrierRelease(); SDL_generic_TLS_mutex = mutex; - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { SDL_AtomicUnlock(&tls_lock); return NULL; } @@ -161,10 +161,10 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) prev = NULL; for (entry = SDL_generic_TLS; entry; entry = entry->next) { if (entry->thread == thread) { - if (data != NULL) { + if (data) { entry->storage = data; } else { - if (prev != NULL) { + if (prev) { prev->next = entry->next; } else { SDL_generic_TLS = entry->next; @@ -175,7 +175,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) } prev = entry; } - if (entry == NULL) { + if (!entry) { entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry)); if (entry) { entry->thread = thread; @@ -186,7 +186,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) } SDL_UnlockMutex(SDL_generic_TLS_mutex); - if (entry == NULL) { + if (!entry) { return SDL_OutOfMemory(); } return 0; @@ -251,7 +251,7 @@ SDL_error *SDL_GetErrBuf(void) if (errbuf == ALLOCATION_IN_PROGRESS) { return SDL_GetStaticErrBuf(); } - if (errbuf == NULL) { + if (!errbuf) { /* Get the original memory functions for this allocation because the lifetime * of the error buffer may span calls to SDL_SetMemoryFunctions() by the app */ @@ -262,7 +262,7 @@ SDL_error *SDL_GetErrBuf(void) /* Mark that we're in the middle of allocating our buffer */ SDL_TLSSet(tls_errbuf, ALLOCATION_IN_PROGRESS, NULL); errbuf = (SDL_error *)realloc_func(NULL, sizeof(*errbuf)); - if (errbuf == NULL) { + if (!errbuf) { SDL_TLSSet(tls_errbuf, NULL, NULL); return SDL_GetStaticErrBuf(); } @@ -330,7 +330,7 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), /* Allocate memory for the thread info structure */ thread = (SDL_Thread *)SDL_calloc(1, sizeof(*thread)); - if (thread == NULL) { + if (!thread) { SDL_OutOfMemory(); return NULL; } @@ -338,9 +338,9 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), SDL_AtomicSet(&thread->state, SDL_THREAD_STATE_ALIVE); /* Set up the arguments for the thread */ - if (name != NULL) { + if (name) { thread->name = SDL_strdup(name); - if (thread->name == NULL) { + if (!thread->name) { SDL_OutOfMemory(); SDL_free(thread); return NULL; @@ -383,7 +383,7 @@ DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int(SDLCALL *fn)(void *), size_t stacksize = 0; /* If the SDL_HINT_THREAD_STACK_SIZE exists, use it */ - if (stackhint != NULL) { + if (stackhint) { char *endp = NULL; const Sint64 hintval = SDL_strtoll(stackhint, &endp, 10); if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */ @@ -452,7 +452,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status) void SDL_DetachThread(SDL_Thread *thread) { - if (thread == NULL) { + if (!thread) { return; } diff --git a/src/thread/generic/SDL_syscond.c b/src/thread/generic/SDL_syscond.c index a19292970..d601435a7 100644 --- a/src/thread/generic/SDL_syscond.c +++ b/src/thread/generic/SDL_syscond.c @@ -95,7 +95,7 @@ void SDL_DestroyCond_generic(SDL_cond *_cond) int SDL_CondSignal_generic(SDL_cond *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -119,7 +119,7 @@ int SDL_CondSignal_generic(SDL_cond *_cond) int SDL_CondBroadcast_generic(SDL_cond *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -175,7 +175,7 @@ int SDL_CondWaitTimeout_generic(SDL_cond *_cond, SDL_mutex *mutex, Uint32 ms) SDL_cond_generic *cond = (SDL_cond_generic *)_cond; int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index daafbb607..0e77b3a27 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -107,7 +107,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) int retval = 0; SDL_threadID this_thread; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index fc9794ed4..3e25a935c 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -78,7 +78,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -120,7 +120,7 @@ int SDL_SemTryWait(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -139,7 +139,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -184,7 +184,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) int SDL_SemPost(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/n3ds/SDL_syscond.c b/src/thread/n3ds/SDL_syscond.c index 05e0462af..7ec9db849 100644 --- a/src/thread/n3ds/SDL_syscond.c +++ b/src/thread/n3ds/SDL_syscond.c @@ -54,7 +54,7 @@ void SDL_DestroyCond(SDL_cond *cond) /* Restart one of the threads that are waiting on the condition variable */ int SDL_CondSignal(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -65,7 +65,7 @@ int SDL_CondSignal(SDL_cond *cond) /* Restart all threads that are waiting on the condition variable */ int SDL_CondBroadcast(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -98,10 +98,10 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { Result res; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } - if (mutex == NULL) { + if (!mutex) { return SDL_InvalidParamError("mutex"); } diff --git a/src/thread/n3ds/SDL_sysmutex.c b/src/thread/n3ds/SDL_sysmutex.c index 09e0e0ae3..2be6a18b3 100644 --- a/src/thread/n3ds/SDL_sysmutex.c +++ b/src/thread/n3ds/SDL_sysmutex.c @@ -64,7 +64,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn /* try Lock the mutex */ int SDL_TryLockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c index e7615e4d9..214aa7bf9 100644 --- a/src/thread/n3ds/SDL_syssem.c +++ b/src/thread/n3ds/SDL_syssem.c @@ -46,7 +46,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) } sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -66,7 +66,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) int SDL_SemTryWait(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -81,7 +81,7 @@ int SDL_SemTryWait(SDL_sem *sem) int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -122,7 +122,7 @@ int SDL_SemWait(SDL_sem *sem) Uint32 SDL_SemValue(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -131,7 +131,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) int SDL_SemPost(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } LightSemaphore_Release(&sem->semaphore, 1); diff --git a/src/thread/n3ds/SDL_systhread.c b/src/thread/n3ds/SDL_systhread.c index 091ab1a4f..6027e665d 100644 --- a/src/thread/n3ds/SDL_systhread.c +++ b/src/thread/n3ds/SDL_systhread.c @@ -66,7 +66,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) cpu, false); - if (thread->handle == NULL) { + if (!thread->handle) { return SDL_SetError("Couldn't create thread"); } diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp index 20133c671..c09fac5a6 100644 --- a/src/thread/ngage/SDL_syssem.cpp +++ b/src/thread/ngage/SDL_syssem.cpp @@ -92,7 +92,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { RSemaphore sema; sema.SetHandle(sem->handle); sema.Signal(sema.Count()); @@ -104,7 +104,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -134,7 +134,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) int SDL_SemTryWait(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -151,7 +151,7 @@ int SDL_SemWait(SDL_sem *sem) Uint32 SDL_SemValue(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -160,7 +160,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) int SDL_SemPost(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } sem->count++; diff --git a/src/thread/os2/SDL_syssem.c b/src/thread/os2/SDL_syssem.c index 407867d67..7982ac15d 100644 --- a/src/thread/os2/SDL_syssem.c +++ b/src/thread/os2/SDL_syssem.c @@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) ULONG ulRC; SDL_sem *pSDLSem = SDL_malloc(sizeof(SDL_sem)); - if (pSDLSem == NULL) { + if (!pSDLSem) { SDL_OutOfMemory(); return NULL; } @@ -85,7 +85,7 @@ int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) ULONG ulTimeout; ULONG cPost; - if (sem == NULL) + if (!sem) return SDL_InvalidParamError("sem"); if (timeout != SEM_INDEFINITE_WAIT) @@ -140,7 +140,7 @@ Uint32 SDL_SemValue(SDL_sem * sem) { ULONG ulRC; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -159,7 +159,7 @@ int SDL_SemPost(SDL_sem * sem) { ULONG ulRC; - if (sem == NULL) + if (!sem) return SDL_InvalidParamError("sem"); ulRC = DosRequestMutexSem(sem->hMtx, SEM_INDEFINITE_WAIT); diff --git a/src/thread/os2/SDL_systhread.c b/src/thread/os2/SDL_systhread.c index b2555892c..977f1a69b 100644 --- a/src/thread/os2/SDL_systhread.c +++ b/src/thread/os2/SDL_systhread.c @@ -45,7 +45,7 @@ static void RunThread(void *data) SDL_Thread *thread = (SDL_Thread *) data; pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread) thread->endfunc; - if (ppSDLTLSData != NULL) + if (ppSDLTLSData) *ppSDLTLSData = NULL; SDL_RunThread(thread); diff --git a/src/thread/os2/SDL_systls.c b/src/thread/os2/SDL_systls.c index 563ab74b8..a6cefc148 100644 --- a/src/thread/os2/SDL_systls.c +++ b/src/thread/os2/SDL_systls.c @@ -41,7 +41,7 @@ void SDL_OS2TLSAlloc(void) { ULONG ulRC; - if (cTLSAlloc == 0 || ppSDLTLSData == NULL) { + if (cTLSAlloc == 0 || !ppSDLTLSData) { /* First call - allocate the thread local memory (1 DWORD) */ ulRC = DosAllocThreadLocalMemory(1, (PULONG *)&ppSDLTLSData); if (ulRC != NO_ERROR) { @@ -59,7 +59,7 @@ void SDL_OS2TLSFree(void) if (cTLSAlloc != 0) cTLSAlloc--; - if (cTLSAlloc == 0 && ppSDLTLSData != NULL) { + if (cTLSAlloc == 0 && ppSDLTLSData) { /* Last call - free the thread local memory */ ulRC = DosFreeThreadLocalMemory((PULONG)ppSDLTLSData); if (ulRC != NO_ERROR) { @@ -72,7 +72,7 @@ void SDL_OS2TLSFree(void) SDL_TLSData *SDL_SYS_GetTLSData(void) { - return (ppSDLTLSData == NULL)? NULL : *ppSDLTLSData; + return (!ppSDLTLSData)? NULL : *ppSDLTLSData; } int SDL_SYS_SetTLSData(SDL_TLSData *data) diff --git a/src/thread/ps2/SDL_syssem.c b/src/thread/ps2/SDL_syssem.c index bba13a5e1..c54fc992c 100644 --- a/src/thread/ps2/SDL_syssem.c +++ b/src/thread/ps2/SDL_syssem.c @@ -50,7 +50,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) ee_sema_t sema; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sema.init_count = initial_value; sema.max_count = 255; @@ -72,7 +72,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { DeleteSema(sem->semid); sem->semid = 0; @@ -88,7 +88,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) struct timer_alarm_t alarm; InitializeTimerAlarm(&alarm); - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -127,7 +127,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) { ee_sema_t info; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -143,7 +143,7 @@ int SDL_SemPost(SDL_sem *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/psp/SDL_syscond.c b/src/thread/psp/SDL_syscond.c index a16187c18..8d3741364 100644 --- a/src/thread/psp/SDL_syscond.c +++ b/src/thread/psp/SDL_syscond.c @@ -80,7 +80,7 @@ void SDL_DestroyCond(SDL_cond *cond) /* Restart one of the threads that are waiting on the condition variable */ int SDL_CondSignal(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -103,7 +103,7 @@ int SDL_CondSignal(SDL_cond *cond) /* Restart all threads that are waiting on the condition variable */ int SDL_CondBroadcast(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -158,7 +158,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/psp/SDL_sysmutex.c b/src/thread/psp/SDL_sysmutex.c index 3b3cf3786..771be39a2 100644 --- a/src/thread/psp/SDL_sysmutex.c +++ b/src/thread/psp/SDL_sysmutex.c @@ -101,7 +101,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/psp/SDL_syssem.c b/src/thread/psp/SDL_syssem.c index 131f6b73b..269553616 100644 --- a/src/thread/psp/SDL_syssem.c +++ b/src/thread/psp/SDL_syssem.c @@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { @@ -62,7 +62,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { sceKernelDeleteSema(sem->semid); sem->semid = 0; @@ -81,7 +81,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) Uint32 *pTimeout; int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -126,7 +126,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) { SceKernelSemaInfo info; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -142,7 +142,7 @@ int SDL_SemPost(SDL_sem *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c index 5b8aeb4ad..7e3384613 100644 --- a/src/thread/pthread/SDL_syscond.c +++ b/src/thread/pthread/SDL_syscond.c @@ -64,7 +64,7 @@ int SDL_CondSignal(SDL_cond *cond) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -80,7 +80,7 @@ int SDL_CondBroadcast(SDL_cond *cond) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -99,7 +99,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) #endif struct timespec abstime; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -141,7 +141,7 @@ tryagain: */ int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) { return SDL_SetError("pthread_cond_wait() failed"); diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c index 9b24e1605..6f701974e 100644 --- a/src/thread/pthread/SDL_sysmutex.c +++ b/src/thread/pthread/SDL_sysmutex.c @@ -117,7 +117,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) pthread_t this_thread; #endif - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index fee50bb86..7c53161fb 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -45,7 +45,7 @@ struct SDL_semaphore SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem = (SDL_sem *)SDL_malloc(sizeof(SDL_sem)); - if (sem != NULL) { + if (sem) { if (sem_init(&sem->sem, 0, initial_value) < 0) { SDL_SetError("sem_init() failed"); SDL_free(sem); @@ -59,7 +59,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { sem_destroy(&sem->sem); SDL_free(sem); } @@ -69,7 +69,7 @@ int SDL_SemTryWait(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } retval = SDL_MUTEX_TIMEDOUT; @@ -83,7 +83,7 @@ int SDL_SemWait(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -109,7 +109,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) Uint32 end; #endif - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -175,7 +175,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) { int ret = 0; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -191,7 +191,7 @@ int SDL_SemPost(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 531680705..97eae57c4 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -127,10 +127,10 @@ void SDL_SYS_SetupThread(const char *name) sigset_t mask; #endif /* !__NACL__ */ - if (name != NULL) { + if (name) { #if (defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) SDL_assert(checked_setname); - if (ppthread_setname_np != NULL) { + if (ppthread_setname_np) { #if defined(__MACOSX__) || defined(__IPHONEOS__) ppthread_setname_np(name); #elif defined(__LINUX__) diff --git a/src/thread/stdcpp/SDL_syscond.cpp b/src/thread/stdcpp/SDL_syscond.cpp index ebd03cf4f..b0804a0f7 100644 --- a/src/thread/stdcpp/SDL_syscond.cpp +++ b/src/thread/stdcpp/SDL_syscond.cpp @@ -57,7 +57,7 @@ SDL_CreateCond(void) extern "C" void SDL_DestroyCond(SDL_cond *cond) { - if (cond != NULL) { + if (cond) { delete cond; } } @@ -66,7 +66,7 @@ SDL_DestroyCond(SDL_cond *cond) extern "C" int SDL_CondSignal(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -78,7 +78,7 @@ SDL_CondSignal(SDL_cond *cond) extern "C" int SDL_CondBroadcast(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp index e74627b1a..d72646172 100644 --- a/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/src/thread/stdcpp/SDL_sysmutex.cpp @@ -51,7 +51,7 @@ SDL_CreateMutex(void) extern "C" void SDL_DestroyMutex(SDL_mutex *mutex) { - if (mutex != NULL) { + if (mutex) { delete mutex; } } @@ -77,7 +77,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) { int retval = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/vita/SDL_syscond.c b/src/thread/vita/SDL_syscond.c index 632756506..3d29e6522 100644 --- a/src/thread/vita/SDL_syscond.c +++ b/src/thread/vita/SDL_syscond.c @@ -45,7 +45,7 @@ SDL_cond *SDL_CreateCond(void) SDL_cond *cond; cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond)); - if (cond != NULL) { + if (cond) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); cond->wait_done = SDL_CreateSemaphore(0); @@ -63,7 +63,7 @@ SDL_cond *SDL_CreateCond(void) /* Destroy a condition variable */ void SDL_DestroyCond(SDL_cond *cond) { - if (cond != NULL) { + if (cond) { if (cond->wait_sem) { SDL_DestroySemaphore(cond->wait_sem); } @@ -80,7 +80,7 @@ void SDL_DestroyCond(SDL_cond *cond) /* Restart one of the threads that are waiting on the condition variable */ int SDL_CondSignal(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -103,7 +103,7 @@ int SDL_CondSignal(SDL_cond *cond) /* Restart all threads that are waiting on the condition variable */ int SDL_CondBroadcast(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -158,7 +158,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/vita/SDL_sysmutex.c b/src/thread/vita/SDL_sysmutex.c index 232ae0479..aaf14014e 100644 --- a/src/thread/vita/SDL_sysmutex.c +++ b/src/thread/vita/SDL_sysmutex.c @@ -41,7 +41,7 @@ SDL_mutex *SDL_CreateMutex(void) /* Allocate mutex memory */ mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); - if (mutex != NULL) { + if (mutex) { res = sceKernelCreateLwMutex( &mutex->lock, @@ -62,7 +62,7 @@ SDL_mutex *SDL_CreateMutex(void) /* Free the mutex */ void SDL_DestroyMutex(SDL_mutex *mutex) { - if (mutex != NULL) { + if (mutex) { sceKernelDeleteLwMutex(&mutex->lock); SDL_free(mutex); } @@ -76,7 +76,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -97,7 +97,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/vita/SDL_syssem.c b/src/thread/vita/SDL_syssem.c index 453afa924..4b568feb7 100644 --- a/src/thread/vita/SDL_syssem.c +++ b/src/thread/vita/SDL_syssem.c @@ -45,7 +45,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { @@ -63,7 +63,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { sceKernelDeleteSema(sem->semid); sem->semid = 0; @@ -82,7 +82,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) Uint32 *pTimeout; int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -128,7 +128,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) SceKernelSemaInfo info; info.size = sizeof(info); - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -144,7 +144,7 @@ int SDL_SemPost(SDL_sem *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index 905d416b8..c96850a75 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -89,7 +89,7 @@ static SDL_cond *SDL_CreateCond_cv(void) /* Relies on CONDITION_VARIABLE_INIT == 0. */ cond = (SDL_cond_cv *)SDL_calloc(1, sizeof(*cond)); - if (cond == NULL) { + if (!cond) { SDL_OutOfMemory(); } @@ -98,7 +98,7 @@ static SDL_cond *SDL_CreateCond_cv(void) static void SDL_DestroyCond_cv(SDL_cond *cond) { - if (cond != NULL) { + if (cond) { /* There are no kernel allocated resources */ SDL_free(cond); } @@ -107,7 +107,7 @@ static void SDL_DestroyCond_cv(SDL_cond *cond) static int SDL_CondSignal_cv(SDL_cond *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -119,7 +119,7 @@ static int SDL_CondSignal_cv(SDL_cond *_cond) static int SDL_CondBroadcast_cv(SDL_cond *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -134,10 +134,10 @@ static int SDL_CondWaitTimeout_cv(SDL_cond *_cond, SDL_mutex *_mutex, Uint32 ms) DWORD timeout; int ret; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } - if (_mutex == NULL) { + if (!_mutex) { return SDL_InvalidParamError("mutex"); } @@ -220,14 +220,14 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = { SDL_cond *SDL_CreateCond(void) { - if (SDL_cond_impl_active.Create == NULL) { + if (!SDL_cond_impl_active.Create) { /* Default to generic implementation, works with all mutex implementations */ const SDL_cond_impl_t *impl = &SDL_cond_impl_generic; if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) { /* The mutex implementation isn't decided yet, trigger it */ SDL_mutex *mutex = SDL_CreateMutex(); - if (mutex == NULL) { + if (!mutex) { return NULL; } SDL_DestroyMutex(mutex); diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index 6091819f8..9c377e63d 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -62,7 +62,7 @@ static SDL_mutex *SDL_CreateMutex_srw(void) /* Relies on SRWLOCK_INIT == 0. */ mutex = (SDL_mutex_srw *)SDL_calloc(1, sizeof(*mutex)); - if (mutex == NULL) { + if (!mutex) { SDL_OutOfMemory(); } @@ -153,7 +153,7 @@ static SDL_mutex *SDL_CreateMutex_cs(void) /* Allocate mutex memory */ mutex = (SDL_mutex_cs *)SDL_malloc(sizeof(*mutex)); - if (mutex != NULL) { + if (mutex) { /* Initialize */ /* On SMP systems, a non-zero spin count generally helps performance */ #if __WINRT__ @@ -221,7 +221,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = { SDL_mutex *SDL_CreateMutex(void) { - if (SDL_mutex_impl_active.Create == NULL) { + if (!SDL_mutex_impl_active.Create) { /* Default to fallback implementation */ const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs; @@ -260,7 +260,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) int SDL_LockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -269,7 +269,7 @@ int SDL_LockMutex(SDL_mutex *mutex) int SDL_TryLockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -278,7 +278,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) int SDL_UnlockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index 6853549b6..6397f0280 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -97,7 +97,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value) SDL_sem_atom *sem; sem = (SDL_sem_atom *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { sem->count = initial_value; } else { SDL_OutOfMemory(); @@ -107,7 +107,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value) static void SDL_DestroySemaphore_atom(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { SDL_free(sem); } } @@ -117,7 +117,7 @@ static int SDL_SemTryWait_atom(SDL_sem *_sem) SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -138,7 +138,7 @@ static int SDL_SemWait_atom(SDL_sem *_sem) SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -169,7 +169,7 @@ static int SDL_SemWaitTimeout_atom(SDL_sem *_sem, Uint32 timeout) return SDL_SemWait_atom(_sem); } - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -211,7 +211,7 @@ static Uint32 SDL_SemValue_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -223,7 +223,7 @@ static int SDL_SemPost_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -261,7 +261,7 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value) /* Allocate sem memory */ sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* Create the semaphore, with max value 32K */ #if __WINRT__ sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS); @@ -284,7 +284,7 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value) static void SDL_DestroySemaphore_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem != NULL) { + if (sem) { if (sem->id) { CloseHandle(sem->id); sem->id = 0; @@ -299,7 +299,7 @@ static int SDL_SemWaitTimeout_kern(SDL_sem *_sem, Uint32 timeout) int retval; DWORD dwMilliseconds; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -337,7 +337,7 @@ static int SDL_SemWait_kern(SDL_sem *sem) static Uint32 SDL_SemValue_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -347,7 +347,7 @@ static Uint32 SDL_SemValue_kern(SDL_sem *_sem) static int SDL_SemPost_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } /* Increase the counter in the first place, because @@ -379,7 +379,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = { SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { - if (SDL_sem_impl_active.Create == NULL) { + if (!SDL_sem_impl_active.Create) { /* Default to fallback implementation */ const SDL_sem_impl_t *impl = &SDL_sem_impl_kern; diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index b55eb1326..a2b0c92c9 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -49,7 +49,7 @@ static DWORD RunThread(void *data) SDL_Thread *thread = (SDL_Thread *)data; pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)thread->endfunc; SDL_RunThread(thread); - if (pfnEndThread != NULL) { + if (pfnEndThread) { pfnEndThread(0); } return 0; @@ -98,7 +98,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) RunThreadViaCreateThread, thread, flags, &threadid); } - if (thread->handle == NULL) { + if (!thread->handle) { return SDL_SetError("Not enough resources to create thread"); } return 0; @@ -118,7 +118,7 @@ typedef HRESULT(WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR); void SDL_SYS_SetupThread(const char *name) { - if (name != NULL) { + if (name) { #ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ static pfnSetThreadDescription pSetThreadDescription = NULL; static HMODULE kernel32 = NULL; @@ -130,7 +130,7 @@ void SDL_SYS_SetupThread(const char *name) } } - if (pSetThreadDescription != NULL) { + if (pSetThreadDescription) { WCHAR *strw = WIN_UTF8ToStringW(name); if (strw) { pSetThreadDescription(GetCurrentThread(), strw); diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 874f15462..5b6fd808d 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -173,7 +173,7 @@ static int SDLCALL SDL_TimerThread(void *_data) current->scheduled = tick + interval; SDL_AddTimerInternal(data, current); } else { - if (freelist_head == NULL) { + if (!freelist_head) { freelist_head = current; } if (freelist_tail) { @@ -298,7 +298,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_RemoveTimer(timer->timerID); } else { timer = (SDL_Timer *)SDL_malloc(sizeof(*timer)); - if (timer == NULL) { + if (!timer) { SDL_OutOfMemory(); return 0; } @@ -311,7 +311,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_AtomicSet(&timer->canceled, 0); entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_free(timer); SDL_OutOfMemory(); return 0; @@ -424,7 +424,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_TimerMap *entry; entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 9f861ebac..cfc207c05 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1024,7 +1024,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) SDL_PixelFormat *, SDL_PixelFormat *); dest = surface->map->dst; - if (dest == NULL) { + if (!dest) { return -1; } df = dest->format; @@ -1081,7 +1081,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) maxsize += sizeof(RLEDestFormat); rlebuf = (Uint8 *)SDL_malloc(maxsize); - if (rlebuf == NULL) { + if (!rlebuf) { return SDL_OutOfMemory(); } { @@ -1227,7 +1227,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) /* reallocate the buffer to release unused memory */ { Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); - if (p == NULL) { + if (!p) { p = rlebuf; } surface->map->data = p; @@ -1300,7 +1300,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) } rlebuf = (Uint8 *)SDL_malloc(maxsize); - if (rlebuf == NULL) { + if (!rlebuf) { return SDL_OutOfMemory(); } @@ -1395,7 +1395,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) { /* If SDL_realloc returns NULL, the original block is left intact */ Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); - if (p == NULL) { + if (!p) { p = rlebuf; } surface->map->data = p; @@ -1492,7 +1492,7 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) } surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch); - if (surface->pixels == NULL) { + if (!surface->pixels) { return SDL_FALSE; } surface->flags |= SDL_SIMD_ALIGNED; @@ -1558,7 +1558,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) /* re-create the original surface */ surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch); - if (surface->pixels == NULL) { + if (!surface->pixels) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; return; diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 88b7f7330..490c6fb78 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -251,7 +251,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) } #endif #if SDL_HAVE_BLIT_AUTO - if (blit == NULL) { + if (!blit) { Uint32 src_format = surface->format->format; Uint32 dst_format = dst->format->format; @@ -262,7 +262,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) #endif #ifndef TEST_SLOW_BLIT - if (blit == NULL) + if (!blit) #endif { Uint32 src_format = surface->format->format; @@ -278,7 +278,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) map->data = blit; /* Make sure we have a blit function */ - if (blit == NULL) { + if (!blit) { SDL_InvalidateMap(map); return SDL_SetError("Blit combination not supported"); } diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 316f3f369..f468b99a3 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -1427,7 +1427,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) /* Per-pixel alpha blits */ switch (df->BytesPerPixel) { case 1: - if (df->palette != NULL) { + if (df->palette) { return BlitNto1PixelAlpha; } else { /* RGB332 has no palette ! */ @@ -1505,7 +1505,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) /* Per-surface alpha blits */ switch (df->BytesPerPixel) { case 1: - if (df->palette != NULL) { + if (df->palette) { return BlitNto1SurfaceAlpha; } else { /* RGB332 has no palette ! */ @@ -1560,7 +1560,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) if (sf->Amask == 0) { if (df->BytesPerPixel == 1) { - if (df->palette != NULL) { + if (df->palette) { return BlitNto1SurfaceAlphaKey; } else { /* RGB332 has no palette ! */ diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index 7c0b0106d..ca933c344 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -977,7 +977,7 @@ static void Blit_RGB888_index8(SDL_BlitInfo *info) dstskip = info->dst_skip; map = info->table; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -1091,7 +1091,7 @@ static void Blit_RGB101010_index8(SDL_BlitInfo *info) dstskip = info->dst_skip; map = info->table; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -2115,7 +2115,7 @@ static void BlitNto1(SDL_BlitInfo *info) srcfmt = info->src_fmt; srcbpp = srcfmt->BytesPerPixel; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -2513,7 +2513,7 @@ static void BlitNto1Key(SDL_BlitInfo *info) srcbpp = srcfmt->BytesPerPixel; ckey &= rgbmask; - if (palmap == NULL) { + if (!palmap) { while (height--) { /* *INDENT-OFF* */ /* clang-format off */ DUFFS_LOOP( diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 82147a583..24a3c2897 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -238,7 +238,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) /* Make sure we are passed a valid data source */ surface = NULL; was_error = SDL_FALSE; - if (src == NULL) { + if (!src) { SDL_InvalidParamError("src"); was_error = SDL_TRUE; goto done; @@ -424,7 +424,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) surface = SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask, Bmask, Amask); - if (surface == NULL) { + if (!surface) { was_error = SDL_TRUE; goto done; } @@ -667,7 +667,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) } #endif /* SAVE_32BIT_BMP */ - if (surface->format->palette != NULL && !save32bit) { + if (surface->format->palette && !save32bit) { if (surface->format->BitsPerPixel == 8) { intermediate_surface = surface; } else { @@ -697,7 +697,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24); } intermediate_surface = SDL_ConvertSurface(surface, &format, 0); - if (intermediate_surface == NULL) { + if (!intermediate_surface) { SDL_SetError("Couldn't convert image to %d bpp", format.BitsPerPixel); } diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index e18668cea..f1d8e90da 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -27,11 +27,11 @@ int SDL_SetClipboardText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { return SDL_SetError("Video subsystem must be initialized to set clipboard text"); } - if (text == NULL) { + if (!text) { text = ""; } if (_this->SetClipboardText) { @@ -47,11 +47,11 @@ int SDL_SetPrimarySelectionText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { return SDL_SetError("Video subsystem must be initialized to set primary selection text"); } - if (text == NULL) { + if (!text) { text = ""; } if (_this->SetPrimarySelectionText) { @@ -67,7 +67,7 @@ char *SDL_GetClipboardText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to get clipboard text"); return SDL_strdup(""); } @@ -76,7 +76,7 @@ char *SDL_GetClipboardText(void) return _this->GetClipboardText(_this); } else { const char *text = _this->clipboard_text; - if (text == NULL) { + if (!text) { text = ""; } return SDL_strdup(text); @@ -87,7 +87,7 @@ char *SDL_GetPrimarySelectionText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to get primary selection text"); return SDL_strdup(""); } @@ -96,7 +96,7 @@ char *SDL_GetPrimarySelectionText(void) return _this->GetPrimarySelectionText(_this); } else { const char *text = _this->primary_selection_text; - if (text == NULL) { + if (!text) { text = ""; } return SDL_strdup(text); @@ -107,7 +107,7 @@ SDL_bool SDL_HasClipboardText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to check clipboard text"); return SDL_FALSE; } @@ -127,7 +127,7 @@ SDL_bool SDL_HasPrimarySelectionText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to check primary selection text"); return SDL_FALSE; } diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 8e5f165b5..15bf8de85 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -178,7 +178,7 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext const char *ext_start; /* Invalid extensions can be rejected early */ - if (ext == NULL || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { + if (!ext || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); */ return SDL_FALSE; } @@ -191,7 +191,7 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext * 1 If set, the client extension is masked and not present to SDL. */ ext_override = SDL_getenv(ext); - if (ext_override != NULL) { + if (ext_override) { int disable_ext = SDL_atoi(ext_override); if (disable_ext & 0x01 && type == SDL_EGL_DISPLAY_EXTENSION) { return SDL_FALSE; @@ -217,12 +217,12 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext return SDL_FALSE; } - if (egl_extstr != NULL) { + if (egl_extstr) { ext_start = egl_extstr; while (*ext_start) { ext_start = SDL_strstr(ext_start, ext); - if (ext_start == NULL) { + if (!ext_start) { return SDL_FALSE; } /* Check if the match is not just a substring of one of the extensions */ @@ -245,24 +245,24 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext void *SDL_EGL_GetProcAddress(_THIS, const char *proc) { void *retval = NULL; - if (_this->egl_data != NULL) { + if (_this->egl_data) { const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor); const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5); /* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */ - if (retval == NULL && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } #if !defined(__EMSCRIPTEN__) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */ /* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */ - if (retval == NULL) { + if (!retval) { retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc); } #endif /* Try eglGetProcAddress if we're on <= 1.4 and still searching... */ - if (retval == NULL && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } } @@ -336,17 +336,17 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) #if !defined(SDL_VIDEO_STATIC_ANGLE) && !defined(SDL_VIDEO_DRIVER_VITA) /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); - if (path != NULL) { + if (path) { opengl_dll_handle = SDL_LoadObject(path); } - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { if (_this->gl_config.major_version > 1) { path = DEFAULT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); #ifdef ALT_OGL_ES2 - if (opengl_dll_handle == NULL && !vc4) { + if (!opengl_dll_handle && !vc4) { path = ALT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); } @@ -355,12 +355,12 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) } else { path = DEFAULT_OGL_ES; opengl_dll_handle = SDL_LoadObject(path); - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { path = DEFAULT_OGL_ES_PVR; opengl_dll_handle = SDL_LoadObject(path); } #ifdef ALT_OGL_ES2 - if (opengl_dll_handle == NULL && !vc4) { + if (!opengl_dll_handle && !vc4) { path = ALT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); } @@ -372,7 +372,7 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) path = DEFAULT_OGL; opengl_dll_handle = SDL_LoadObject(path); #ifdef ALT_OGL - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { path = ALT_OGL; opengl_dll_handle = SDL_LoadObject(path); } @@ -382,34 +382,34 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) } _this->egl_data->opengl_dll_handle = opengl_dll_handle; - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { return SDL_SetError("Could not initialize OpenGL / GLES library"); } /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */ - if (egl_path != NULL) { + if (egl_path) { egl_dll_handle = SDL_LoadObject(egl_path); } /* Try loading a EGL symbol, if it does not work try the default library paths */ - if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { - if (egl_dll_handle != NULL) { + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { SDL_UnloadObject(egl_dll_handle); } path = SDL_getenv("SDL_VIDEO_EGL_DRIVER"); - if (path == NULL) { + if (!path) { path = DEFAULT_EGL; } egl_dll_handle = SDL_LoadObject(path); #ifdef ALT_EGL - if (egl_dll_handle == NULL && !vc4) { + if (!egl_dll_handle && !vc4) { path = ALT_EGL; egl_dll_handle = SDL_LoadObject(path); } #endif - if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { - if (egl_dll_handle != NULL) { + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { SDL_UnloadObject(egl_dll_handle); } return SDL_SetError("Could not load EGL library"); @@ -535,7 +535,7 @@ int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_di } #endif /* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */ - if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay != NULL)) { + if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay)) { _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); } if (_this->egl_data->egl_display == EGL_NO_DISPLAY) { @@ -578,11 +578,11 @@ int SDL_EGL_InitializeOffscreen(_THIS, int device) } /* Check for all extensions that are optional until used and fail if any is missing */ - if (_this->egl_data->eglQueryDevicesEXT == NULL) { + if (!_this->egl_data->eglQueryDevicesEXT) { return SDL_SetError("eglQueryDevicesEXT is missing (EXT_device_enumeration not supported by the drivers?)"); } - if (_this->egl_data->eglGetPlatformDisplayEXT == NULL) { + if (!_this->egl_data->eglGetPlatformDisplayEXT) { return SDL_SetError("eglGetPlatformDisplayEXT is missing (EXT_platform_base not supported by the drivers?)"); } diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 5687fb951..9db592953 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -233,12 +233,12 @@ static void SDL_FillRect4(Uint8 *pixels, int pitch, Uint32 color, int w, int h) */ int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_FillRect(): dst"); } /* If 'rect' == NULL, then fill the whole surface */ - if (rect == NULL) { + if (!rect) { rect = &dst->clip_rect; /* Don't attempt to fill if the surface's clip_rect is empty */ if (SDL_RectEmpty(rect)) { @@ -306,7 +306,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL; int i; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_FillRects(): dst"); } @@ -320,7 +320,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return SDL_SetError("SDL_FillRects(): You must lock the surface"); } - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_FillRects(): rects"); } @@ -342,7 +342,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #if SDL_ARM_NEON_BLITTERS - if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && fill_function == NULL) { + if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && !fill_function) { switch (dst->format->BytesPerPixel) { case 1: fill_function = fill_8_neon; @@ -357,7 +357,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #endif #if SDL_ARM_SIMD_BLITTERS - if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && fill_function == NULL) { + if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && !fill_function) { switch (dst->format->BytesPerPixel) { case 1: fill_function = fill_8_simd; @@ -372,7 +372,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #endif - if (fill_function == NULL) { + if (!fill_function) { switch (dst->format->BytesPerPixel) { case 1: { diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 65e33ab86..1167c22d2 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -518,7 +518,7 @@ SDL_PixelFormat *SDL_AllocFormat(Uint32 pixel_format) /* Allocate an empty pixel format structure, and initialize it */ format = SDL_malloc(sizeof(*format)); - if (format == NULL) { + if (!format) { SDL_AtomicUnlock(&formats_lock); SDL_OutOfMemory(); return NULL; @@ -616,7 +616,7 @@ void SDL_FreeFormat(SDL_PixelFormat *format) { SDL_PixelFormat *prev; - if (format == NULL) { + if (!format) { SDL_InvalidParamError("format"); return; } @@ -659,7 +659,7 @@ SDL_Palette *SDL_AllocPalette(int ncolors) } palette = (SDL_Palette *)SDL_malloc(sizeof(*palette)); - if (palette == NULL) { + if (!palette) { SDL_OutOfMemory(); return NULL; } @@ -681,7 +681,7 @@ SDL_Palette *SDL_AllocPalette(int ncolors) int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette) { - if (format == NULL) { + if (!format) { return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format"); } @@ -712,7 +712,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int status = 0; /* Verify the parameters */ - if (palette == NULL) { + if (!palette) { return -1; } if (ncolors > (palette->ncolors - firstcolor)) { @@ -734,7 +734,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, void SDL_FreePalette(SDL_Palette *palette) { - if (palette == NULL) { + if (!palette) { SDL_InvalidParamError("palette"); return; } @@ -856,7 +856,7 @@ Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b) SDL_InvalidParamError("format"); return 0; } - if (format->palette == NULL) { + if (!format->palette) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask; } else { return SDL_FindColor(format->palette, r, g, b, SDL_ALPHA_OPAQUE); @@ -870,7 +870,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uin SDL_InvalidParamError("format"); return 0; } - if (format->palette == NULL) { + if (!format->palette) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask); } else { return SDL_FindColor(format->palette, r, g, b, a); @@ -880,7 +880,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uin void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b) { - if (format->palette == NULL) { + if (!format->palette) { unsigned v; v = (pixel & format->Rmask) >> format->Rshift; *r = SDL_expand_byte[format->Rloss][v]; @@ -902,7 +902,7 @@ void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) { - if (format->palette == NULL) { + if (!format->palette) { unsigned v; v = (pixel & format->Rmask) >> format->Rshift; *r = SDL_expand_byte[format->Rloss][v]; @@ -943,7 +943,7 @@ static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical) *identical = 0; } map = (Uint8 *)SDL_calloc(256, sizeof(Uint8)); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -966,7 +966,7 @@ static Uint8 *Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); map = (Uint8 *)SDL_calloc(256, bpp); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -1002,7 +1002,7 @@ SDL_BlitMap *SDL_AllocBlitMap(void) /* Allocate the empty map */ map = (SDL_BlitMap *)SDL_calloc(1, sizeof(*map)); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -1031,7 +1031,7 @@ void SDL_InvalidateAllBlitMap(SDL_Surface *surface) void SDL_InvalidateMap(SDL_BlitMap *map) { - if (map == NULL) { + if (!map) { return; } if (map->dst) { @@ -1070,7 +1070,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->info.table = Map1to1(srcfmt->palette, dstfmt->palette, &map->identity); if (!map->identity) { - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1082,7 +1082,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->info.table = Map1toN(srcfmt, src->map->info.r, src->map->info.g, src->map->info.b, src->map->info.a, dstfmt); - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1091,7 +1091,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) /* BitField --> Palette */ map->info.table = MapNto1(srcfmt, dstfmt, &map->identity); if (!map->identity) { - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1144,7 +1144,7 @@ void SDL_CalculateGammaRamp(float gamma, Uint16 * ramp) SDL_InvalidParamError("gamma"); return; } - if (ramp == NULL) { + if (!ramp) { SDL_InvalidParamError("ramp"); return; } diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index 1b461d230..e07a795d0 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -38,10 +38,10 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, } else if (height < 1) { SDL_InvalidParamError("height"); return SDL_FALSE; - } else if (rects == NULL) { + } else if (!rects) { SDL_InvalidParamError("rects"); return SDL_FALSE; - } else if (span == NULL) { + } else if (!span) { SDL_InvalidParamError("span"); return SDL_FALSE; } else if (numrects < 1) { diff --git a/src/video/SDL_rect_impl.h b/src/video/SDL_rect_impl.h index b0e3901b1..923092619 100644 --- a/src/video/SDL_rect_impl.h +++ b/src/video/SDL_rect_impl.h @@ -25,10 +25,10 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return SDL_FALSE; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return SDL_FALSE; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { @@ -70,13 +70,13 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return SDL_FALSE; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return SDL_FALSE; - } else if (result == NULL) { + } else if (!result) { SDL_InvalidParamError("result"); return SDL_FALSE; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */ @@ -120,13 +120,13 @@ void SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return; - } else if (result == NULL) { + } else if (!result) { SDL_InvalidParamError("result"); return; } else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */ @@ -180,7 +180,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c SCALARTYPE x, y; int i; - if (points == NULL) { + if (!points) { SDL_InvalidParamError("points"); return SDL_FALSE; } else if (count < 1) { @@ -210,7 +210,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c } if (!added) { /* Special case: if no result was requested, we are done */ - if (result == NULL) { + if (!result) { return SDL_TRUE; } @@ -236,7 +236,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c } } else { /* Special case: if no result was requested, we are done */ - if (result == NULL) { + if (!result) { return SDL_TRUE; } @@ -299,19 +299,19 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY SCALARTYPE recty2; int outcode1, outcode2; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return SDL_FALSE; - } else if (X1 == NULL) { + } else if (!X1) { SDL_InvalidParamError("X1"); return SDL_FALSE; - } else if (Y1 == NULL) { + } else if (!Y1) { SDL_InvalidParamError("Y1"); return SDL_FALSE; - } else if (X2 == NULL) { + } else if (!X2) { SDL_InvalidParamError("X2"); return SDL_FALSE; - } else if (Y2 == NULL) { + } else if (!Y2) { SDL_InvalidParamError("Y2"); return SDL_FALSE; } else if (SDL_RECTEMPTY(rect)) { diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index a0b977b6e..ecd683e78 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -32,13 +32,13 @@ SDL_Window *SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned i { SDL_Window *result = NULL; result = SDL_CreateWindow(title, -1000, -1000, w, h, (flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */); - if (result != NULL) { + if (result) { if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { SDL_DestroyWindow(result); return NULL; } result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); - if (result->shaper != NULL) { + if (result->shaper) { result->shaper->userx = x; result->shaper->usery = y; result->shaper->mode.mode = ShapeModeDefault; @@ -136,7 +136,7 @@ static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SD SDL_ShapeTree *result = (SDL_ShapeTree *)SDL_malloc(sizeof(SDL_ShapeTree)); SDL_Rect next = { 0, 0, 0, 0 }; - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -237,7 +237,7 @@ SDL_ShapeTree *SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *sha void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure) { - SDL_assert(tree != NULL); + SDL_assert(tree); if (tree->kind == QuadShape) { SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft, function, closure); SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright, function, closure); @@ -265,16 +265,16 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo SDL_VideoDevice *_this = SDL_GetVideoDevice(); int result; - if (window == NULL || !SDL_IsShapedWindow(window)) { + if (!window || !SDL_IsShapedWindow(window)) { /* The window given was not a shapeable window. */ return SDL_NONSHAPEABLE_WINDOW; } - if (shape == NULL) { + if (!shape) { /* Invalid shape argument. */ return SDL_INVALID_SHAPE_ARGUMENT; } - if (shape_mode != NULL) { + if (shape_mode) { window->shaper->mode = *shape_mode; } result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode); @@ -317,7 +317,7 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo static SDL_bool SDL_WindowHasAShape(SDL_Window *window) { - if (window == NULL || !SDL_IsShapedWindow(window)) { + if (!window || !SDL_IsShapedWindow(window)) { return SDL_FALSE; } return window->shaper->hasshape; @@ -325,8 +325,8 @@ static SDL_bool SDL_WindowHasAShape(SDL_Window *window) int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode) { - if (window != NULL && SDL_IsShapedWindow(window)) { - if (shape_mode == NULL) { + if (window && SDL_IsShapedWindow(window)) { + if (!shape_mode) { if (SDL_WindowHasAShape(window)) { return 0; /* The window given has a shape. */ } else { diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 39e06262b..132cfaa30 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -107,7 +107,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, /* Allocate the surface */ surface = (SDL_Surface *)SDL_calloc(1, sizeof(*surface)); - if (surface == NULL) { + if (!surface) { SDL_OutOfMemory(); return NULL; } @@ -125,7 +125,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { SDL_Palette *palette = SDL_AllocPalette((1 << surface->format->BitsPerPixel)); - if (palette == NULL) { + if (!palette) { SDL_FreeSurface(surface); return NULL; } @@ -238,7 +238,7 @@ SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, } surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); - if (surface != NULL) { + if (surface) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; @@ -284,7 +284,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, } surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); - if (surface != NULL) { + if (surface) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; @@ -297,7 +297,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface"); } if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) { @@ -312,7 +312,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -330,7 +330,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) SDL_bool SDL_HasSurfaceRLE(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -345,7 +345,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -373,7 +373,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key) SDL_bool SDL_HasColorKey(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -386,7 +386,7 @@ SDL_bool SDL_HasColorKey(SDL_Surface *surface) int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -406,7 +406,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp { int x, y, bpp; - if (surface == NULL) { + if (!surface) { return; } @@ -495,7 +495,7 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -517,7 +517,7 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -537,7 +537,7 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -557,7 +557,7 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -571,7 +571,7 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) { int flags, status; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -608,11 +608,11 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } - if (blendMode == NULL) { + if (!blendMode) { return 0; } @@ -641,7 +641,7 @@ SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect) SDL_Rect full_rect; /* Don't do anything if there's no surface to act on */ - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -652,7 +652,7 @@ SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect) full_rect.h = surface->h; /* Set the clipping rectangle */ - if (rect == NULL) { + if (!rect) { surface->clip_rect = full_rect; return SDL_TRUE; } @@ -705,7 +705,7 @@ int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, int srcx, srcy, w, h; /* Make sure the surfaces aren't locked */ - if (src == NULL || dst == NULL) { + if (!src || !dst) { return SDL_InvalidParamError("SDL_UpperBlit(): src/dst"); } if (src->locked || dst->locked) { @@ -713,7 +713,7 @@ int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, } /* If the destination rectangle is NULL, use the entire dest surface */ - if (dstrect == NULL) { + if (!dstrect) { fulldst.x = fulldst.y = 0; fulldst.w = dst->w; fulldst.h = dst->h; @@ -817,14 +817,14 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, int dst_w, dst_h; /* Make sure the surfaces aren't locked */ - if (src == NULL || dst == NULL) { + if (!src || !dst) { return SDL_InvalidParamError("SDL_UpperBlitScaled(): src/dst"); } if (src->locked || dst->locked) { return SDL_SetError("Surfaces must not be locked during blit"); } - if (srcrect == NULL) { + if (!srcrect) { src_w = src->w; src_h = src->h; } else { @@ -832,7 +832,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, src_h = srcrect->h; } - if (dstrect == NULL) { + if (!dstrect) { dst_w = dst->w; dst_h = dst->h; } else { @@ -848,7 +848,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, scaling_w = (double)dst_w / src_w; scaling_h = (double)dst_h / src_h; - if (dstrect == NULL) { + if (!dstrect) { dst_x0 = 0; dst_y0 = 0; dst_x1 = dst_w; @@ -860,7 +860,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, dst_y1 = dst_y0 + dst_h; } - if (srcrect == NULL) { + if (!srcrect) { src_x0 = 0; src_y0 = 0; src_x1 = src_w; @@ -1146,17 +1146,17 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * f Uint8 *palette_saved_alpha = NULL; int palette_saved_alpha_ncolors = 0; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } - if (format == NULL) { + if (!format) { SDL_InvalidParamError("format"); return NULL; } /* Check for empty destination palette! (results in empty image) */ - if (format->palette != NULL) { + if (format->palette) { int i; for (i = 0; i < format->palette->ncolors; ++i) { if ((format->palette->colors[i].r != 0xFF) || (format->palette->colors[i].g != 0xFF) || (format->palette->colors[i].b != 0xFF)) { @@ -1174,7 +1174,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * f format->BitsPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask); - if (convert == NULL) { + if (!convert) { return NULL; } @@ -1429,13 +1429,13 @@ int SDL_ConvertPixels(int width, int height, void *nonconst_src = (void *)src; int ret; - if (src == NULL) { + if (!src) { return SDL_InvalidParamError("src"); } if (!src_pitch) { return SDL_InvalidParamError("src_pitch"); } - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("dst"); } if (!dst_pitch) { @@ -1511,13 +1511,13 @@ int SDL_PremultiplyAlpha(int width, int height, Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - if (src == NULL) { + if (!src) { return SDL_InvalidParamError("src"); } if (!src_pitch) { return SDL_InvalidParamError("src_pitch"); } - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("dst"); } if (!dst_pitch) { @@ -1559,7 +1559,7 @@ int SDL_PremultiplyAlpha(int width, int height, */ void SDL_FreeSurface(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return; } if (surface->flags & SDL_DONTFREE) { diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 23ce7b1a7..44356baec 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -203,12 +203,12 @@ typedef struct static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { #if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ - if (_this->GL_CreateContext != NULL) { + if (_this->GL_CreateContext) { return SDL_WINDOW_OPENGL; } #endif #if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__) - if (_this->Metal_CreateView != NULL) { + if (_this->Metal_CreateView) { return SDL_WINDOW_METAL; } #endif @@ -224,7 +224,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U SDL_GetWindowSizeInPixels(window, &w, &h); - if (data == NULL) { + if (!data) { SDL_Renderer *renderer = NULL; const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' && @@ -241,7 +241,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U break; } } - if (renderer == NULL || (SDL_GetRendererInfo(renderer, &info) == -1)) { + if (!renderer || (SDL_GetRendererInfo(renderer, &info) == -1)) { if (renderer) { SDL_DestroyRenderer(renderer); } @@ -262,16 +262,16 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U } } } - if (renderer == NULL) { + if (!renderer) { return SDL_SetError("No hardware accelerated renderers available"); } } - SDL_assert(renderer != NULL); /* should have explicitly checked this above. */ + SDL_assert(renderer); /* should have explicitly checked this above. */ /* Create the data after we successfully create the renderer (bug #1116) */ data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_DestroyRenderer(renderer); return SDL_OutOfMemory(); } @@ -346,7 +346,7 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, SDL_GetWindowSizeInPixels(window, &w, &h); data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); - if (data == NULL || !data->texture) { + if (!data || !data->texture) { return SDL_SetError("No window texture data"); } @@ -373,7 +373,7 @@ static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window SDL_WindowTextureData *data; data = SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, NULL); - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -437,7 +437,7 @@ int SDL_VideoInit(const char *driver_name) int i = 0; /* Check to make sure we don't overwrite '_this' */ - if (_this != NULL) { + if (_this) { SDL_VideoQuit(); } @@ -465,14 +465,14 @@ int SDL_VideoInit(const char *driver_name) /* Select the proper video driver */ video = NULL; - if (driver_name == NULL) { + if (!driver_name) { driver_name = SDL_GetHint(SDL_HINT_VIDEODRIVER); } - if (driver_name != NULL && *driver_name != 0) { + if (driver_name && *driver_name != 0) { const char *driver_attempt = driver_name; - while (driver_attempt != NULL && *driver_attempt != 0 && video == NULL) { + while (driver_attempt && *driver_attempt != 0 && !video) { const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); - size_t driver_attempt_len = (driver_attempt_end != NULL) ? (driver_attempt_end - driver_attempt) + size_t driver_attempt_len = (driver_attempt_end) ? (driver_attempt_end - driver_attempt) : SDL_strlen(driver_attempt); for (i = 0; bootstrap[i]; ++i) { @@ -483,17 +483,17 @@ int SDL_VideoInit(const char *driver_name) } } - driver_attempt = (driver_attempt_end != NULL) ? (driver_attempt_end + 1) : NULL; + driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL; } } else { for (i = 0; bootstrap[i]; ++i) { video = bootstrap[i]->create(); - if (video != NULL) { + if (video) { break; } } } - if (video == NULL) { + if (!video) { if (driver_name) { SDL_SetError("%s not available", driver_name); goto pre_driver_error; @@ -556,7 +556,7 @@ int SDL_VideoInit(const char *driver_name) return 0; pre_driver_error: - SDL_assert(_this == NULL); + SDL_assert(!_this); if (init_touch) { SDL_TouchQuit(); } @@ -574,7 +574,7 @@ pre_driver_error: const char *SDL_GetCurrentVideoDriver() { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -654,7 +654,7 @@ void SDL_DelVideoDisplay(int index) int SDL_GetNumVideoDisplays(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return 0; } @@ -700,7 +700,7 @@ int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect) CHECK_DISPLAY_INDEX(displayIndex, -1); - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -737,7 +737,7 @@ int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect) CHECK_DISPLAY_INDEX(displayIndex, -1); - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -805,7 +805,7 @@ SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mo modes = SDL_realloc(modes, (display->max_display_modes + 32) * sizeof(*modes)); - if (modes == NULL) { + if (!modes) { return SDL_FALSE; } display->display_modes = modes; @@ -917,7 +917,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di int i; SDL_DisplayMode *current, *match; - if (mode == NULL || closest == NULL) { + if (!mode || !closest) { SDL_InvalidParamError("mode/closest"); return NULL; } @@ -954,7 +954,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di modes may still follow. */ continue; } - if (match == NULL || current->w < match->w || current->h < match->h) { + if (!match || current->w < match->w || current->h < match->h) { match = current; continue; } @@ -1211,7 +1211,7 @@ int SDL_GetWindowDisplayIndex(SDL_Window *window) SDL_VideoDisplay *new_display = &_this->displays[displayIndex]; /* The window was moved to a different display */ - if (new_display->fullscreen_window != NULL) { + if (new_display->fullscreen_window) { /* Uh oh, there's already a fullscreen window here */ } else { new_display->fullscreen_window = window; @@ -1271,7 +1271,7 @@ int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode) CHECK_WINDOW_MAGIC(window, -1); - if (mode == NULL) { + if (!mode) { return SDL_InvalidParamError("mode"); } @@ -1403,7 +1403,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) #endif display = SDL_GetDisplayForWindow(window); - if (display == NULL) { /* No display connected, nothing to do. */ + if (!display) { /* No display connected, nothing to do. */ return 0; } @@ -1601,14 +1601,14 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint SDL_Window *window; Uint32 type_flags, graphics_flags; - if (_this == NULL) { + if (!_this) { /* Initialize the video system if needed */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { return NULL; } /* Make clang-tidy happy */ - if (_this == NULL) { + if (!_this) { return NULL; } } @@ -1690,7 +1690,7 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); - if (window == NULL) { + if (!window) { SDL_OutOfMemory(); return NULL; } @@ -1804,7 +1804,7 @@ SDL_Window *SDL_CreateWindowFrom(const void *data) SDL_Window *window; Uint32 flags = SDL_WINDOW_FOREIGN; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -1840,7 +1840,7 @@ SDL_Window *SDL_CreateWindowFrom(const void *data) } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); - if (window == NULL) { + if (!window) { SDL_OutOfMemory(); return NULL; } @@ -2004,7 +2004,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) SDL_bool SDL_HasWindows(void) { - return _this && _this->windows != NULL; + return _this && _this->windows; } Uint32 SDL_GetWindowID(SDL_Window *window) @@ -2018,7 +2018,7 @@ SDL_Window *SDL_GetWindowFromID(Uint32 id) { SDL_Window *window; - if (_this == NULL) { + if (!_this) { return NULL; } for (window = _this->windows; window; window = window->next) { @@ -2063,7 +2063,7 @@ void SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon) { CHECK_WINDOW_MAGIC(window, ); - if (icon == NULL) { + if (!icon) { return; } @@ -2346,16 +2346,16 @@ int SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *botto { int dummy = 0; - if (top == NULL) { + if (!top) { top = &dummy; } - if (left == NULL) { + if (!left) { left = &dummy; } - if (right == NULL) { + if (!right) { right = &dummy; } - if (bottom == NULL) { + if (!bottom) { bottom = &dummy; } @@ -2377,11 +2377,11 @@ void SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) CHECK_WINDOW_MAGIC(window, ); - if (w == NULL) { + if (!w) { w = &filter; } - if (h == NULL) { + if (!h) { h = &filter; } @@ -2637,7 +2637,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) #if defined(__LINUX__) /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ - else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "x11") == 0)) { + else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { struct stat sb; if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ attempt_texture_framebuffer = SDL_FALSE; @@ -2645,7 +2645,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) } #endif #if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ - else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "windows") == 0)) { + else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) { attempt_texture_framebuffer = SDL_FALSE; } #endif @@ -2853,7 +2853,7 @@ int SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * red, if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) { return -1; } - SDL_assert(window->gamma != NULL); + SDL_assert(window->gamma); } if (red) { @@ -3180,7 +3180,7 @@ static SDL_bool ShouldMinimizeOnFocusLoss(SDL_Window *window) /* Real fullscreen windows should minimize on focus loss so the desktop video mode is restored */ hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); - if (hint == NULL || !*hint || SDL_strcasecmp(hint, "auto") == 0) { + if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) { if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP || DisableDisplayModeSwitching(_this) == SDL_TRUE) { return SDL_FALSE; @@ -3210,7 +3210,7 @@ SDL_Window *SDL_GetFocusWindow(void) { SDL_Window *window; - if (_this == NULL) { + if (!_this) { return NULL; } for (window = _this->windows; window; window = window->next) { @@ -3312,7 +3312,7 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_bool SDL_IsScreenSaverEnabled() { - if (_this == NULL) { + if (!_this) { return SDL_TRUE; } return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE; @@ -3320,7 +3320,7 @@ SDL_bool SDL_IsScreenSaverEnabled() void SDL_EnableScreenSaver() { - if (_this == NULL) { + if (!_this) { return; } if (!_this->suspend_screensaver) { @@ -3334,7 +3334,7 @@ void SDL_EnableScreenSaver() void SDL_DisableScreenSaver() { - if (_this == NULL) { + if (!_this) { return; } if (_this->suspend_screensaver) { @@ -3350,7 +3350,7 @@ void SDL_VideoQuit(void) { int i; - if (_this == NULL) { + if (!_this) { return; } @@ -3390,7 +3390,7 @@ int SDL_GL_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } if (_this->gl_config.driver_loaded) { @@ -3418,7 +3418,7 @@ void *SDL_GL_GetProcAddress(const char *proc) { void *func; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -3437,7 +3437,7 @@ void *SDL_GL_GetProcAddress(const char *proc) void SDL_GL_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return; } @@ -3480,7 +3480,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) /* Lookup the available extensions */ glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return SDL_FALSE; } @@ -3492,7 +3492,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi"); glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); - if ((glGetStringiFunc == NULL) || (glGetIntegervFunc == NULL)) { + if ((!glGetStringiFunc) || (!glGetIntegervFunc)) { return SDL_FALSE; } @@ -3513,7 +3513,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) /* Try the old way with glGetString(GL_EXTENSIONS) ... */ extensions = (const char *)glGetStringFunc(GL_EXTENSIONS); - if (extensions == NULL) { + if (!extensions) { return SDL_FALSE; } /* @@ -3525,7 +3525,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) for (;;) { where = SDL_strstr(start, extension); - if (where == NULL) { + if (!where) { break; } @@ -3576,7 +3576,7 @@ void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor) void SDL_GL_ResetAttributes() { - if (_this == NULL) { + if (!_this) { return; } @@ -3633,7 +3633,7 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value) #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } retval = 0; @@ -3771,14 +3771,14 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) GLenum attachmentattrib = 0; #endif - if (value == NULL) { + if (!value) { return SDL_InvalidParamError("value"); } /* Clear value in any case */ *value = 0; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } @@ -3954,7 +3954,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) #if SDL_VIDEO_OPENGL glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return -1; } @@ -3992,7 +3992,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } glGetErrorFunc = SDL_GL_GetProcAddress("glGetError"); - if (glGetErrorFunc == NULL) { + if (!glGetErrorFunc) { return -1; } @@ -4039,7 +4039,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } @@ -4073,7 +4073,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) SDL_Window *SDL_GL_GetCurrentWindow(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4082,7 +4082,7 @@ SDL_Window *SDL_GL_GetCurrentWindow(void) SDL_GLContext SDL_GL_GetCurrentContext(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4102,7 +4102,7 @@ void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) int SDL_GL_SetSwapInterval(int interval) { - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } else if (SDL_GL_GetCurrentContext() == NULL) { return SDL_SetError("No OpenGL context has been made current"); @@ -4115,7 +4115,7 @@ int SDL_GL_SetSwapInterval(int interval) int SDL_GL_GetSwapInterval(void) { - if (_this == NULL) { + if (!_this) { return 0; } else if (SDL_GL_GetCurrentContext() == NULL) { return 0; @@ -4148,7 +4148,7 @@ void SDL_GL_SwapWindow(SDL_Window *window) void SDL_GL_DeleteContext(SDL_GLContext context) { - if (_this == NULL || !context) { + if (!_this || !context) { return; } @@ -4428,7 +4428,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_Window *current_window; SDL_MessageBoxData mbdata; - if (messageboxdata == NULL) { + if (!messageboxdata) { return SDL_InvalidParamError("messageboxdata"); } else if (messageboxdata->numbuttons < 0) { return SDL_SetError("Invalid number of buttons"); @@ -4443,7 +4443,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) show_cursor_prev = SDL_ShowCursor(1); SDL_ResetKeyboard(); - if (buttonid == NULL) { + if (!buttonid) { buttonid = &dummybutton; } @@ -4566,10 +4566,10 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *messag /* Web browsers don't (currently) have an API for a custom message box that can block, but for the most common case (SDL_ShowSimpleMessageBox), we can use the standard Javascript alert() function. */ - if (title == NULL) { + if (!title) { title = ""; } - if (message == NULL) { + if (!message) { message = ""; } EM_ASM({ @@ -4646,7 +4646,7 @@ void SDL_OnApplicationWillResignActive(void) { if (_this) { SDL_Window *window; - for (window = _this->windows; window != NULL; window = window->next) { + for (window = _this->windows; window; window = window->next) { SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } @@ -4670,7 +4670,7 @@ void SDL_OnApplicationDidBecomeActive(void) if (_this) { SDL_Window *window; - for (window = _this->windows; window != NULL; window = window->next) { + for (window = _this->windows; window; window = window->next) { SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } @@ -4682,7 +4682,7 @@ void SDL_OnApplicationDidBecomeActive(void) int SDL_Vulkan_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return -1; } @@ -4705,7 +4705,7 @@ int SDL_Vulkan_LoadLibrary(const char *path) void *SDL_Vulkan_GetVkGetInstanceProcAddr(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4718,7 +4718,7 @@ void *SDL_Vulkan_GetVkGetInstanceProcAddr(void) void SDL_Vulkan_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return; } @@ -4743,7 +4743,7 @@ SDL_bool SDL_Vulkan_GetInstanceExtensions(SDL_Window *window, unsigned *count, c } } - if (count == NULL) { + if (!count) { SDL_InvalidParamError("count"); return SDL_FALSE; } @@ -4767,7 +4767,7 @@ SDL_bool SDL_Vulkan_CreateSurface(SDL_Window *window, return SDL_FALSE; } - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return SDL_FALSE; } diff --git a/src/video/SDL_vulkan_utils.c b/src/video/SDL_vulkan_utils.c index 3d5827f69..04ba664b1 100644 --- a/src/video/SDL_vulkan_utils.c +++ b/src/video/SDL_vulkan_utils.c @@ -149,7 +149,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( retval = SDL_calloc(count, sizeof(VkExtensionProperties)); } - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -232,7 +232,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, goto error; } chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY"); - if (chosenDisplayId != NULL) { + if (chosenDisplayId) { displayId = SDL_atoi(chosenDisplayId); } @@ -249,7 +249,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); - if (physicalDevices == NULL) { + if (!physicalDevices) { SDL_OutOfMemory(); goto error; } @@ -292,7 +292,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } displayProperties = SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount); - if (displayProperties == NULL) { + if (!displayProperties) { SDL_OutOfMemory(); goto error; } @@ -321,7 +321,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display modes: %u", displayModePropertiesCount); displayModeProperties = SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount); - if (displayModeProperties == NULL) { + if (!displayModeProperties) { SDL_OutOfMemory(); goto error; } @@ -368,7 +368,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount); displayPlaneProperties = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount); - if (displayPlaneProperties == NULL) { + if (!displayPlaneProperties) { SDL_OutOfMemory(); goto error; } @@ -399,7 +399,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount); planeSupportedDisplays = SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount); - if (planeSupportedDisplays == NULL) { + if (!planeSupportedDisplays) { SDL_free(displayPlaneProperties); SDL_OutOfMemory(); goto error; diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index dd79d79cf..9b8a45429 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -597,7 +597,7 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height, int tmp_pitch = (width * sizeof(Uint32)); tmp = SDL_malloc((size_t)tmp_pitch * height); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } @@ -978,7 +978,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, int tmp_pitch = (width * sizeof(Uint32)); tmp = SDL_malloc((size_t)tmp_pitch * height); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } @@ -1067,7 +1067,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src /* Allocate a temporary row for the swap */ tmp = (Uint8 *)SDL_malloc(UVwidth); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } for (y = 0; y < UVheight; ++y) { @@ -1127,7 +1127,7 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const voi if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } SDL_memcpy(tmp, src, (size_t)2 * UVheight * srcUVPitch); @@ -1200,7 +1200,7 @@ static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const vo if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } SDL_memcpy(tmp, src, (size_t)UVheight * srcUVPitch); diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index ba652019a..1d8fbb991 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -361,7 +361,7 @@ void Android_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index 7d9ab0928..ddb99eb45 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -89,7 +89,7 @@ static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (converted == NULL) { + if (!converted) { return NULL; } custom_cursor = Android_JNI_CreateCustomCursor(converted, hot_x, hot_y); @@ -118,7 +118,7 @@ static void Android_FreeCursor(SDL_Cursor *cursor) static SDL_Cursor *Android_CreateEmptyCursor() { - if (empty_cursor == NULL) { + if (!empty_cursor) { SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888); if (empty_surface) { SDL_memset(empty_surface->pixels, 0, (size_t)empty_surface->h * empty_surface->pitch); @@ -139,7 +139,7 @@ static void Android_DestroyEmptyCursor() static int Android_ShowCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { cursor = Android_CreateEmptyCursor(); } if (cursor) { @@ -216,7 +216,7 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y int changes; Uint8 button; - if (window == NULL) { + if (!window) { return; } diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index a62ae9eb8..3cf925d8a 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -54,7 +54,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin SDL_TouchID touchDeviceId = 0; SDL_FingerID fingerId = 0; - if (window == NULL) { + if (!window) { return; } diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 714fa45a5..0e4e3d1a7 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -88,13 +88,13 @@ static SDL_VideoDevice *Android_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return NULL; diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index 088d85e78..6008a521c 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -47,10 +47,10 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = "libvulkan.so"; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -75,7 +75,7 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 9b3573973..e38ce7e23 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -65,7 +65,7 @@ int Android_CreateWindow(_THIS, SDL_Window *window) SDL_SetKeyboardFocus(window); data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { retval = SDL_OutOfMemory(); goto endfunction; } @@ -132,7 +132,7 @@ void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *di } data = (SDL_WindowData *)window->driverdata; - if (data == NULL || !data->native_window) { + if (!data || !data->native_window) { if (data && !data->native_window) { SDL_SetError("Missing native window"); } diff --git a/src/video/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index f185cac33..4b3fedb74 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -79,13 +79,13 @@ static void LoadFont(_THIS, SDL_Window * window) SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); - if (windata->font != NULL) { + if (windata->font) { SDL_DFB_RELEASE(windata->font); windata->font = NULL; SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font)); } - if (windata->theme.font != NULL) + if (windata->theme.font) { DFBFontDescription fdesc; @@ -317,7 +317,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) SDL_FALLTHROUGH; default: windata->wm_grab = pos; - if (grabbed_window != NULL) + if (grabbed_window) DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_FALSE); DirectFB_SetWindowMouseGrab(_this, window, SDL_TRUE); windata->wm_lastx = evt->cx; @@ -350,7 +350,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) } } DirectFB_SetWindowMouseGrab(_this, window, SDL_FALSE); - if (grabbed_window != NULL) + if (grabbed_window) DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_TRUE); windata->wm_grab = WM_POS_NONE; return 1; diff --git a/src/video/directfb/SDL_DirectFB_dyn.c b/src/video/directfb/SDL_DirectFB_dyn.c index 02ed371a9..6131d9f92 100644 --- a/src/video/directfb/SDL_DirectFB_dyn.c +++ b/src/video/directfb/SDL_DirectFB_dyn.c @@ -93,7 +93,7 @@ int SDL_DirectFB_LoadLibrary(void) void SDL_DirectFB_UnLoadLibrary(void) { - if (handle != NULL) { + if (handle) { SDL_UnloadObject(handle); handle = NULL; } diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 47a8e6206..16d073c1d 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -308,7 +308,7 @@ static void ProcessInputEvent(_THIS, DFBInputEvent * ievt) if (!devdata->use_linux_input) { if (ievt->type == DIET_AXISMOTION) { - if ((grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) { + if ((grabbed_window) && (ievt->flags & DIEF_AXISREL)) { if (ievt->axis == DIAI_X) SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, ievt->axisrel, 0, 0); @@ -405,7 +405,7 @@ void DirectFB_PumpEventsWindow(_THIS) DFBInputEvent ievt; SDL_Window *w; - for (w = devdata->firstwin; w != NULL; w = w->next) { + for (w = devdata->firstwin; w; w = w->next) { SDL_DFB_WINDOWDATA(w); DFBWindowEvent evt; diff --git a/src/video/directfb/SDL_DirectFB_opengl.c b/src/video/directfb/SDL_DirectFB_opengl.c index 1c146a0e1..4ec2ff272 100644 --- a/src/video/directfb/SDL_DirectFB_opengl.c +++ b/src/video/directfb/SDL_DirectFB_opengl.c @@ -113,15 +113,15 @@ int DirectFB_GL_LoadLibrary(_THIS, const char *path) } - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { + if (!path) { path = "libGL.so.1"; } } handle = GL_LoadObject(path); - if (handle == NULL) { + if (!handle) { SDL_DFB_ERR("Library not found: %s\n", path); /* SDL_LoadObject() will call SDL_SetError() for us. */ return -1; @@ -210,7 +210,7 @@ int DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) } - if (ctx != NULL) { + if (ctx) { SDL_DFB_CHECKERR(ctx->context->Lock(ctx->context)); ctx->is_locked = 1; } @@ -242,7 +242,7 @@ int DirectFB_GL_SwapWindow(_THIS, SDL_Window * window) devdata->glFlush(); #endif - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window && p->is_locked) { SDL_DFB_CHECKERR(p->context->Unlock(p->context)); @@ -278,7 +278,7 @@ void DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) { if (p->is_locked) @@ -291,7 +291,7 @@ void DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) { SDL_DFB_WINDOWDATA(window); @@ -306,7 +306,7 @@ void DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) DirectFB_GL_DeleteContext(_this, p); } diff --git a/src/video/directfb/SDL_DirectFB_shape.c b/src/video/directfb/SDL_DirectFB_shape.c index a6c9aa092..f3b84831f 100644 --- a/src/video/directfb/SDL_DirectFB_shape.c +++ b/src/video/directfb/SDL_DirectFB_shape.c @@ -61,7 +61,7 @@ SDL_WindowShaper *DirectFB_CreateShaper(SDL_Window* window) int DirectFB_ResizeWindowShape(SDL_Window* window) { SDL_ShapeData* data = window->shaper->driverdata; - SDL_assert(data != NULL); + SDL_assert(data); if (window->x != -1000) { @@ -76,7 +76,7 @@ int DirectFB_ResizeWindowShape(SDL_Window* window) int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { - if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) + if(!shaper || !shape || !shaper->driverdata) return -1; if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) return -2; diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index be10dd15c..341957eca 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -39,7 +39,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -57,7 +57,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, DUMMY_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find dummy surface for window"); } diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 41dcf1b84..ff073a34c 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -94,7 +94,7 @@ static SDL_VideoDevice *DUMMY_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index e08d06b80..f2bae8bbe 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -964,7 +964,7 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data) /* Keyboard events are awkward */ keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); - if (keyElement == NULL) { + if (!keyElement) { keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW; } @@ -1007,7 +1007,7 @@ void Emscripten_UnregisterEventHandlers(SDL_WindowData *data) emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL); target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); - if (target == NULL) { + if (!target) { target = EMSCRIPTEN_EVENT_TARGET_WINDOW; } diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index 622619860..ba445fb07 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -46,7 +46,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); - if (surface == NULL) { + if (!surface) { return -1; } @@ -64,7 +64,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL_WindowData *data = (SDL_WindowData *)window->driverdata; surface = data->surface; - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find framebuffer surface for window"); } diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c index 51829d487..0ffc4adbf 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.c +++ b/src/video/emscripten/SDL_emscriptenmouse.c @@ -48,7 +48,7 @@ static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL cursor = SDL_calloc(1, sizeof(SDL_Cursor)); if (cursor) { curdata = (Emscripten_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -78,7 +78,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888, 0); - if (conv_surf == NULL) { + if (!conv_surf) { return NULL; } @@ -194,7 +194,7 @@ static void Emscripten_FreeCursor(SDL_Cursor *cursor) if (cursor) { curdata = (Emscripten_CursorData *)cursor->driverdata; - if (curdata != NULL) { + if (curdata) { if (curdata->is_custom) { SDL_free((char *)curdata->system_cursor); } @@ -247,7 +247,7 @@ static int Emscripten_SetRelativeMouseMode(SDL_bool enabled) /* TODO: pointer lock isn't actually enabled yet */ if (enabled) { window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { return -1; } diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index 8ddf91010..d4033d2b8 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -66,7 +66,7 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -209,7 +209,7 @@ static int Emscripten_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } diff --git a/src/video/haiku/SDL_bclipboard.cc b/src/video/haiku/SDL_bclipboard.cc index 0fd375321..6166d291e 100644 --- a/src/video/haiku/SDL_bclipboard.cc +++ b/src/video/haiku/SDL_bclipboard.cc @@ -65,7 +65,7 @@ char *HAIKU_GetClipboardText(_THIS) { be_clipboard->Unlock(); } - if (text == NULL) { + if (!text) { result = SDL_strdup(""); } else { /* Copy the data and pass on to SDL */ diff --git a/src/video/haiku/SDL_bframebuffer.cc b/src/video/haiku/SDL_bframebuffer.cc index 2cb4f6497..9c4be2846 100644 --- a/src/video/haiku/SDL_bframebuffer.cc +++ b/src/video/haiku/SDL_bframebuffer.cc @@ -94,7 +94,7 @@ int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window, int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) { - if (window == NULL) { + if (!window) { return 0; } diff --git a/src/video/haiku/SDL_bmessagebox.cc b/src/video/haiku/SDL_bmessagebox.cc index 60fce0078..620be9603 100644 --- a/src/video/haiku/SDL_bmessagebox.cc +++ b/src/video/haiku/SDL_bmessagebox.cc @@ -356,15 +356,15 @@ int HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid // "You need a valid BApplication object before interacting with the app_server." // "2 BApplication objects were created. Only one is allowed." BApplication *application = NULL; - if (be_app == NULL) { + if (!be_app) { application = new(std::nothrow) BApplication(SDL_signature); - if (application == NULL) { + if (!application) { return SDL_SetError("Cannot create the BApplication object. Lack of memory?"); } } HAIKU_SDL_MessageBox *SDL_MessageBox = new(std::nothrow) HAIKU_SDL_MessageBox(messageboxdata); - if (SDL_MessageBox == NULL) { + if (!SDL_MessageBox) { return SDL_SetError("Cannot create the HAIKU_SDL_MessageBox (BAlert inheritor) object. Lack of memory?"); } const int closeButton = SDL_MessageBox->GetCloseButtonId(); @@ -381,7 +381,7 @@ int HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid delete messageBox; } */ - if (application != NULL) { + if (application) { delete application; } diff --git a/src/video/haiku/SDL_bopengl.cc b/src/video/haiku/SDL_bopengl.cc index 7e12ad6a6..3949e4bbd 100644 --- a/src/video/haiku/SDL_bopengl.cc +++ b/src/video/haiku/SDL_bopengl.cc @@ -65,7 +65,7 @@ int HAIKU_GL_LoadLibrary(_THIS, const char *path) void *HAIKU_GL_GetProcAddress(_THIS, const char *proc) { - if (_this->gl_config.dll_handle != NULL) { + if (_this->gl_config.dll_handle) { void *location = NULL; status_t err; if ((err = @@ -92,8 +92,8 @@ int HAIKU_GL_SwapWindow(_THIS, SDL_Window * window) { int HAIKU_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { BGLView* glView = (BGLView*)context; // printf("HAIKU_GL_MakeCurrent(%llx), win = %llx, thread = %d\n", (uint64)context, (uint64)window, find_thread(NULL)); - if (glView != NULL) { - if ((glView->Window() == NULL) || (window == NULL) || (_ToBeWin(window)->GetGLView() != glView)) { + if (glView) { + if ((glView->Window() == NULL) || (!window) || (_ToBeWin(window)->GetGLView() != glView)) { return SDL_SetError("MakeCurrent failed"); } } @@ -146,7 +146,7 @@ void HAIKU_GL_DeleteContext(_THIS, SDL_GLContext context) { // printf("HAIKU_GL_DeleteContext(%llx), thread = %d\n", (uint64)context, find_thread(NULL)); BGLView* glView = (BGLView*)context; SDL_BWin *bwin = (SDL_BWin*)glView->Window(); - if (bwin == NULL) { + if (!bwin) { delete glView; } else { bwin->RemoveGLView(); diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 0f23c4d7b..7e26c1ac0 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -193,7 +193,7 @@ static SDL_Cursor * HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (converted == NULL) { + if (!converted) { return NULL; } @@ -215,7 +215,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return 0; } @@ -234,7 +234,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) { SDL_Window *window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { return 0; } @@ -254,7 +254,7 @@ static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) static void HAIKU_MouseInit(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return; } mouse->CreateCursor = HAIKU_CreateCursor; diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc index 18e03d4ae..db21719b5 100644 --- a/src/video/haiku/SDL_bwindow.cc +++ b/src/video/haiku/SDL_bwindow.cc @@ -67,7 +67,7 @@ static int _InitWindow(_THIS, SDL_Window *window) { } SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags); - if (bwin == NULL) { + if (!bwin) { return -1; } diff --git a/src/video/kmsdrm/SDL_kmsdrmdyn.c b/src/video/kmsdrm/SDL_kmsdrmdyn.c index 15c0f0d39..14460dc3d 100644 --- a/src/video/kmsdrm/SDL_kmsdrmdyn.c +++ b/src/video/kmsdrm/SDL_kmsdrmdyn.c @@ -52,22 +52,22 @@ static void *KMSDRM_GetSym(const char *fnname, int *pHasModule) int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].lib != NULL) { + if (kmsdrmlibs[i].lib) { fn = SDL_LoadFunction(kmsdrmlibs[i].lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_KMSDRM - if (fn != NULL) + if (fn) SDL_Log("KMSDRM: Found '%s' in %s (%p)\n", fnname, kmsdrmlibs[i].libname, fn); else SDL_Log("KMSDRM: Symbol '%s' NOT FOUND!\n", fnname); #endif - if (fn == NULL) { + if (!fn) { *pHasModule = 0; /* kill this module. */ } @@ -101,7 +101,7 @@ void SDL_KMSDRM_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].lib != NULL) { + if (kmsdrmlibs[i].lib) { SDL_UnloadObject(kmsdrmlibs[i].lib); kmsdrmlibs[i].lib = NULL; } @@ -122,7 +122,7 @@ int SDL_KMSDRM_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].libname != NULL) { + if (kmsdrmlibs[i].libname) { kmsdrmlibs[i].lib = SDL_LoadObject(kmsdrmlibs[i].libname); } } diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index 955045a7e..b139abe46 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -152,7 +152,7 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) int i; int ret; - if (curdata == NULL || !dispdata->cursor_bo) { + if (!curdata || !dispdata->cursor_bo) { return SDL_SetError("Cursor or display not initialized properly."); } @@ -163,7 +163,7 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) ready_buffer = (uint8_t *)SDL_calloc(1, bufsize); - if (ready_buffer == NULL) { + if (!ready_buffer) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -241,12 +241,12 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ ret = NULL; cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); - if (cursor == NULL) { + if (!cursor) { SDL_OutOfMemory(); goto cleanup; } curdata = (KMSDRM_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); goto cleanup; } @@ -282,7 +282,7 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ ret = cursor; cleanup: - if (ret == NULL) { + if (!ret) { if (curdata) { if (curdata->buffer) { SDL_free(curdata->buffer); @@ -310,13 +310,13 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor) /* Get the mouse focused window, if any. */ mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return SDL_SetError("No mouse."); } window = mouse->focus; - if (window == NULL || cursor == NULL) { + if (!window || !cursor) { /* If no window is focused by mouse or cursor is NULL, since we have no window (no mouse->focus) and hence diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 513694c59..ca31b4a03 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -144,7 +144,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window) /* Get an actual usable fb for the next front buffer. */ fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); - if (fb_info == NULL) { + if (!fb_info) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer"); return 0; } diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index f5e2577de..006798042 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -89,7 +89,7 @@ static int get_driindex(void) SDL_strlcpy(device, kmsdrm_dri_path, sizeof(device)); folder = opendir(device); - if (folder == NULL) { + if (!folder) { SDL_SetError("Failed to open directory '%s'", device); return -ENOENT; } @@ -127,7 +127,7 @@ static int get_driindex(void) KMSDRM_drmModeGetConnector( drm_fd, resources->connectors[i]); - if (conn == NULL) { + if (!conn) { continue; } @@ -241,13 +241,13 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) } device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } viddata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (viddata == NULL) { + if (!viddata) { SDL_OutOfMemory(); goto cleanup; } @@ -348,7 +348,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) when the backing buffer is destroyed */ fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo)); - if (fb_info == NULL) { + if (!fb_info) { SDL_OutOfMemory(); return NULL; } @@ -677,7 +677,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re /* Reserve memory for the new display's driverdata. */ dispdata = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (dispdata == NULL) { + if (!dispdata) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -698,7 +698,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re for (i = 0; i < resources->count_encoders; i++) { encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); - if (encoder == NULL) { + if (!encoder) { continue; } @@ -710,13 +710,13 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re encoder = NULL; } - if (encoder == NULL) { + if (!encoder) { /* No encoder was connected, find the first supported one */ for (i = 0; i < resources->count_encoders; i++) { encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); - if (encoder == NULL) { + if (!encoder) { continue; } @@ -735,7 +735,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re } } - if (encoder == NULL) { + if (!encoder) { ret = SDL_SetError("No connected encoder found for connector."); goto cleanup; } @@ -745,7 +745,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re /* If no CRTC was connected to the encoder, find the first CRTC that is supported by the encoder, and use that. */ - if (crtc == NULL) { + if (!crtc) { for (i = 0; i < resources->count_crtcs; i++) { if (encoder->possible_crtcs & (1 << i)) { encoder->crtc_id = resources->crtcs[i]; @@ -755,7 +755,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re } } - if (crtc == NULL) { + if (!crtc) { ret = SDL_SetError("No CRTC found for connector."); goto cleanup; } @@ -840,7 +840,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re There's no problem with it being still incomplete. */ modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -910,7 +910,7 @@ static int KMSDRM_InitDisplays(_THIS) /* Get all of the available connectors / devices / crtcs */ resources = KMSDRM_drmModeGetResources(viddata->drm_fd); - if (resources == NULL) { + if (!resources) { ret = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd); goto cleanup; } @@ -921,7 +921,7 @@ static int KMSDRM_InitDisplays(_THIS) drmModeConnector *connector = KMSDRM_drmModeGetConnector(viddata->drm_fd, resources->connectors[i]); - if (connector == NULL) { + if (!connector) { continue; } @@ -1332,7 +1332,7 @@ int KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mod return 0; } - if (modedata == NULL) { + if (!modedata) { return SDL_SetError("Mode doesn't have an associated index"); } @@ -1355,7 +1355,7 @@ void KMSDRM_DestroyWindow(_THIS, SDL_Window *window) SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ unsigned int i, j; - if (windata == NULL) { + if (!windata) { return; } @@ -1439,7 +1439,7 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (windata == NULL) { + if (!windata) { return SDL_OutOfMemory(); } @@ -1580,7 +1580,7 @@ int KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window); SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata; Uint16* tempRamp = SDL_calloc(3 * sizeof(Uint16), 256); - if (tempRamp == NULL) + if (!tempRamp) { return SDL_OutOfMemory(); } diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index 567bfc71d..31a3061cb 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -56,10 +56,10 @@ int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } @@ -93,7 +93,7 @@ int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } diff --git a/src/video/n3ds/SDL_n3dsframebuffer.c b/src/video/n3ds/SDL_n3dsframebuffer.c index 601e8bc0f..dd343811c 100644 --- a/src/video/n3ds/SDL_n3dsframebuffer.c +++ b/src/video/n3ds/SDL_n3dsframebuffer.c @@ -47,7 +47,7 @@ int SDL_N3DS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, FreePreviousWindowFramebuffer(window); framebuffer = CreateNewWindowFramebuffer(window); - if (framebuffer == NULL) { + if (!framebuffer) { return SDL_OutOfMemory(); } @@ -84,7 +84,7 @@ int SDL_N3DS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect * u32 bufsize; surface = (SDL_Surface *)SDL_GetWindowData(window, N3DS_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("%s: Unable to get the window surface.", __func__); } diff --git a/src/video/n3ds/SDL_n3dsvideo.c b/src/video/n3ds/SDL_n3dsvideo.c index 1668f9dec..09b4c0e80 100644 --- a/src/video/n3ds/SDL_n3dsvideo.c +++ b/src/video/n3ds/SDL_n3dsvideo.c @@ -57,7 +57,7 @@ static void N3DS_DeleteDevice(SDL_VideoDevice *device) static SDL_VideoDevice *N3DS_CreateDevice(void) { SDL_VideoDevice *device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -108,7 +108,7 @@ AddN3DSDisplay(gfxScreen_t screen) SDL_DisplayMode mode; SDL_VideoDisplay display; DisplayDriverData *display_driver_data = SDL_calloc(1, sizeof(DisplayDriverData)); - if (display_driver_data == NULL) { + if (!display_driver_data) { SDL_OutOfMemory(); return; } @@ -150,7 +150,7 @@ static void N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { DisplayDriverData *driver_data = (DisplayDriverData *)display->driverdata; - if (driver_data == NULL) { + if (!driver_data) { return -1; } rect->x = 0; @@ -165,7 +165,7 @@ static int N3DS_CreateWindow(_THIS, SDL_Window *window) { DisplayDriverData *display_data; SDL_WindowData *window_data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (window_data == NULL) { + if (!window_data) { return SDL_OutOfMemory(); } display_data = (DisplayDriverData *)SDL_GetDisplayDriverData(window->display_index); @@ -177,7 +177,7 @@ static int N3DS_CreateWindow(_THIS, SDL_Window *window) static void N3DS_DestroyWindow(_THIS, SDL_Window *window) { - if (window == NULL) { + if (!window) { return; } SDL_free(window->driverdata); diff --git a/src/video/ngage/SDL_ngageframebuffer.cpp b/src/video/ngage/SDL_ngageframebuffer.cpp index 20b1857dc..af170ea73 100644 --- a/src/video/ngage/SDL_ngageframebuffer.cpp +++ b/src/video/ngage/SDL_ngageframebuffer.cpp @@ -57,7 +57,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -149,7 +149,7 @@ int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, NGAGE_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find ngage surface for window"); } diff --git a/src/video/ngage/SDL_ngagevideo.cpp b/src/video/ngage/SDL_ngagevideo.cpp index 4b5c692e6..b3d42b9e2 100644 --- a/src/video/ngage/SDL_ngagevideo.cpp +++ b/src/video/ngage/SDL_ngagevideo.cpp @@ -106,14 +106,14 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } /* Initialize internal N-Gage specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return 0; diff --git a/src/video/ngage/SDL_ngagewindow.cpp b/src/video/ngage/SDL_ngagewindow.cpp index 9d598b79f..1ff57a8da 100644 --- a/src/video/ngage/SDL_ngagewindow.cpp +++ b/src/video/ngage/SDL_ngagewindow.cpp @@ -36,7 +36,7 @@ int NGAGE_CreateWindow(_THIS, SDL_Window *window) { NGAGE_Window *ngage_window = (NGAGE_Window *)SDL_calloc(1, sizeof(NGAGE_Window)); - if (ngage_window == NULL) { + if (!ngage_window) { return SDL_OutOfMemory(); } diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index 4e27c7250..6fa04d6e8 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -39,7 +39,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *for /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -58,7 +58,7 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_R SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, OFFSCREEN_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find offscreen surface for window"); } diff --git a/src/video/offscreen/SDL_offscreenvideo.c b/src/video/offscreen/SDL_offscreenvideo.c index 2fd86d98f..23c4bb5ee 100644 --- a/src/video/offscreen/SDL_offscreenvideo.c +++ b/src/video/offscreen/SDL_offscreenvideo.c @@ -58,7 +58,7 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/offscreen/SDL_offscreenwindow.c b/src/video/offscreen/SDL_offscreenwindow.c index 03a14c390..934616166 100644 --- a/src/video/offscreen/SDL_offscreenwindow.c +++ b/src/video/offscreen/SDL_offscreenwindow.c @@ -31,7 +31,7 @@ int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window) { OFFSCREEN_Window *offscreen_window = SDL_calloc(1, sizeof(OFFSCREEN_Window)); - if (offscreen_window == NULL) { + if (!offscreen_window) { return SDL_OutOfMemory(); } diff --git a/src/video/os2/SDL_os2dive.c b/src/video/os2/SDL_os2dive.c index 1b3eb13ba..4a214f968 100644 --- a/src/video/os2/SDL_os2dive.c +++ b/src/video/os2/SDL_os2dive.c @@ -101,7 +101,7 @@ PVODATA voOpen(void) { PVODATA pVOData = SDL_calloc(1, sizeof(VODATA)); - if (pVOData == NULL) { + if (!pVOData) { SDL_OutOfMemory(); return NULL; } @@ -277,7 +277,7 @@ static VOID voVideoBufFree(PVODATA pVOData) pVOData->ulDIVEBufNum = 0; } - if (pVOData->pBuffer != NULL) { + if (pVOData->pBuffer) { ulRC = DosFreeMem(pVOData->pBuffer); if (ulRC != NO_ERROR) { debug_os2("DosFreeMem(), rc = %u", ulRC); @@ -296,11 +296,11 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, return FALSE; } - if (pSDLRects != NULL) { + if (pSDLRects) { PBYTE pbLineMask; pbLineMask = SDL_stack_alloc(BYTE, pVOData->ulHeight); - if (pbLineMask == NULL) { + if (!pbLineMask) { debug_os2("Not enough stack size"); return FALSE; } diff --git a/src/video/os2/SDL_os2messagebox.c b/src/video/os2/SDL_os2messagebox.c index 83ac8775e..075ae8a1d 100644 --- a/src/video/os2/SDL_os2messagebox.c +++ b/src/video/os2/SDL_os2messagebox.c @@ -206,9 +206,9 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) ULONG cSDLBtnData = messageboxdata->numbuttons; PSZ pszTitle = OS2_UTF8ToSys(messageboxdata->title); - ULONG cbTitle = (pszTitle == NULL)? 1 : (SDL_strlen(pszTitle) + 1); + ULONG cbTitle = (!pszTitle)? 1 : (SDL_strlen(pszTitle) + 1); PSZ pszText = OS2_UTF8ToSys(messageboxdata->message); - ULONG cbText = (pszText == NULL)? 1 : (SDL_strlen(pszText) + 1); + ULONG cbText = (!pszText)? 1 : (SDL_strlen(pszText) + 1); PDLGTEMPLATE pTemplate; ULONG cbTemplate; @@ -219,7 +219,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) ULONG cbBtnText; HWND hwnd; - const SDL_MessageBoxColor* pSDLColors = (messageboxdata->colorScheme == NULL)? + const SDL_MessageBoxColor* pSDLColors = (!messageboxdata->colorScheme)? NULL : messageboxdata->colorScheme->colors; const SDL_MessageBoxColor* pSDLColor; @@ -237,11 +237,11 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) /* Button items datas - text for buttons. */ for (ulIdx = 0; ulIdx < cSDLBtnData; ulIdx++) { pszBtnText = (PSZ)pSDLBtnData[ulIdx].text; - cbTemplate += (pszBtnText == NULL)? 1 : (SDL_strlen(pszBtnText) + 1); + cbTemplate += (!pszBtnText)? 1 : (SDL_strlen(pszBtnText) + 1); } /* Presentation parameter space. */ - if (pSDLColors != NULL) { + if (pSDLColors) { cbTemplate += 26 /* PP for frame. */ + 26 /* PP for static text. */ + (48 * cSDLBtnData); /* PP for buttons. */ @@ -291,7 +291,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cx = 175; pDlgItem->cy = 65; pDlgItem->id = DID_OK; /* An ID value? */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the frame - dialog colors. */ @@ -346,7 +346,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cy = 62; /* It will be used. */ pDlgItem->id = IDD_TEXT_MESSAGE; /* an ID value */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the static text - dialog colors. */ @@ -407,7 +407,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->offClassName = (USHORT)WC_BUTTON; pszBtnText = OS2_UTF8ToSys(pSDLBtnData[ulIdx].text); - cbBtnText = (pszBtnText == NULL)? 1 : (SDL_strlen(pszBtnText) + 1); + cbBtnText = (!pszBtnText)? 1 : (SDL_strlen(pszBtnText) + 1); pDlgItem->cchText = cbBtnText; pDlgItem->offText = pcDlgData - (PCHAR)pTemplate; /* Offset to the text. */ /* Copy text for the button into the dialog template. */ @@ -435,7 +435,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cy = 15; pDlgItem->id = IDD_PB_FIRST + ulIdx; /* an ID value */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the button - dialog colors. */ @@ -473,7 +473,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) /* Create the dialog from template. */ stDlgData.cb = sizeof(MSGBOXDLGDATA); - stDlgData.hwndUnder = (messageboxdata->window != NULL && messageboxdata->window->driverdata != NULL)? + stDlgData.hwndUnder = (messageboxdata->window && messageboxdata->window->driverdata)? ((WINDATA *)messageboxdata->window->driverdata)->hwnd : HWND_DESKTOP; hwnd = WinCreateDlg(HWND_DESKTOP, /* Parent is desktop. */ diff --git a/src/video/os2/SDL_os2mouse.c b/src/video/os2/SDL_os2mouse.c index 3ffdef917..18468801d 100644 --- a/src/video/os2/SDL_os2mouse.c +++ b/src/video/os2/SDL_os2mouse.c @@ -46,7 +46,7 @@ static SDL_Cursor* OS2_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) return NULL; pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor)); - if (pSDLCursor == NULL) { + if (!pSDLCursor) { WinDestroyPointer(hptr); SDL_OutOfMemory(); return NULL; @@ -91,7 +91,7 @@ static SDL_Cursor* OS2_CreateSystemCursor(SDL_SystemCursor id) } pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor)); - if (pSDLCursor == NULL) { + if (!pSDLCursor) { WinDestroyPointer(hptr); SDL_OutOfMemory(); return NULL; @@ -111,7 +111,7 @@ static void OS2_FreeCursor(SDL_Cursor *cursor) static int OS2_ShowCursor(SDL_Cursor *cursor) { - hptrCursor = (cursor != NULL)? (HPOINTER)cursor->driverdata : NULLHANDLE; + hptrCursor = (cursor)? (HPOINTER)cursor->driverdata : NULLHANDLE; return ((SDL_GetMouseFocus() == NULL) || WinSetPointer(HWND_DESKTOP, hptrCursor))? 0 : -1; } @@ -137,7 +137,7 @@ static int OS2_WarpMouseGlobal(int x, int y) static int OS2_CaptureMouse(SDL_Window *window) { - return WinSetCapture(HWND_DESKTOP, (window == NULL)? NULLHANDLE : + return WinSetCapture(HWND_DESKTOP, (!window)? NULLHANDLE : ((WINDATA *)window->driverdata)->hwnd)? 0 : -1; } @@ -182,7 +182,7 @@ void OS2_QuitMouse(_THIS) { SDL_Mouse *pSDLMouse = SDL_GetMouse(); - if (pSDLMouse->def_cursor != NULL) { + if (pSDLMouse->def_cursor) { SDL_free(pSDLMouse->def_cursor); pSDLMouse->def_cursor = NULL; pSDLMouse->cur_cursor = NULL; diff --git a/src/video/os2/SDL_os2util.c b/src/video/os2/SDL_os2util.c index e6a306fbf..86541c5cf 100644 --- a/src/video/os2/SDL_os2util.c +++ b/src/video/os2/SDL_os2util.c @@ -41,7 +41,7 @@ HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY) } pulBitmap = (PULONG) SDL_malloc(surface->h * surface->w * 2 * sizeof(ULONG)); - if (pulBitmap == NULL) { + if (!pulBitmap) { SDL_OutOfMemory(); return NULLHANDLE; } diff --git a/src/video/os2/SDL_os2video.c b/src/video/os2/SDL_os2video.c index 1fdd2c64f..7c8462005 100644 --- a/src/video/os2/SDL_os2video.c +++ b/src/video/os2/SDL_os2video.c @@ -171,7 +171,7 @@ static SDL_DisplayMode *_getDisplayModeForSDLWindow(SDL_Window *window) { SDL_VideoDisplay *pSDLDisplay = SDL_GetDisplayForWindow(window); - if (pSDLDisplay == NULL) { + if (!pSDLDisplay) { debug_os2("No display for the window"); return FALSE; } @@ -201,19 +201,19 @@ static VOID _setVisibleRegion(WINDATA *pWinData, BOOL fVisible) { SDL_VideoDisplay *pSDLDisplay; - if (! pWinData->pVOData) + if (!pWinData->pVOData) return; pSDLDisplay = (fVisible)? SDL_GetDisplayForWindow(pWinData->window) : NULL; pWinData->pOutput->SetVisibleRegion(pWinData->pVOData, pWinData->hwnd, - (pSDLDisplay == NULL) ? - NULL : &pSDLDisplay->current_mode, + (!pSDLDisplay) ? + NULL : &pSDLDisplay->current_mode, pWinData->hrgnShape, fVisible); } static VOID _wmPaint(WINDATA *pWinData, HWND hwnd) { - if (pWinData->pVOData == NULL || + if (!pWinData->pVOData || !pWinData->pOutput->Update(pWinData->pVOData, hwnd, NULL, 0)) { RECTL rectl; HPS hps; @@ -438,7 +438,7 @@ static MRESULT EXPENTRY wndFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp HWND hwndClient = WinQueryWindow(hwnd, QW_BOTTOM); WINDATA * pWinData = (WINDATA *)WinQueryWindowULong(hwndClient, 0); - if (pWinData == NULL) + if (!pWinData) return WinDefWindowProc(hwnd, msg, mp1, mp2); /* Send a SDL_SYSWMEVENT if the application wants them */ @@ -544,7 +544,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { WINDATA *pWinData = (WINDATA *)WinQueryWindowULong(hwnd, 0); - if (pWinData == NULL) + if (!pWinData) return WinDefWindowProc(hwnd, msg, mp1, mp2); /* Send a SDL_SYSWMEVENT if the application wants them */ @@ -565,7 +565,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) case WM_CLOSE: case WM_QUIT: SDL_SendWindowEvent(pWinData->window, SDL_WINDOWEVENT_CLOSE, 0, 0); - if (pWinData->fnUserWndProc == NULL) + if (!pWinData->fnUserWndProc) return (MRESULT)FALSE; break; @@ -642,7 +642,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) case WM_TRANSLATEACCEL: /* ALT and acceleration keys not allowed (must be processed in WM_CHAR) */ - if (mp1 == NULL || ((PQMSG)mp1)->msg != WM_CHAR) + if (!mp1 || ((PQMSG)mp1)->msg != WM_CHAR) break; return (MRESULT)FALSE; @@ -690,7 +690,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) return _wmDrop(pWinData, (PDRAGINFO)PVOIDFROMMP(mp1)); } - return (pWinData->fnUserWndProc != NULL)? + return (pWinData->fnUserWndProc)? pWinData->fnUserWndProc(hwnd, msg, mp1, mp2) : WinDefWindowProc(hwnd, msg, mp1, mp2); } @@ -715,7 +715,7 @@ static WINDATA *_setupWindow(_THIS, SDL_Window *window, HWND hwndFrame, SDL_VideoData *pVData = (SDL_VideoData *)_this->driverdata; WINDATA *pWinData = SDL_calloc(1, sizeof(WINDATA)); - if (pWinData == NULL) { + if (!pWinData) { SDL_OutOfMemory(); return NULL; } @@ -745,7 +745,7 @@ static int OS2_CreateWindow(_THIS, SDL_Window *window) ULONG ulSWPFlags = SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE; WINDATA *pWinData; - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return -1; /* Create a PM window */ @@ -766,7 +766,7 @@ static int OS2_CreateWindow(_THIS, SDL_Window *window) /* Setup window data and frame window procedure */ pWinData = _setupWindow(_this, window, hwndFrame, hwnd); - if (pWinData == NULL) { + if (!pWinData) { WinDestroyWindow(hwndFrame); return -1; } @@ -809,7 +809,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) POINTL pointl; debug_os2("Enter"); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return -1; /* User can accept client OR frame window handle. @@ -892,7 +892,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) /* Setup window data and frame window procedure */ pWinData = _setupWindow(_this, window, hwndFrame, hwnd); - if (pWinData == NULL) { + if (!pWinData) { SDL_free(window->title); window->title = NULL; return -1; @@ -911,7 +911,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) WINDATA *pWinData = (WINDATA *)window->driverdata; debug_os2("Enter"); - if (pWinData == NULL) + if (!pWinData) return; if (pWinData->hrgnShape != NULLHANDLE) { @@ -925,7 +925,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) window->shaper = NULL; } - if (pWinData->fnUserWndProc == NULL) { + if (!pWinData->fnUserWndProc) { /* Window was created by SDL (OS2_CreateWindow()), * not by user (OS2_CreateWindowFrom()) */ WinDestroyWindow(pWinData->hwndFrame); @@ -933,7 +933,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) WinSetWindowULong(pWinData->hwnd, 0, 0); } - if ((pVData != NULL) && (pWinData->pVOData != NULL)) { + if ((pVData) && (pWinData->pVOData)) { pVData->pOutput->Close(pWinData->pVOData); pWinData->pVOData = NULL; } @@ -949,7 +949,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) static void OS2_SetWindowTitle(_THIS, SDL_Window *window) { - PSZ pszTitle = (window->title == NULL)? NULL : OS2_UTF8ToSys(window->title); + PSZ pszTitle = (!window->title)? NULL : OS2_UTF8ToSys(window->title); WinSetWindowText(((WINDATA *)window->driverdata)->hwndFrame, pszTitle); SDL_free(pszTitle); @@ -982,7 +982,7 @@ static void OS2_SetWindowPosition(_THIS, SDL_Window *window) SDL_DisplayMode *pSDLDisplayMode = _getDisplayModeForSDLWindow(window); debug_os2("Enter"); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return; rectl.xLeft = 0; @@ -1102,7 +1102,7 @@ static void OS2_SetWindowFullscreen(_THIS, SDL_Window *window, debug_os2("Enter, fullscreen: %u", fullscreen); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return; if (SDL_ShouldAllowTopmost() && @@ -1189,7 +1189,7 @@ static void _combineRectRegions(SDL_ShapeTree *node, void *closure) /* Expand rectangles list */ if ((pShapeRects->cRects & 0x0F) == 0) { pRect = SDL_realloc(pShapeRects->pRects, (pShapeRects->cRects + 0x10) * sizeof(RECTL)); - if (pRect == NULL) + if (!pRect) return; pShapeRects->pRects = pRect; } @@ -1235,13 +1235,13 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, HPS hps; debug_os2("Enter"); - if (shaper == NULL || shape == NULL || + if (!shaper || !shape || (shape->format->Amask == 0 && shape_mode->mode != ShapeModeColorKey) || shape->w != shaper->window->w || shape->h != shaper->window->h) { return SDL_INVALID_SHAPE_ARGUMENT; } - if (shaper->driverdata != NULL) + if (shaper->driverdata) SDL_FreeShapeTree((SDL_ShapeTree **)&shaper->driverdata); pShapeTree = SDL_CalculateShapeTree(*shape_mode, shape); @@ -1257,7 +1257,7 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, if (pWinData->hrgnShape != NULLHANDLE) GpiDestroyRegion(hps, pWinData->hrgnShape); - pWinData->hrgnShape = (stShapeRects.pRects == NULL) ? NULLHANDLE : + pWinData->hrgnShape = (!stShapeRects.pRects) ? NULLHANDLE : GpiCreateRegion(hps, stShapeRects.cRects, stShapeRects.pRects); WinReleasePS(hps); @@ -1270,11 +1270,11 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, static int OS2_ResizeWindowShape(SDL_Window *window) { debug_os2("Enter"); - if (window == NULL) + if (!window) return -1; if (window->x != -1000) { - if (window->shaper->driverdata != NULL) + if (window->shaper->driverdata) SDL_FreeShapeTree((SDL_ShapeTree **)window->shaper->driverdata); if (window->shaper->hasshape == SDL_TRUE) { @@ -1295,7 +1295,7 @@ static void OS2_DestroyWindowFramebuffer(_THIS, SDL_Window *window) WINDATA *pWinData = (WINDATA *)window->driverdata; debug_os2("Enter"); - if (pWinData != NULL && pWinData->pVOData != NULL) + if (pWinData && pWinData->pVOData) pWinData->pOutput->VideoBufFree(pWinData->pVOData); } @@ -1310,14 +1310,14 @@ static int OS2_CreateWindowFramebuffer(_THIS, SDL_Window *window, ULONG ulWidth, ulHeight; debug_os2("Enter"); - if (pSDLDisplay == NULL) { + if (!pSDLDisplay) { debug_os2("No display for the window"); return -1; } pSDLDisplayMode = &pSDLDisplay->current_mode; pModeData = (MODEDATA *)pSDLDisplayMode->driverdata; - if (pModeData == NULL) + if (!pModeData) return SDL_SetError("No mode data for the display"); SDL_GetWindowSize(window, (int *)&ulWidth, (int *)&ulHeight); @@ -1326,7 +1326,7 @@ static int OS2_CreateWindowFramebuffer(_THIS, SDL_Window *window, *pixels = pWinData->pOutput->VideoBufAlloc( pWinData->pVOData, ulWidth, ulHeight, pModeData->ulDepth, pModeData->fccColorEncoding, (PULONG)pitch); - if (*pixels == NULL) + if (!*pixels) return -1; *format = pSDLDisplayMode->format; @@ -1353,13 +1353,13 @@ static int OS2_SetClipboardText(_THIS, const char *text) { SDL_VideoData *pVData = (SDL_VideoData *)_this->driverdata; PSZ pszClipboard; - PSZ pszText = (text == NULL)? NULL : OS2_UTF8ToSys(text); + PSZ pszText = (!text)? NULL : OS2_UTF8ToSys(text); ULONG cbText; ULONG ulRC; BOOL fSuccess; debug_os2("Enter"); - if (pszText == NULL) + if (!pszText) return -1; cbText = SDL_strlen(pszText) + 1; @@ -1408,7 +1408,7 @@ static char *OS2_GetClipboardText(_THIS) WinCloseClipbrd(pVData->hab); } - return (pszClipboard == NULL) ? SDL_strdup("") : pszClipboard; + return (!pszClipboard) ? SDL_strdup("") : pszClipboard; } static SDL_bool OS2_HasClipboardText(_THIS) @@ -1438,7 +1438,7 @@ static int OS2_VideoInit(_THIS) /* Create SDL video driver private data */ pVData = SDL_calloc(1, sizeof(SDL_VideoData)); - if (pVData == NULL) + if (!pVData) return SDL_OutOfMemory(); /* Change process type code for use Win* API from VIO session */ @@ -1493,7 +1493,7 @@ static int OS2_VideoInit(_THIS) stSDLDisplayMode.driverdata = NULL; pModeData = SDL_malloc(sizeof(MODEDATA)); - if (pModeData != NULL) { + if (pModeData) { pModeData->ulDepth = stVOInfo.ulBPP; pModeData->fccColorEncoding = stVOInfo.fccColorEncoding; pModeData->ulScanLineBytes = stVOInfo.ulScanLineSize; @@ -1507,7 +1507,7 @@ static int OS2_VideoInit(_THIS) stSDLDisplay.num_display_modes = 0; pDisplayData = SDL_malloc(sizeof(DISPLAYDATA)); - if (pDisplayData != NULL) { + if (pDisplayData) { HPS hps = WinGetPS(HWND_DESKTOP); HDC hdc = GpiQueryDevice(hps); @@ -1566,14 +1566,14 @@ static int OS2_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, DISPLAYDATA *pDisplayData = (DISPLAYDATA *)display->driverdata; debug_os2("Enter"); - if (pDisplayData == NULL) + if (!pDisplayData) return -1; - if (ddpi != NULL) + if (ddpi) *hdpi = pDisplayData->ulDPIDiag; - if (hdpi != NULL) + if (hdpi) *hdpi = pDisplayData->ulDPIHor; - if (vdpi != NULL) + if (vdpi) *vdpi = pDisplayData->ulDPIVer; return 0; diff --git a/src/video/os2/SDL_os2vman.c b/src/video/os2/SDL_os2vman.c index 00ae4bca2..ee0b5087b 100644 --- a/src/video/os2/SDL_os2vman.c +++ b/src/video/os2/SDL_os2vman.c @@ -143,7 +143,7 @@ static PRECTL _getRectlArray(PVODATA pVOData, ULONG cRects) return pVOData->pRectl; pRectl = SDL_realloc(pVOData->pRectl, cRects * sizeof(RECTL)); - if (pRectl == NULL) + if (!pRectl) return NULL; pVOData->pRectl = pRectl; @@ -159,7 +159,7 @@ static PBLTRECT _getBltRectArray(PVODATA pVOData, ULONG cRects) return pVOData->pBltRect; pBltRect = SDL_realloc(pVOData->pBltRect, cRects * sizeof(BLTRECT)); - if (pBltRect == NULL) + if (!pBltRect) return NULL; pVOData->pBltRect = pBltRect; @@ -200,7 +200,7 @@ static PVODATA voOpen(void) return NULL; pVOData = SDL_calloc(1, sizeof(VODATA)); - if (pVOData == NULL) { + if (!pVOData) { SDL_OutOfMemory(); return NULL; } @@ -210,10 +210,10 @@ static PVODATA voOpen(void) static VOID voClose(PVODATA pVOData) { - if (pVOData->pRectl != NULL) + if (pVOData->pRectl) SDL_free(pVOData->pRectl); - if (pVOData->pBltRect != NULL) + if (pVOData->pBltRect) SDL_free(pVOData->pBltRect); voVideoBufFree(pVOData); @@ -253,7 +253,7 @@ static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd, WinQueryWindowRect(hwnd, &pVOData->rectlWin); WinMapWindowPoints(hwnd, HWND_DESKTOP, (PPOINTL)&pVOData->rectlWin, 2); - if (pSDLDisplayMode != NULL) { + if (pSDLDisplayMode) { pVOData->ulScreenHeight = pSDLDisplayMode->h; pVOData->ulScreenBytesPerLine = ((MODEDATA *)pSDLDisplayMode->driverdata)->ulScanLineBytes; @@ -302,7 +302,7 @@ static VOID voVideoBufFree(PVODATA pVOData) { ULONG ulRC; - if (pVOData->pBuffer == NULL) + if (!pVOData->pBuffer) return; ulRC = DosFreeMem(pVOData->pBuffer); @@ -329,7 +329,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, BITBLTINFO sBitbltInfo; ULONG ulIdx; - if (pVOData->pBuffer == NULL) + if (!pVOData->pBuffer) return FALSE; if (pVOData->hrgnVisible == NULLHANDLE) @@ -366,7 +366,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, /* Make list of destination rectangles (prectlDst) list from the source * list (prectl). */ prectlDst = _getRectlArray(pVOData, cSDLRects); - if (prectlDst == NULL) { + if (!prectlDst) { debug_os2("Not enough memory"); return FALSE; } @@ -400,7 +400,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, } /* We don't need prectlDst, use it again to store update regions */ prectlDst = _getRectlArray(pVOData, rgnCtl.crcReturned); - if (prectlDst == NULL) { + if (!prectlDst) { debug_os2("Not enough memory"); GpiDestroyRegion(hps, hrgnUpdate); WinReleasePS(hps); @@ -418,7 +418,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, /* Make lists for blitting from update regions */ pbrDst = _getBltRectArray(pVOData, cSDLRects); - if (pbrDst == NULL) { + if (!pbrDst) { debug_os2("Not enough memory"); return FALSE; } diff --git a/src/video/pandora/SDL_pandora.c b/src/video/pandora/SDL_pandora.c index 16debcb13..5b1498aa1 100644 --- a/src/video/pandora/SDL_pandora.c +++ b/src/video/pandora/SDL_pandora.c @@ -48,7 +48,7 @@ static int PND_available(void) static void PND_destroy(SDL_VideoDevice * device) { - if (device->driverdata != NULL) { + if (device->driverdata) { SDL_free(device->driverdata); device->driverdata = NULL; } @@ -70,14 +70,14 @@ static SDL_VideoDevice *PND_create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal Pandora specific data */ phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -196,7 +196,7 @@ int PND_createwindow(_THIS, SDL_Window * window) /* Allocate window internal data */ wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } @@ -297,15 +297,15 @@ SDL_bool PND_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *i int PND_gl_loadlibrary(_THIS, const char *path) { /* Check if OpenGL ES library is specified for GF driver */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGLES_LIBRARY"); } } /* Check if default library loading requested */ - if (path == NULL) { + if (!path) { /* Already linked with GF library which provides egl* subset of */ /* functions, use Common profile of OpenGL ES library by default */ #ifdef WIZ_GLES_LITE @@ -336,7 +336,7 @@ void *PND_gl_getprocaddres(_THIS, const char *proc) /* Try to get function address through the egl interface */ function_address = eglGetProcAddress(proc); - if (function_address != NULL) { + if (function_address) { return function_address; } @@ -344,7 +344,7 @@ void *PND_gl_getprocaddres(_THIS, const char *proc) if (_this->gl_config.dll_handle) { function_address = SDL_LoadFunction(_this->gl_config.dll_handle, proc); - if (function_address != NULL) { + if (function_address) { return function_address; } } @@ -586,7 +586,7 @@ SDL_GLContext PND_gl_createcontext(_THIS, SDL_Window * window) } #ifdef WIZ_GLES_LITE - if( !hNativeWnd ) { + if(!hNativeWnd) { hNativeWnd = (NativeWindowType)SDL_malloc(16*1024); if(!hNativeWnd) @@ -683,7 +683,7 @@ int PND_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context) return SDL_SetError("PND: GF initialization failed, no OpenGL ES support"); } - if ((window == NULL) && (context == NULL)) { + if ((!window) && (!context)) { status = eglMakeCurrent(phdata->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); diff --git a/src/video/ps2/SDL_ps2video.c b/src/video/ps2/SDL_ps2video.c index 490ea259e..9edca12bb 100644 --- a/src/video/ps2/SDL_ps2video.c +++ b/src/video/ps2/SDL_ps2video.c @@ -107,7 +107,7 @@ static SDL_VideoDevice *PS2_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index 676196c01..110ca7675 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -46,7 +46,7 @@ static void PSP_Destroy(SDL_VideoDevice *device) { /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ - if (device->driverdata != NULL) { + if (device->driverdata) { device->driverdata = NULL; } } @@ -59,21 +59,21 @@ static SDL_VideoDevice *PSP_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal PSP specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; } gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); - if (gldata == NULL) { + if (!gldata) { SDL_OutOfMemory(); SDL_free(device); SDL_free(phdata); @@ -202,7 +202,7 @@ int PSP_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } diff --git a/src/video/qnx/gl.c b/src/video/qnx/gl.c index cf487ed46..e6e999a60 100644 --- a/src/video/qnx/gl.c +++ b/src/video/qnx/gl.c @@ -84,7 +84,7 @@ int glGetConfig(EGLConfig *pconf, int *pformat) // Allocate enough memory for all configurations. egl_configs = SDL_malloc(egl_num_configs * sizeof(*egl_configs)); - if (egl_configs == NULL) { + if (!egl_configs) { return -1; } diff --git a/src/video/qnx/video.c b/src/video/qnx/video.c index cecd717d5..621236b9e 100644 --- a/src/video/qnx/video.c +++ b/src/video/qnx/video.c @@ -74,7 +74,7 @@ static int createWindow(_THIS, SDL_Window *window) int usage; impl = SDL_calloc(1, sizeof(*impl)); - if (impl == NULL) { + if (!impl) { return -1; } @@ -311,7 +311,7 @@ static SDL_VideoDevice *createDevice(int devindex) SDL_VideoDevice *device; device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { return NULL; } diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index 2d9b884d9..b14235d0d 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -70,12 +70,12 @@ static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) SDL_assert(surface->pitch == surface->w * 4); cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); - if (cursor == NULL) { + if (!cursor) { SDL_OutOfMemory(); return NULL; } curdata = (RPI_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -119,12 +119,12 @@ static int RPI_ShowCursor(SDL_Cursor *cursor) const char *env; mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return -1; } if (cursor != global_cursor) { - if (global_cursor != NULL) { + if (global_cursor) { curdata = (RPI_CursorData *)global_cursor->driverdata; if (curdata && curdata->element > DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); @@ -139,26 +139,26 @@ static int RPI_ShowCursor(SDL_Cursor *cursor) global_cursor = cursor; } - if (cursor == NULL) { + if (!cursor) { return 0; } curdata = (RPI_CursorData *)cursor->driverdata; - if (curdata == NULL) { + if (!curdata) { return -1; } - if (mouse->focus == NULL) { + if (!mouse->focus) { return -1; } display = SDL_GetDisplayForWindow(mouse->focus); - if (display == NULL) { + if (!display) { return -1; } data = (SDL_DisplayData *)display->driverdata; - if (data == NULL) { + if (!data) { return -1; } @@ -199,10 +199,10 @@ static void RPI_FreeCursor(SDL_Cursor *cursor) DISPMANX_UPDATE_HANDLE_T update; RPI_CursorData *curdata; - if (cursor != NULL) { + if (cursor) { curdata = (RPI_CursorData *)cursor->driverdata; - if (curdata != NULL) { + if (curdata) { if (curdata->element != DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); SDL_assert(update); @@ -242,7 +242,7 @@ static int RPI_WarpMouseGlobal(int x, int y) VC_RECT_T src_rect; SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { return 0; } @@ -300,7 +300,7 @@ static int RPI_WarpMouseGlobalGraphicOnly(int x, int y) VC_RECT_T src_rect; SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { return 0; } diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index f56e23d95..a87570334 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -77,14 +77,14 @@ static SDL_VideoDevice *RPI_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -179,7 +179,7 @@ static void AddDispManXDisplay(const int display_id) /* Allocate display internal data */ data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (data == NULL) { + if (!data) { vc_dispmanx_display_close(handle); return; /* oh well */ } @@ -256,7 +256,7 @@ int RPI_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } display = SDL_GetDisplayForWindow(window); diff --git a/src/video/riscos/SDL_riscosframebuffer.c b/src/video/riscos/SDL_riscosframebuffer.c index 36ce340ef..64f2ce639 100644 --- a/src/video/riscos/SDL_riscosframebuffer.c +++ b/src/video/riscos/SDL_riscosframebuffer.c @@ -80,7 +80,7 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo regs.r[5] = h; regs.r[6] = sprite_mode; error = _kernel_swi(OS_SpriteOp, ®s, ®s); - if (error != NULL) { + if (error) { SDL_free(driverdata->fb_area); return SDL_SetError("Unable to create sprite: %s (%i)", error->errmess, error->errnum); } @@ -106,7 +106,7 @@ int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *re regs.r[6] = 0; regs.r[7] = 0; error = _kernel_swi(OS_SpriteOp, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("OS_SpriteOp 52 failed: %s (%i)", error->errmess, error->errnum); } diff --git a/src/video/riscos/SDL_riscosmodes.c b/src/video/riscos/SDL_riscosmodes.c index 35a42e38e..2a6d6b3f6 100644 --- a/src/video/riscos/SDL_riscosmodes.c +++ b/src/video/riscos/SDL_riscosmodes.c @@ -166,7 +166,7 @@ static void *convert_mode_block(const int *block) } dst = SDL_malloc(40); - if (dst == NULL) { + if (!dst) { return NULL; } @@ -207,7 +207,7 @@ int RISCOS_InitModes(_THIS) regs.r[0] = 1; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("Unable to retrieve the current screen mode: %s (%i)", error->errmess, error->errnum); } @@ -237,13 +237,13 @@ void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) regs.r[6] = 0; regs.r[7] = 0; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); return; } block = SDL_malloc(-regs.r[7]); - if (block == NULL) { + if (!block) { SDL_OutOfMemory(); return; } @@ -251,7 +251,7 @@ void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) regs.r[6] = (int)block; regs.r[7] = -regs.r[7]; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { SDL_free(block); SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); return; @@ -290,7 +290,7 @@ int RISCOS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mod regs.r[0] = 0; regs.r[1] = (int)mode->driverdata; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum); } diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 05c7d925b..29a818f64 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -56,14 +56,14 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } /* Initialize internal data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; diff --git a/src/video/riscos/SDL_riscoswindow.c b/src/video/riscos/SDL_riscoswindow.c index cf8e71dfa..6a1b89421 100644 --- a/src/video/riscos/SDL_riscoswindow.c +++ b/src/video/riscos/SDL_riscoswindow.c @@ -36,7 +36,7 @@ int RISCOS_CreateWindow(_THIS, SDL_Window *window) SDL_WindowData *driverdata; driverdata = (SDL_WindowData *)SDL_calloc(1, sizeof(*driverdata)); - if (driverdata == NULL) { + if (!driverdata) { return SDL_OutOfMemory(); } driverdata->window = window; @@ -54,7 +54,7 @@ void RISCOS_DestroyWindow(_THIS, SDL_Window *window) { SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata; - if (driverdata == NULL) { + if (!driverdata) { return; } diff --git a/src/video/vita/SDL_vitaframebuffer.c b/src/video/vita/SDL_vitaframebuffer.c index 43b657bd3..e58ba333a 100644 --- a/src/video/vita/SDL_vitaframebuffer.c +++ b/src/video/vita/SDL_vitaframebuffer.c @@ -103,7 +103,7 @@ void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/vita/SDL_vitagl_pvr.c b/src/video/vita/SDL_vitagl_pvr.c index ea920ad5a..140c1d9f0 100644 --- a/src/video/vita/SDL_vitagl_pvr.c +++ b/src/video/vita/SDL_vitagl_pvr.c @@ -53,8 +53,8 @@ int VITA_GL_LoadLibrary(_THIS, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (skip_init == NULL) { // we don't care about actual value - if (override != NULL) { + if (!skip_init) { // we don't care about actual value + if (override) { default_path = override; } diff --git a/src/video/vita/SDL_vitagles_pvr.c b/src/video/vita/SDL_vitagles_pvr.c index 711d1ddd3..bf95abbec 100644 --- a/src/video/vita/SDL_vitagles_pvr.c +++ b/src/video/vita/SDL_vitagles_pvr.c @@ -42,9 +42,9 @@ int VITA_GLES_LoadLibrary(_THIS, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (skip_init == NULL) { // we don't care about actual value + if (!skip_init) { // we don't care about actual value - if (override != NULL) { + if (override) { default_path = override; } diff --git a/src/video/vita/SDL_vitakeyboard.c b/src/video/vita/SDL_vitakeyboard.c index 56be9e6fa..868985014 100644 --- a/src/video/vita/SDL_vitakeyboard.c +++ b/src/video/vita/SDL_vitakeyboard.c @@ -50,7 +50,7 @@ void VITA_InitKeyboard(void) void VITA_PollKeyboard(void) { // We skip polling keyboard if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/src/video/vita/SDL_vitamouse.c b/src/video/vita/SDL_vitamouse.c index b14690fc2..edec0bc50 100644 --- a/src/video/vita/SDL_vitamouse.c +++ b/src/video/vita/SDL_vitamouse.c @@ -45,7 +45,7 @@ void VITA_InitMouse(void) void VITA_PollMouse(void) { // We skip polling mouse if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c index 87939b322..7f22b855e 100644 --- a/src/video/vita/SDL_vitatouch.c +++ b/src/video/vita/SDL_vitatouch.c @@ -86,7 +86,7 @@ void VITA_PollTouch(void) int port; // We skip polling touch if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index 9e823996e..0031e8eb3 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -76,14 +76,14 @@ static SDL_VideoDevice *VITA_Create() #endif /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal VITA specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -91,7 +91,7 @@ static SDL_VideoDevice *VITA_Create() #if SDL_VIDEO_VITA_PIB gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); - if (gldata == NULL) { + if (!gldata) { SDL_OutOfMemory(); SDL_free(device); SDL_free(phdata); @@ -258,7 +258,7 @@ int VITA_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } @@ -266,7 +266,7 @@ int VITA_CreateWindow(_THIS, SDL_Window *window) window->driverdata = wdata; // Vita can only have one window - if (Vita_Window != NULL) { + if (Vita_Window) { return SDL_SetError("Only one window supported"); } diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index b74391d4b..b1e6127ba 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -41,7 +41,7 @@ static void VIVANTE_Destroy(SDL_VideoDevice *device) { - if (device->driverdata != NULL) { + if (device->driverdata) { SDL_free(device->driverdata); device->driverdata = NULL; } @@ -54,14 +54,14 @@ static SDL_VideoDevice *VIVANTE_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -133,7 +133,7 @@ static int VIVANTE_AddVideoDisplays(_THIS) unsigned long pixels = 0; data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -265,7 +265,7 @@ int VIVANTE_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } diff --git a/src/video/vivante/SDL_vivantevulkan.c b/src/video/vivante/SDL_vivantevulkan.c index 8e4c867c6..3183721c1 100644 --- a/src/video/vivante/SDL_vivantevulkan.c +++ b/src/video/vivante/SDL_vivantevulkan.c @@ -47,10 +47,10 @@ int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { /* If no path set, try Vivante fb vulkan driver explicitly */ path = "libvulkan-fb.so"; _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -84,7 +84,7 @@ int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/wayland/SDL_waylandclipboard.c b/src/video/wayland/SDL_waylandclipboard.c index bf4dca44a..d643a51ef 100644 --- a/src/video/wayland/SDL_waylandclipboard.c +++ b/src/video/wayland/SDL_waylandclipboard.c @@ -33,11 +33,11 @@ int Wayland_SetClipboardText(_THIS, const char *text) int status = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { status = SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; if (text[0] != '\0') { SDL_WaylandDataSource *source = Wayland_data_source_create(_this); @@ -64,11 +64,11 @@ int Wayland_SetPrimarySelectionText(_THIS, const char *text) int status = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { status = SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; if (text[0] != '\0') { SDL_WaylandPrimarySelectionSource *source = Wayland_primary_selection_source_create(_this); @@ -97,11 +97,11 @@ char *Wayland_GetClipboardText(_THIS) char *text = NULL; size_t length = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; /* Prefer own selection, if not canceled */ if (Wayland_data_source_has_mime( @@ -116,7 +116,7 @@ char *Wayland_GetClipboardText(_THIS) } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } @@ -131,11 +131,11 @@ char *Wayland_GetPrimarySelectionText(_THIS) char *text = NULL; size_t length = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; /* Prefer own selection, if not canceled */ if (Wayland_primary_selection_source_has_mime( @@ -150,7 +150,7 @@ char *Wayland_GetPrimarySelectionText(_THIS) } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } @@ -163,11 +163,11 @@ SDL_bool Wayland_HasClipboardText(_THIS) SDL_WaylandDataDevice *data_device = NULL; SDL_bool result = SDL_FALSE; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; result = result || Wayland_data_source_has_mime(data_device->selection_source, TEXT_MIME) || @@ -183,11 +183,11 @@ SDL_bool Wayland_HasPrimarySelectionText(_THIS) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; SDL_bool result = SDL_FALSE; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; result = result || Wayland_primary_selection_source_has_mime( diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index 3d580ce6c..d430bdbce 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -115,13 +115,13 @@ static ssize_t read_pipe(int fd, void **buffer, size_t *total_length, SDL_bool n new_buffer_length = *total_length; } - if (*buffer == NULL) { + if (!*buffer) { output_buffer = SDL_malloc(new_buffer_length); } else { output_buffer = SDL_realloc(*buffer, new_buffer_length); } - if (output_buffer == NULL) { + if (!output_buffer) { bytes_read = SDL_OutOfMemory(); } else { SDL_memcpy((Uint8 *)output_buffer + pos, temp, bytes_read); @@ -186,9 +186,9 @@ static int mime_data_list_add(struct wl_list *list, SDL_MimeDataList *mime_data = NULL; void *internal_buffer = NULL; - if (buffer != NULL) { + if (buffer) { internal_buffer = SDL_malloc(length); - if (internal_buffer == NULL) { + if (!internal_buffer) { return SDL_OutOfMemory(); } SDL_memcpy(internal_buffer, buffer, length); @@ -196,16 +196,16 @@ static int mime_data_list_add(struct wl_list *list, mime_data = mime_data_list_find(list, mime_type); - if (mime_data == NULL) { + if (!mime_data) { mime_data = SDL_calloc(1, sizeof(*mime_data)); - if (mime_data == NULL) { + if (!mime_data) { status = SDL_OutOfMemory(); } else { WAYLAND_wl_list_insert(list, &(mime_data->link)); mime_type_length = SDL_strlen(mime_type) + 1; mime_data->mime_type = SDL_malloc(mime_type_length); - if (mime_data->mime_type == NULL) { + if (!mime_data->mime_type) { status = SDL_OutOfMemory(); } else { SDL_memcpy(mime_data->mime_type, mime_type, mime_type_length); @@ -213,8 +213,8 @@ static int mime_data_list_add(struct wl_list *list, } } - if (mime_data != NULL && buffer != NULL && length > 0) { - if (mime_data->data != NULL) { + if (mime_data && buffer && length > 0) { + if (mime_data->data) { SDL_free(mime_data->data); } mime_data->data = internal_buffer; @@ -233,10 +233,10 @@ static void mime_data_list_free(struct wl_list *list) wl_list_for_each_safe(mime_data, next, list, link) { - if (mime_data->data != NULL) { + if (mime_data->data) { SDL_free(mime_data->data); } - if (mime_data->mime_type != NULL) { + if (mime_data->mime_type) { SDL_free(mime_data->mime_type); } SDL_free(mime_data); @@ -248,7 +248,7 @@ static ssize_t Wayland_source_send(SDL_MimeDataList *mime_data, const char *mime size_t written_bytes = 0; ssize_t status = 0; - if (mime_data == NULL || mime_data->data == NULL) { + if (!mime_data || !mime_data->data) { status = SDL_SetError("Invalid mime type"); close(fd); } else { @@ -306,7 +306,7 @@ SDL_bool Wayland_data_source_has_mime(SDL_WaylandDataSource *source, { SDL_bool found = SDL_FALSE; - if (source != NULL) { + if (source) { found = mime_data_list_find(&source->mimes, mime_type) != NULL; } return found; @@ -317,7 +317,7 @@ SDL_bool Wayland_primary_selection_source_has_mime(SDL_WaylandPrimarySelectionSo { SDL_bool found = SDL_FALSE; - if (source != NULL) { + if (source) { found = mime_data_list_find(&source->mimes, mime_type) != NULL; } return found; @@ -329,14 +329,14 @@ static void *Wayland_source_get_data(SDL_MimeDataList *mime_data, { void *buffer = NULL; - if (mime_data != NULL && mime_data->length > 0) { + if (mime_data && mime_data->length > 0) { size_t buffer_length = mime_data->length; if (null_terminate == SDL_TRUE) { ++buffer_length; } buffer = SDL_malloc(buffer_length); - if (buffer == NULL) { + if (!buffer) { *length = SDL_OutOfMemory(); } else { *length = mime_data->length; @@ -358,7 +358,7 @@ void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, void *buffer = NULL; *length = 0; - if (source == NULL) { + if (!source) { SDL_SetError("Invalid data source"); } else { mime_data = mime_data_list_find(&source->mimes, mime_type); @@ -376,7 +376,7 @@ void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSourc void *buffer = NULL; *length = 0; - if (source == NULL) { + if (!source) { SDL_SetError("Invalid primary selection source"); } else { mime_data = mime_data_list_find(&source->mimes, mime_type); @@ -388,7 +388,7 @@ void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSourc void Wayland_data_source_destroy(SDL_WaylandDataSource *source) { - if (source != NULL) { + if (source) { SDL_WaylandDataDevice *data_device = (SDL_WaylandDataDevice *)source->data_device; if (data_device && (data_device->selection_source == source)) { data_device->selection_source = NULL; @@ -401,7 +401,7 @@ void Wayland_data_source_destroy(SDL_WaylandDataSource *source) void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source) { - if (source != NULL) { + if (source) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = (SDL_WaylandPrimarySelectionDevice *)source->primary_selection_device; if (primary_selection_device && (primary_selection_device->selection_source == source)) { primary_selection_device->selection_source = NULL; @@ -422,12 +422,12 @@ void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, void *buffer = NULL; *length = 0; - if (offer == NULL) { + if (!offer) { SDL_SetError("Invalid data offer"); return NULL; } data_device = offer->data_device; - if (data_device == NULL) { + if (!data_device) { SDL_SetError("Data device not initialized"); } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); @@ -456,12 +456,12 @@ void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer * void *buffer = NULL; *length = 0; - if (offer == NULL) { + if (!offer) { SDL_SetError("Invalid data offer"); return NULL; } primary_selection_device = offer->primary_selection_device; - if (primary_selection_device == NULL) { + if (!primary_selection_device) { SDL_SetError("Primary selection device not initialized"); } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); @@ -497,7 +497,7 @@ SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, { SDL_bool found = SDL_FALSE; - if (offer != NULL) { + if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; } return found; @@ -508,7 +508,7 @@ SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOff { SDL_bool found = SDL_FALSE; - if (offer != NULL) { + if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; } return found; @@ -516,7 +516,7 @@ SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOff void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) { - if (offer != NULL) { + if (offer) { wl_data_offer_destroy(offer->offer); mime_data_list_free(&offer->mimes); SDL_free(offer); @@ -525,7 +525,7 @@ void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer) { - if (offer != NULL) { + if (offer) { zwp_primary_selection_offer_v1_destroy(offer->offer); mime_data_list_free(&offer->mimes); SDL_free(offer); @@ -536,9 +536,9 @@ int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device) { int status = 0; - if (data_device == NULL || data_device->data_device == NULL) { + if (!data_device || !data_device->data_device) { status = SDL_SetError("Invalid Data Device"); - } else if (data_device->selection_source != NULL) { + } else if (data_device->selection_source) { wl_data_device_set_selection(data_device->data_device, NULL, 0); Wayland_data_source_destroy(data_device->selection_source); data_device->selection_source = NULL; @@ -550,9 +550,9 @@ int Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelection { int status = 0; - if (primary_selection_device == NULL || primary_selection_device->primary_selection_device == NULL) { + if (!primary_selection_device || !primary_selection_device->primary_selection_device) { status = SDL_SetError("Invalid Primary Selection Device"); - } else if (primary_selection_device->selection_source != NULL) { + } else if (primary_selection_device->selection_source) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, NULL, 0); Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); @@ -568,9 +568,9 @@ int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, size_t num_offers = 0; size_t index = 0; - if (data_device == NULL) { + if (!data_device) { status = SDL_SetError("Invalid Data Device"); - } else if (source == NULL) { + } else if (!source) { status = SDL_SetError("Invalid source"); } else { SDL_MimeDataList *mime_data = NULL; @@ -601,7 +601,7 @@ int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, source->source, data_device->selection_serial); } - if (data_device->selection_source != NULL) { + if (data_device->selection_source) { Wayland_data_source_destroy(data_device->selection_source); } data_device->selection_source = source; @@ -619,9 +619,9 @@ int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDe size_t num_offers = 0; size_t index = 0; - if (primary_selection_device == NULL) { + if (!primary_selection_device) { status = SDL_SetError("Invalid Primary Selection Device"); - } else if (source == NULL) { + } else if (!source) { status = SDL_SetError("Invalid source"); } else { SDL_MimeDataList *mime_data = NULL; @@ -652,7 +652,7 @@ int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDe source->source, primary_selection_device->selection_serial); } - if (primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_source) { Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); } primary_selection_device->selection_source = source; @@ -667,11 +667,11 @@ int Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, uint32_t serial) { int status = -1; - if (data_device != NULL) { + if (data_device) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (data_device->selection_serial == 0 && data_device->selection_source != NULL) { + if (data_device->selection_serial == 0 && data_device->selection_source) { wl_data_device_set_selection(data_device->data_device, data_device->selection_source->source, data_device->selection_serial); @@ -687,11 +687,11 @@ int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevic uint32_t serial) { int status = -1; - if (primary_selection_device != NULL) { + if (primary_selection_device) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, primary_selection_device->selection_source->source, primary_selection_device->selection_serial); diff --git a/src/video/wayland/SDL_waylanddyn.c b/src/video/wayland/SDL_waylanddyn.c index 8ebeaede2..4084a371f 100644 --- a/src/video/wayland/SDL_waylanddyn.c +++ b/src/video/wayland/SDL_waylanddyn.c @@ -59,23 +59,23 @@ static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool requir void *fn = NULL; waylanddynlib *dynlib; for (dynlib = waylandlibs; dynlib->libname; dynlib++) { - if (dynlib->lib != NULL) { + if (dynlib->lib) { fn = SDL_LoadFunction(dynlib->lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_WAYLAND - if (fn != NULL) { + if (fn) { SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, dynlib->libname, fn); } else { SDL_Log("WAYLAND: Symbol '%s' NOT FOUND!\n", fnname); } #endif - if (fn == NULL && required) { + if (!fn && required) { *pHasModule = 0; /* kill this module. */ } @@ -115,7 +115,7 @@ void SDL_WAYLAND_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { - if (waylandlibs[i].lib != NULL) { + if (waylandlibs[i].lib) { SDL_UnloadObject(waylandlibs[i].lib); waylandlibs[i].lib = NULL; } @@ -136,7 +136,7 @@ int SDL_WAYLAND_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { - if (waylandlibs[i].libname != NULL) { + if (waylandlibs[i].libname) { waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname); } } diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 628722680..276963837 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -269,7 +269,7 @@ int Wayland_WaitEventTimeout(_THIS, int timeout) WAYLAND_wl_display_flush(d->display); #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + if (!d->text_input_manager && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_IME_PumpEvents(); } #endif @@ -338,7 +338,7 @@ void Wayland_PumpEvents(_THIS) int err; #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + if (!d->text_input_manager && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_IME_PumpEvents(); } #endif @@ -410,7 +410,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer, struct SDL_WaylandInput *input = data; SDL_WindowData *window; - if (surface == NULL) { + if (!surface) { /* enter event for a window we've just destroyed */ return; } @@ -448,7 +448,7 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer, { struct SDL_WaylandInput *input = data; - if (surface == NULL || !SDL_WAYLAND_own_surface(surface)) { + if (!surface || !SDL_WAYLAND_own_surface(surface)) { return; } @@ -947,7 +947,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, char *map_str; const char *locale; - if (data == NULL) { + if (!data) { close(fd); return; } @@ -1019,11 +1019,11 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, /* Look up the preferred locale, falling back to "C" as default */ locale = SDL_getenv("LC_ALL"); - if (locale == NULL) { + if (!locale) { locale = SDL_getenv("LC_CTYPE"); - if (locale == NULL) { + if (!locale) { locale = SDL_getenv("LANG"); - if (locale == NULL) { + if (!locale) { locale = "C"; } } @@ -1087,7 +1087,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, SDL_WindowData *window; uint32_t *key; - if (surface == NULL) { + if (!surface) { /* enter event for a window we've just destroyed */ return; } @@ -1129,7 +1129,7 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, struct SDL_WaylandInput *input = data; SDL_WindowData *window; - if (surface == NULL || !SDL_WAYLAND_own_surface(surface)) { + if (!surface || !SDL_WAYLAND_own_surface(surface)) { return; } @@ -1157,7 +1157,7 @@ static SDL_bool keyboard_input_get_text(char text[8], const struct SDL_WaylandIn const xkb_keysym_t *syms; xkb_keysym_t sym; - if (window == NULL || window->keyboard_device != input || !input->xkb.state) { + if (!window || window->keyboard_device != input || !input->xkb.state) { return SDL_FALSE; } @@ -1427,21 +1427,21 @@ SDL_WaylandDataSource *Wayland_data_source_create(_THIS) SDL_VideoData *driver_data = NULL; struct wl_data_source *id = NULL; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { driver_data = _this->driverdata; - if (driver_data->data_device_manager != NULL) { + if (driver_data->data_device_manager) { id = wl_data_device_manager_create_data_source( driver_data->data_device_manager); } - if (id == NULL) { + if (!id) { SDL_SetError("Wayland unable to create data source"); } else { data_source = SDL_calloc(1, sizeof(*data_source)); - if (data_source == NULL) { + if (!data_source) { SDL_OutOfMemory(); wl_data_source_destroy(id); } else { @@ -1462,21 +1462,21 @@ SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(_THIS SDL_VideoData *driver_data = NULL; struct zwp_primary_selection_source_v1 *id = NULL; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { driver_data = _this->driverdata; - if (driver_data->primary_selection_device_manager != NULL) { + if (driver_data->primary_selection_device_manager) { id = zwp_primary_selection_device_manager_v1_create_source( driver_data->primary_selection_device_manager); } - if (id == NULL) { + if (!id) { SDL_SetError("Wayland unable to create primary selection source"); } else { primary_selection_source = SDL_calloc(1, sizeof(*primary_selection_source)); - if (primary_selection_source == NULL) { + if (!primary_selection_source) { SDL_OutOfMemory(); zwp_primary_selection_source_v1_destroy(id); } else { @@ -1530,7 +1530,7 @@ static void data_device_handle_data_offer(void *data, struct wl_data_device *wl_ SDL_WaylandDataOffer *data_offer = NULL; data_offer = SDL_calloc(1, sizeof(*data_offer)); - if (data_offer == NULL) { + if (!data_offer) { SDL_OutOfMemory(); } else { data_offer->offer = id; @@ -1551,7 +1551,7 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ data_device->drag_serial = serial; - if (id != NULL) { + if (id) { data_device->drag_offer = wl_data_offer_get_user_data(id); /* TODO: SDL Support more mime types */ @@ -1592,7 +1592,7 @@ static void data_device_handle_leave(void *data, struct wl_data_device *wl_data_ { SDL_WaylandDataDevice *data_device = data; - if (data_device->drag_offer != NULL) { + if (data_device->drag_offer) { Wayland_data_offer_destroy(data_device->drag_offer); data_device->drag_offer = NULL; } @@ -1622,7 +1622,7 @@ static int Wayland_URIDecode(char *buf, int len) { int ri, wi, di; char decode = '\0'; - if (buf == NULL || len < 0) { + if (!buf || len < 0) { errno = EINVAL; return -1; } @@ -1700,7 +1700,7 @@ static char *Wayland_URIToLocal(char *uri) /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { char *hostname_end = SDL_strchr(uri + 1, '/'); - if (hostname_end != NULL) { + if (hostname_end) { char hostname[257]; if (gethostname(hostname, 255) == 0) { hostname[256] = '\0'; @@ -1728,7 +1728,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d { SDL_WaylandDataDevice *data_device = data; - if (data_device->drag_offer != NULL) { + if (data_device->drag_offer) { /* TODO: SDL Support more mime types */ size_t length; SDL_bool drop_handled = SDL_FALSE; @@ -1761,13 +1761,13 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d * non paths that are not visible to the application */ if (!drop_handled && Wayland_data_offer_has_mime( - data_device->drag_offer, FILE_MIME)) { + data_device->drag_offer, FILE_MIME)) { void *buffer = Wayland_data_offer_receive(data_device->drag_offer, &length, FILE_MIME, SDL_TRUE); if (buffer) { char *saveptr = NULL; char *token = SDL_strtokr((char *)buffer, "\r\n", &saveptr); - while (token != NULL) { + while (token) { char *fn = Wayland_URIToLocal(token); if (fn) { SDL_SendDropFile(data_device->dnd_window, fn); @@ -1795,7 +1795,7 @@ static void data_device_handle_selection(void *data, struct wl_data_device *wl_d SDL_WaylandDataDevice *data_device = data; SDL_WaylandDataOffer *offer = NULL; - if (id != NULL) { + if (id) { offer = wl_data_offer_get_user_data(id); } @@ -1822,7 +1822,7 @@ static void primary_selection_device_handle_offer(void *data, struct zwp_primary SDL_WaylandPrimarySelectionOffer *primary_selection_offer = NULL; primary_selection_offer = SDL_calloc(1, sizeof(*primary_selection_offer)); - if (primary_selection_offer == NULL) { + if (!primary_selection_offer) { SDL_OutOfMemory(); } else { primary_selection_offer->offer = id; @@ -1839,7 +1839,7 @@ static void primary_selection_device_handle_selection(void *data, struct zwp_pri SDL_WaylandPrimarySelectionDevice *primary_selection_device = data; SDL_WaylandPrimarySelectionOffer *offer = NULL; - if (id != NULL) { + if (id) { offer = zwp_primary_selection_offer_v1_get_user_data(id); } @@ -1963,7 +1963,7 @@ static void Wayland_create_data_device(SDL_VideoData *d) SDL_WaylandDataDevice *data_device = NULL; data_device = SDL_calloc(1, sizeof(*data_device)); - if (data_device == NULL) { + if (!data_device) { return; } @@ -1971,7 +1971,7 @@ static void Wayland_create_data_device(SDL_VideoData *d) d->data_device_manager, d->input->seat); data_device->video_data = d; - if (data_device->data_device == NULL) { + if (!data_device->data_device) { SDL_free(data_device); } else { wl_data_device_set_user_data(data_device->data_device, data_device); @@ -1986,7 +1986,7 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; primary_selection_device = SDL_calloc(1, sizeof(*primary_selection_device)); - if (primary_selection_device == NULL) { + if (!primary_selection_device) { return; } @@ -1994,7 +1994,7 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d) d->primary_selection_device_manager, d->input->seat); primary_selection_device->video_data = d; - if (primary_selection_device->primary_selection_device == NULL) { + if (!primary_selection_device->primary_selection_device) { SDL_free(primary_selection_device); } else { zwp_primary_selection_device_v1_set_user_data(primary_selection_device->primary_selection_device, @@ -2010,14 +2010,14 @@ static void Wayland_create_text_input(SDL_VideoData *d) SDL_WaylandTextInput *text_input = NULL; text_input = SDL_calloc(1, sizeof(*text_input)); - if (text_input == NULL) { + if (!text_input) { return; } text_input->text_input = zwp_text_input_manager_v3_get_text_input( d->text_input_manager, d->input->seat); - if (text_input->text_input == NULL) { + if (!text_input->text_input) { SDL_free(text_input); } else { zwp_text_input_v3_set_user_data(text_input->text_input, text_input); @@ -2031,7 +2031,7 @@ void Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t ver { d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version)); - if (d->input != NULL) { + if (d->input) { Wayland_create_data_device(d); } } @@ -2040,7 +2040,7 @@ void Wayland_add_primary_selection_device_manager(SDL_VideoData *d, uint32_t id, { d->primary_selection_device_manager = wl_registry_bind(d->registry, id, &zwp_primary_selection_device_manager_v1_interface, 1); - if (d->input != NULL) { + if (d->input) { Wayland_create_primary_selection_device(d); } } @@ -2049,7 +2049,7 @@ void Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32_t vers { d->text_input_manager = wl_registry_bind(d->registry, id, &zwp_text_input_manager_v3_interface, 1); - if (d->input != NULL) { + if (d->input) { Wayland_create_text_input(d); } } @@ -2089,7 +2089,7 @@ static void tablet_tool_handle_proximity_in(void *data, struct zwp_tablet_tool_v struct SDL_WaylandTabletInput *input = data; SDL_WindowData *window; - if (surface == NULL) { + if (!surface) { return; } @@ -2146,7 +2146,7 @@ static void tablet_tool_handle_down(void *data, struct zwp_tablet_tool_v2 *tool, struct SDL_WaylandTabletInput *input = data; SDL_WindowData *window = input->tool_focus; input->is_down = SDL_TRUE; - if (window == NULL) { + if (!window) { /* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd. * that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still * received. To prevent SIGSEGV this returns when this is the case. @@ -2164,7 +2164,7 @@ static void tablet_tool_handle_up(void *data, struct zwp_tablet_tool_v2 *tool) input->is_down = SDL_FALSE; - if (window == NULL) { + if (!window) { /* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd. * that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still * received. To prevent SIGSEGV this returns when this is the case. @@ -2280,7 +2280,7 @@ struct SDL_WaylandTabletObjectListNode *tablet_object_list_new_node(void *object struct SDL_WaylandTabletObjectListNode *node; node = SDL_calloc(1, sizeof(*node)); - if (node == NULL) { + if (!node) { return NULL; } @@ -2292,7 +2292,7 @@ struct SDL_WaylandTabletObjectListNode *tablet_object_list_new_node(void *object void tablet_object_list_append(struct SDL_WaylandTabletObjectListNode *head, void *object) { - if (head->object == NULL) { + if (!head->object) { head->object = object; return; } @@ -2350,12 +2350,12 @@ void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_Wayland { struct SDL_WaylandTabletInput *tablet_input; - if (tablet_manager == NULL || input == NULL || !input->seat) { + if (!tablet_manager || !input || !input->seat) { return; } tablet_input = SDL_calloc(1, sizeof(*tablet_input)); - if (tablet_input == NULL) { + if (!tablet_input) { return; } @@ -2388,7 +2388,7 @@ void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) struct SDL_WaylandInput *input; input = SDL_calloc(1, sizeof(*input)); - if (input == NULL) { + if (!input) { return; } @@ -2399,13 +2399,13 @@ void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) input->xkb.current_group = XKB_GROUP_INVALID; d->input = input; - if (d->data_device_manager != NULL) { + if (d->data_device_manager) { Wayland_create_data_device(d); } - if (d->primary_selection_device_manager != NULL) { + if (d->primary_selection_device_manager) { Wayland_create_primary_selection_device(d); } - if (d->text_input_manager != NULL) { + if (d->text_input_manager) { Wayland_create_text_input(d); } @@ -2423,32 +2423,32 @@ void Wayland_display_destroy_input(SDL_VideoData *d) { struct SDL_WaylandInput *input = d->input; - if (input == NULL) { + if (!input) { return; } - if (input->data_device != NULL) { + if (input->data_device) { Wayland_data_device_clear_selection(input->data_device); - if (input->data_device->selection_offer != NULL) { + if (input->data_device->selection_offer) { Wayland_data_offer_destroy(input->data_device->selection_offer); } - if (input->data_device->drag_offer != NULL) { + if (input->data_device->drag_offer) { Wayland_data_offer_destroy(input->data_device->drag_offer); } - if (input->data_device->data_device != NULL) { + if (input->data_device->data_device) { wl_data_device_release(input->data_device->data_device); } SDL_free(input->data_device); } - if (input->primary_selection_device != NULL) { - if (input->primary_selection_device->selection_offer != NULL) { + if (input->primary_selection_device) { + if (input->primary_selection_device->selection_offer) { Wayland_primary_selection_offer_destroy(input->primary_selection_device->selection_offer); } SDL_free(input->primary_selection_device); } - if (input->text_input != NULL) { + if (input->text_input) { zwp_text_input_v3_destroy(input->text_input->text_input); SDL_free(input->text_input); } @@ -2761,7 +2761,7 @@ int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *wi &confined_pointer_listener, window); - if (confine_rect != NULL) { + if (confine_rect) { wl_region_destroy(confine_rect); } diff --git a/src/video/wayland/SDL_waylandkeyboard.c b/src/video/wayland/SDL_waylandkeyboard.c index d8cf07579..999f87e29 100644 --- a/src/video/wayland/SDL_waylandkeyboard.c +++ b/src/video/wayland/SDL_waylandkeyboard.c @@ -32,7 +32,7 @@ int Wayland_InitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; - if (driverdata->text_input_manager == NULL) { + if (!driverdata->text_input_manager) { SDL_IME_Init(); } #endif @@ -45,7 +45,7 @@ void Wayland_QuitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; - if (driverdata->text_input_manager == NULL) { + if (!driverdata->text_input_manager) { SDL_IME_Quit(); } #endif @@ -57,7 +57,7 @@ void Wayland_StartTextInput(_THIS) if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { const SDL_Rect *rect = &input->text_input->cursor_rect; /* Don't re-enable if we're already enabled. */ @@ -98,7 +98,7 @@ void Wayland_StopTextInput(_THIS) if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { zwp_text_input_v3_disable(input->text_input->text_input); zwp_text_input_v3_commit(input->text_input->text_input); input->text_input->is_enabled = SDL_FALSE; @@ -116,14 +116,14 @@ void Wayland_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *driverdata = _this->driverdata; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { if (!SDL_RectEquals(rect, &input->text_input->cursor_rect)) { SDL_copyp(&input->text_input->cursor_rect, rect); zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, diff --git a/src/video/wayland/SDL_waylandmessagebox.c b/src/video/wayland/SDL_waylandmessagebox.c index 24bc21a6f..e57b12f02 100644 --- a/src/video/wayland/SDL_waylandmessagebox.c +++ b/src/video/wayland/SDL_waylandmessagebox.c @@ -89,7 +89,7 @@ static int get_zenity_version(int *major, int *minor) { int tmp; outputfp = fdopen(fd_pipe[0], "r"); - if (outputfp == NULL) { + if (!outputfp) { close(fd_pipe[0]); return SDL_SetError("failed to open pipe for reading: %s", strerror(errno)); } @@ -194,7 +194,7 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button char *output = NULL; char *tmp = NULL; - if (buttonid == NULL) { + if (!buttonid) { /* if we don't need buttonid, we can return immediately */ close(fd_pipe[0]); return 0; /* success */ @@ -202,14 +202,14 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button *buttonid = -1; output = SDL_malloc(output_len + 1); - if (output == NULL) { + if (!output) { close(fd_pipe[0]); return SDL_OutOfMemory(); } output[0] = '\0'; outputfp = fdopen(fd_pipe[0], "r"); - if (outputfp == NULL) { + if (!outputfp) { SDL_free(output); close(fd_pipe[0]); return SDL_SetError("Couldn't open pipe for reading: %s", strerror(errno)); @@ -217,20 +217,20 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button tmp = fgets(output, output_len + 1, outputfp); (void)fclose(outputfp); - if ((tmp == NULL) || (*tmp == '\0') || (*tmp == '\n')) { + if ((!tmp) || (*tmp == '\0') || (*tmp == '\n')) { SDL_free(output); return 0; /* User simply closed the dialog */ } /* It likes to add a newline... */ tmp = SDL_strrchr(output, '\n'); - if (tmp != NULL) { + if (tmp) { *tmp = '\0'; } /* Check which button got pressed */ for (i = 0; i < messageboxdata->numbuttons; i += 1) { - if (messageboxdata->buttons[i].text != NULL) { + if (messageboxdata->buttons[i].text) { if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) { *buttonid = messageboxdata->buttons[i].buttonid; break; diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index adc91271e..2833c948b 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -115,7 +115,7 @@ static SDL_bool wayland_dbus_read_cursor_size(int *size) DBusMessage *reply; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (dbus == NULL || size == NULL) { + if (!dbus || !size) { return SDL_FALSE; } @@ -137,7 +137,7 @@ static SDL_bool wayland_dbus_read_cursor_theme(char **theme) DBusMessage *reply; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (dbus == NULL || theme == NULL) { + if (!dbus || !theme) { return SDL_FALSE; } @@ -189,7 +189,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa } /* First, find the appropriate theme based on the current scale... */ focus = SDL_GetMouse()->focus; - if (focus == NULL) { + if (!focus) { /* Nothing to see here, bail. */ return SDL_FALSE; } @@ -204,19 +204,19 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa break; } } - if (theme == NULL) { + if (!theme) { char *xcursor_theme = NULL; SDL_bool free_theme_str = SDL_FALSE; vdata->cursor_themes = SDL_realloc(vdata->cursor_themes, sizeof(SDL_WaylandCursorTheme) * (vdata->num_cursor_themes + 1)); - if (vdata->cursor_themes == NULL) { + if (!vdata->cursor_themes) { SDL_OutOfMemory(); return SDL_FALSE; } xcursor_theme = SDL_getenv("XCURSOR_THEME"); #if SDL_USE_LIBDBUS - if (xcursor_theme == NULL) { + if (!xcursor_theme) { /* Allocates the string with SDL_strdup, which must be freed. */ free_theme_str = wayland_dbus_read_cursor_theme(&xcursor_theme); } @@ -298,7 +298,7 @@ static int wayland_create_tmp_file(off_t size) int fd; xdg_path = SDL_getenv("XDG_RUNTIME_DIR"); - if (xdg_path == NULL) { + if (!xdg_path) { return -1; } @@ -357,7 +357,7 @@ static int create_buffer_from_shm(Wayland_CursorData *d, return SDL_SetError("mmap() failed."); } - SDL_assert(d->shm_data != NULL); + SDL_assert(d->shm_data); shm_pool = wl_shm_create_pool(data->shm, shm_fd, size); d->buffer = wl_shm_pool_create_buffer(shm_pool, @@ -385,7 +385,7 @@ static SDL_Cursor *Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *wd = (SDL_VideoData *)vd->driverdata; Wayland_CursorData *data = SDL_calloc(1, sizeof(Wayland_CursorData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -429,7 +429,7 @@ static SDL_Cursor *Wayland_CreateSystemCursor(SDL_SystemCursor id) cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { Wayland_CursorData *cdata = SDL_calloc(1, sizeof(Wayland_CursorData)); - if (cdata == NULL) { + if (!cdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -472,7 +472,7 @@ static void Wayland_FreeCursorData(Wayland_CursorData *d) static void Wayland_FreeCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { return; } @@ -496,7 +496,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) struct wl_pointer *pointer = d->pointer; float scale = 1.0f; - if (pointer == NULL) { + if (!pointer) { return -1; } @@ -504,7 +504,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) Wayland_CursorData *data = cursor->driverdata; /* TODO: High-DPI custom cursors? -flibit */ - if (data->shm_data == NULL) { + if (!data->shm_data) { if (!wayland_get_system_cursor(d, data, &scale)) { return -1; } diff --git a/src/video/wayland/SDL_waylandtouch.c b/src/video/wayland/SDL_waylandtouch.c index 7c7a300d7..f4762cfc6 100644 --- a/src/video/wayland/SDL_waylandtouch.c +++ b/src/video/wayland/SDL_waylandtouch.c @@ -99,7 +99,7 @@ static void touch_handle_touch(void *data, /* FIXME: This should be the window the given wayland surface is associated * with, but how do we get the wayland surface? */ window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { window = SDL_GetKeyboardFocus(); } diff --git a/src/video/wayland/SDL_waylandtouch.h b/src/video/wayland/SDL_waylandtouch.h index 5a542e2dd..652f81019 100644 --- a/src/video/wayland/SDL_waylandtouch.h +++ b/src/video/wayland/SDL_waylandtouch.h @@ -94,7 +94,7 @@ static inline struct qt_extended_surface *qt_surface_extension_get_extended_surf id = wl_proxy_create((struct wl_proxy *)qt_surface_extension, &qt_extended_surface_interface); - if (id == NULL) + if (!id) return NULL; WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_surface_extension, diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 6f0747ac9..d8c7aabf7 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -186,13 +186,13 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) } display = WAYLAND_wl_display_connect(NULL); - if (display == NULL) { + if (!display) { SDL_WAYLAND_UnloadSymbols(); return NULL; } data = SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { WAYLAND_wl_display_disconnect(display); SDL_WAYLAND_UnloadSymbols(); SDL_OutOfMemory(); @@ -204,7 +204,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_free(data); WAYLAND_wl_display_disconnect(display); SDL_WAYLAND_UnloadSymbols(); @@ -356,7 +356,7 @@ static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg if (driverdata->index == -1) { /* xdg-output descriptions, if available, supersede wl-output model names. */ - if (driverdata->placeholder.name != NULL) { + if (driverdata->placeholder.name) { SDL_free(driverdata->placeholder.name); } @@ -485,7 +485,7 @@ static void display_handle_geometry(void *data, driverdata->physical_height = physical_height; /* The output name is only set if xdg-output hasn't provided a description. */ - if (driverdata->index == -1 && driverdata->placeholder.name == NULL) { + if (driverdata->index == -1 && !driverdata->placeholder.name) { driverdata->placeholder.name = SDL_strdup(model); } @@ -609,7 +609,7 @@ static void display_handle_done(void *data, * The native display mode is only exposed separately from the desktop size if the * desktop is scaled and the wp_viewporter protocol is supported. */ - if (driverdata->scale_factor > 1.0f && video->viewporter != NULL) { + if (driverdata->scale_factor > 1.0f && video->viewporter) { if (driverdata->index > -1) { SDL_AddDisplayMode(SDL_GetDisplay(driverdata->index), &native_mode); } else { @@ -685,7 +685,7 @@ static void Wayland_add_display(SDL_VideoData *d, uint32_t id) SDL_WaylandOutputData *data; output = wl_registry_bind(d->registry, id, &wl_output_interface, 2); - if (output == NULL) { + if (!output) { SDL_SetError("Failed to retrieve output."); return; } @@ -701,10 +701,10 @@ static void Wayland_add_display(SDL_VideoData *d, uint32_t id) SDL_WAYLAND_register_output(output); /* Keep a list of outputs for deferred xdg-output initialization. */ - if (d->output_list != NULL) { + if (d->output_list) { SDL_WaylandOutputData *node = d->output_list; - while (node->next != NULL) { + while (node->next) { node = node->next; } @@ -730,15 +730,15 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id) display = SDL_GetDisplay(i); data = (SDL_WaylandOutputData *)display->driverdata; if (data->registry_id == id) { - if (d->output_list != NULL) { + if (d->output_list) { SDL_WaylandOutputData *node = d->output_list; if (node == data) { d->output_list = node->next; } else { - while (node->next != data && node->next != NULL) { + while (node->next != data && node->next) { node = node->next; } - if (node->next != NULL) { + if (node->next) { node->next = node->next->next; } } @@ -766,7 +766,7 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id) static void Wayland_init_xdg_output(SDL_VideoData *d) { SDL_WaylandOutputData *node; - for (node = d->output_list; node != NULL; node = node->next) { + for (node = d->output_list; node; node = node->next) { node->xdg_output = zxdg_output_manager_v1_get_xdg_output(node->videodata->xdg_output_manager, node->output); zxdg_output_v1_add_listener(node->xdg_output, &xdg_output_listener, node); } @@ -937,7 +937,7 @@ int Wayland_VideoInit(_THIS) } data->registry = wl_display_get_registry(data->display); - if (data->registry == NULL) { + if (!data->registry) { return SDL_SetError("Failed to get the Wayland registry"); } diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index 59427dedb..c3712ed68 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -53,10 +53,10 @@ int Wayland_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -81,7 +81,7 @@ int Wayland_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 55dee0645..6a773de56 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -145,7 +145,7 @@ static SDL_bool NeedViewport(SDL_Window *window) * - A fullscreen mode is being emulated and the mode does not match the logical desktop dimensions. * - The desktop uses fractional scaling and the high-DPI flag is set. */ - if (video->viewporter != NULL) { + if (video->viewporter) { if (FullscreenModeEmulation(window)) { GetFullScreenDimensions(window, &fs_width, &fs_height, NULL, NULL); if (fs_width != output_width || fs_height != output_height) { @@ -198,7 +198,7 @@ static void SetDrawSurfaceViewport(SDL_Window *window, int src_width, int src_he SDL_VideoData *video = wind->waylandData; if (video->viewporter) { - if (wind->draw_viewport == NULL) { + if (!wind->draw_viewport) { wind->draw_viewport = wp_viewporter_get_viewport(video->viewporter, wind->surface); } @@ -295,7 +295,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) if (window_size_changed) { /* libdecor does this internally on frame commits, so it's only needed for xdg surfaces. */ if (data->shell_surface_type != WAYLAND_SURFACE_LIBDECOR && - viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { + viddata->shell.xdg && data->shell_surface.xdg.surface) { xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->window_width, data->window_height); } @@ -360,7 +360,7 @@ static void SetMinMaxDimensions(SDL_Window *window, SDL_bool commit) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_min_content_size(wind->shell_surface.libdecor.frame, @@ -404,7 +404,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } if (output) { @@ -781,7 +781,7 @@ static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = { static void OverrideLibdecorLimits(SDL_Window *window) { #if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) - if (libdecor_frame_get_min_content_size == NULL) { + if (!libdecor_frame_get_min_content_size) { SetMinMaxDimensions(window, SDL_FALSE); } #elif !defined(SDL_HAVE_LIBDECOR_GET_MIN_MAX) @@ -1208,7 +1208,7 @@ SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * inf #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame != NULL) { + if (data->shell_surface.libdecor.frame) { info->info.wl.xdg_surface = libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame); if (version >= SDL_VERSIONNUM(2, 0, 17)) { info->info.wl.xdg_toplevel = libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame); @@ -1223,7 +1223,7 @@ SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * inf } } else #endif - if (viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { + if (viddata->shell.xdg && data->shell_surface.xdg.surface) { info->info.wl.xdg_surface = data->shell_surface.xdg.surface; if (version >= SDL_VERSIONNUM(2, 0, 17)) { SDL_bool popup = data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP; @@ -1269,10 +1269,10 @@ int Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *paren #ifdef HAVE_LIBDECOR_H if (viddata->shell.libdecor) { - if (modal_data->shell_surface.libdecor.frame == NULL) { + if (!modal_data->shell_surface.libdecor.frame) { return SDL_SetError("Modal window was hidden"); } - if (parent_data->shell_surface.libdecor.frame == NULL) { + if (!parent_data->shell_surface.libdecor.frame) { return SDL_SetError("Parent window was hidden"); } libdecor_frame_set_parent(modal_data->shell_surface.libdecor.frame, @@ -1325,7 +1325,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) data->surface, &libdecor_frame_interface, data); - if (data->shell_surface.libdecor.frame == NULL) { + if (!data->shell_surface.libdecor.frame) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); } else { libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); @@ -1486,11 +1486,11 @@ static void Wayland_ReleasePopup(_THIS, SDL_Window *popup) SDL_WindowData *popupdata; /* Basic sanity checks to weed out the weird popup closures */ - if (popup == NULL || popup->magic != &_this->window_magic) { + if (!popup || popup->magic != &_this->window_magic) { return; } popupdata = popup->driverdata; - if (popupdata == NULL) { + if (!popupdata) { return; } @@ -1601,7 +1601,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, uint32_t serial, struct wl_seat *seat) { if (data->activation_manager) { - if (wind->activation_token != NULL) { + if (wind->activation_token) { /* We're about to overwrite this with a new request */ xdg_activation_token_v1_destroy(wind->activation_token); } @@ -1618,10 +1618,10 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, * * -flibit */ - if (surface != NULL) { + if (surface) { xdg_activation_token_v1_set_surface(wind->activation_token, surface); } - if (seat != NULL) { + if (seat) { xdg_activation_token_v1_set_serial(wind->activation_token, serial, seat); } xdg_activation_token_v1_commit(wind->activation_token); @@ -1695,20 +1695,20 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * { "inverted-landscape", QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION } }; - if (name == NULL) { + if (!name) { return; } if (SDL_strcmp(name, SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION) == 0) { int32_t orientation = QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION; - if (newValue != NULL) { + if (newValue) { const char *value_attempt = newValue; orientation = 0; - while (value_attempt != NULL && *value_attempt != 0) { + while (value_attempt && *value_attempt != 0) { const char *value_attempt_end = SDL_strchr(value_attempt, ','); - size_t value_attempt_len = (value_attempt_end != NULL) ? (value_attempt_end - value_attempt) + size_t value_attempt_len = (value_attempt_end) ? (value_attempt_end - value_attempt) : SDL_strlen(value_attempt); for (i = 0; i < SDL_arraysize(orientations); i += 1) { @@ -1719,7 +1719,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * } } - value_attempt = (value_attempt_end != NULL) ? (value_attempt_end + 1) : NULL; + value_attempt = (value_attempt_end) ? (value_attempt_end + 1) : NULL; } } @@ -1727,7 +1727,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * } else if (SDL_strcmp(name, SDL_HINT_QTWAYLAND_WINDOW_FLAGS) == 0) { uint32_t flags = 0; - if (newValue != NULL) { + if (newValue) { char *tmp = SDL_strdup(newValue); char *saveptr = NULL; @@ -1817,7 +1817,7 @@ void Wayland_RestoreWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_unset_maximized(wind->shell_surface.libdecor.frame); @@ -1862,7 +1862,7 @@ void Wayland_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable) const SDL_WindowData *wind = window->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } if (resizable) { @@ -1897,7 +1897,7 @@ void Wayland_MaximizeWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_maximized(wind->shell_surface.libdecor.frame); @@ -1924,7 +1924,7 @@ void Wayland_MinimizeWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_minimized(wind->shell_surface.libdecor.frame); @@ -1987,7 +1987,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) SDL_VideoData *c; data = SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -2198,7 +2198,7 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_title(wind->shell_surface.libdecor.frame, title); @@ -2322,7 +2322,7 @@ static void EGLTransparencyChangedCallback(void *userdata, const char *name, con viddata->egl_transparency_enabled = newval; /* Iterate over all windows and update the surface opaque regions */ - for (window = dev->windows; window != NULL; window = window->next) { + for (window = dev->windows; window; window = window->next) { SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; if (!newval) { diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index df8a404a7..49e852e5e 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -129,7 +129,7 @@ char *WIN_GetClipboardText(_THIS) SDL_Delay(10); } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } return text; diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 66aa8b0b3..f8bad4edb 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -699,12 +699,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Get the window data for the window */ data = WIN_GetWindowDataFromHWND(hwnd); #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - if (data == NULL) { + if (!data) { /* Fallback */ data = (SDL_WindowData *)GetProp(hwnd, TEXT("SDL_WindowData")); } #endif - if (data == NULL) { + if (!data) { return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); } @@ -1809,7 +1809,7 @@ int WIN_WaitEventTimeout(_THIS, int timeout) message_result = GetMessage(&msg, 0, 0, 0); } if (message_result) { - if (msg.message == WM_TIMER && msg.hwnd == NULL && msg.wParam == timer_id) { + if (msg.message == WM_TIMER && !msg.hwnd && msg.wParam == timer_id) { return 0; } if (g_WindowsMessageHook) { @@ -1898,7 +1898,7 @@ void WIN_PumpEvents(_THIS) not grabbing the keyboard. Note: If we *are* grabbing the keyboard, GetKeyState() will return inaccurate results for VK_LWIN and VK_RWIN but we don't need it anyway. */ focusWindow = SDL_GetKeyboardFocus(); - if (focusWindow == NULL || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { + if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) { SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI); } @@ -1952,8 +1952,8 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) ++app_registered; return 0; } - SDL_assert(SDL_Appname == NULL); - if (name == NULL) { + SDL_assert(!SDL_Appname); + if (!name) { name = "SDL_app"; #if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC) style = (CS_BYTEALIGNCLIENT | CS_OWNDC); diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index 82483526d..0c0f64780 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -114,7 +114,7 @@ void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index d4d2238a7..01a9977f1 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -239,7 +239,7 @@ void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; HIMC himc = 0; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } @@ -698,7 +698,7 @@ static void IME_SetupAPI(SDL_VideoData *videodata) } hime = SDL_LoadObject(ime_file); - if (hime == NULL) { + if (!hime) { return; } @@ -781,7 +781,7 @@ static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD length = ImmGetCompositionStringW(himc, string, NULL, 0); if (length > 0 && videodata->ime_composition_length < length) { - if (videodata->ime_composition != NULL) { + if (videodata->ime_composition) { SDL_free(videodata->ime_composition); } @@ -973,11 +973,11 @@ static int IME_ShowCandidateList(SDL_VideoData *videodata) videodata->ime_candcount = 0; candidates = SDL_realloc(videodata->ime_candidates, MAX_CANDSIZE); - if (candidates != NULL) { + if (candidates) { videodata->ime_candidates = (WCHAR *)candidates; } - if (videodata->ime_candidates == NULL) { + if (!videodata->ime_candidates) { return -1; } @@ -1191,7 +1191,7 @@ TSFSink_Release(TSFSink *sink) STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) { - if (ppv == NULL) { + if (!ppv) { return E_INVALIDARG; } @@ -1228,7 +1228,7 @@ STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BO ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1253,7 +1253,7 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId) ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1279,7 +1279,7 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId) ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1301,7 +1301,7 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId) STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) { - if (ppv == NULL) { + if (!ppv) { return E_INVALIDARG; } diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 9272f536c..246c9cada 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -265,7 +265,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { /* Focus on the first default return-key button */ HWND buttonctl = GetDlgItem(hDlg, (int)(IDBUTTONINDEX0 + buttonindex)); - if (buttonctl == NULL) { + if (!buttonctl) { EndDialog(hDlg, IDINVALPTRDLGITEM); } PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)buttonctl, TRUE); @@ -276,7 +276,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return FALSE; case WM_SETFOCUS: messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); - if (messageboxdata == NULL) { + if (!messageboxdata) { EndDialog(hDlg, IDINVALPTRSETFOCUS); return TRUE; } @@ -288,7 +288,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return TRUE; case WM_COMMAND: messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); - if (messageboxdata == NULL) { + if (!messageboxdata) { EndDialog(hDlg, IDINVALPTRCOMMAND); return TRUE; } @@ -344,7 +344,7 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) if (size > dialog->size) { void *data = SDL_realloc(dialog->data, size); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -387,12 +387,12 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) size_t count; SDL_bool status; - if (string == NULL) { + if (!string) { string = ""; } wstring = WIN_UTF8ToStringW(string); - if (wstring == NULL) { + if (!wstring) { return SDL_FALSE; } @@ -448,7 +448,7 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, if (!AddDialogData(dialog, &type, sizeof(type))) { return SDL_FALSE; } - if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL)) { + if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption)) { if (!AddDialogString(dialog, caption)) { return SDL_FALSE; } @@ -521,7 +521,7 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy); dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog)); - if (dialog == NULL) { + if (!dialog) { return NULL; } @@ -623,7 +623,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) size_t ampcount = 0; size_t srclen = 0; - if (src == NULL) { + if (!src) { return NULL; } @@ -642,7 +642,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) if (SIZE_MAX - srclen < ampcount) { return NULL; } - if (*dst == NULL || *dstlen < srclen + ampcount) { + if (!*dst || *dstlen < srclen + ampcount) { /* Allocating extra space in case the next strings are a bit longer. */ size_t extraspace = SIZE_MAX - (srclen + ampcount); if (extraspace > 512) { @@ -652,7 +652,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) SDL_free(*dst); *dst = NULL; newdst = SDL_malloc(*dstlen); - if (newdst == NULL) { + if (!newdst) { return NULL; } *dst = newdst; @@ -817,7 +817,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * Size.cy += ButtonHeight + TextMargin; dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title); - if (dialog == NULL) { + if (!dialog) { return -1; } @@ -858,7 +858,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * buttontext = EscapeAmpersands(&escape, &escapesize, sdlButton->text); /* Make sure to provide the correct ID to keep buttons indexed in the * same order as how they are in messageboxdata. */ - if (buttontext == NULL || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) { + if (!buttontext || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) { FreeDialogData(dialog); SDL_free(ampescape); return -1; @@ -932,7 +932,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) /* If we cannot load comctl32.dll use the old messagebox! */ hComctl32 = LoadLibrary(TEXT("comctl32.dll")); - if (hComctl32 == NULL) { + if (!hComctl32) { return WIN_ShowOldMessageBox(messageboxdata, buttonid); } @@ -944,7 +944,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") */ pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC)GetProcAddress(hComctl32, "TaskDialogIndirect"); - if (pfnTaskDialogIndirect == NULL) { + if (!pfnTaskDialogIndirect) { FreeLibrary(hComctl32); return WIN_ShowOldMessageBox(messageboxdata, buttonid); } @@ -992,7 +992,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) pButton->nButtonID = IDBUTTONINDEX0 + i; } buttontext = EscapeAmpersands(&escape, &escapesize, messageboxdata->buttons[i].text); - if (buttontext == NULL) { + if (!buttontext) { int j; FreeLibrary(hComctl32); SDL_free(ampescape); diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index b8f47a13a..f0e3d34ef 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -171,7 +171,7 @@ static SDL_bool WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_D } data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_FALSE; } @@ -215,7 +215,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) LONG rc; dll = SDL_LoadObject("USER32.DLL"); - if (dll == NULL) { + if (!dll) { return NULL; } @@ -223,7 +223,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) pQueryDisplayConfig = (SDL_WIN32PROC_QueryDisplayConfig)SDL_LoadFunction(dll, "QueryDisplayConfig"); pDisplayConfigGetDeviceInfo = (SDL_WIN32PROC_DisplayConfigGetDeviceInfo)SDL_LoadFunction(dll, "DisplayConfigGetDeviceInfo"); - if (pGetDisplayConfigBufferSizes == NULL || pQueryDisplayConfig == NULL || pDisplayConfigGetDeviceInfo == NULL) { + if (!pGetDisplayConfigBufferSizes || !pQueryDisplayConfig || !pDisplayConfigGetDeviceInfo) { goto WIN_GetDisplayNameVista_failed; } @@ -238,7 +238,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) paths = (DISPLAYCONFIG_PATH_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_PATH_INFO) * pathCount); modes = (DISPLAYCONFIG_MODE_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_MODE_INFO) * modeCount); - if ((paths == NULL) || (modes == NULL)) { + if ((!paths) || (!modes)) { goto WIN_GetDisplayNameVista_failed; } @@ -352,7 +352,7 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, } displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return; } SDL_memcpy(displaydata->DeviceName, info->szDevice, sizeof(displaydata->DeviceName)); @@ -361,7 +361,7 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_zero(display); display.name = WIN_GetDisplayNameVista(info->szDevice); - if (display.name == NULL) { + if (!display.name) { DISPLAY_DEVICEW device; SDL_zero(device); device.cb = sizeof(device); @@ -521,7 +521,7 @@ int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi_out, float * float hinches, vinches; hdc = GetDC(NULL); - if (hdc == NULL) { + if (!hdc) { return SDL_SetError("GetDC failed"); } hdpi_int = GetDeviceCaps(hdc, LOGPIXELSX); @@ -603,7 +603,7 @@ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut) *dpiOut = 96; } - if (videodevice == NULL || !videodevice->driverdata) { + if (!videodevice || !videodevice->driverdata) { return; } @@ -656,7 +656,7 @@ void WIN_ScreenPointToSDL(int *x, int *y) float ddpi, hdpi, vdpi; int x_pixels, y_pixels; - if (videodevice == NULL || !videodevice->driverdata) { + if (!videodevice || !videodevice->driverdata) { return; } diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index 5844da79e..3840cd311 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -114,7 +114,7 @@ static SDL_Cursor *WIN_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) maskbitslen = ((surface->w + (pad - (surface->w % pad))) / 8) * surface->h; maskbits = SDL_small_alloc(Uint8, maskbitslen, &isstack); - if (maskbits == NULL) { + if (!maskbits) { SDL_OutOfMemory(); return NULL; } @@ -249,7 +249,7 @@ static void WIN_FreeCursor(SDL_Cursor *cursor) static int WIN_ShowCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { cursor = SDL_blank_cursor; } if (cursor) { diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 947e30946..538cfcfe0 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -220,7 +220,7 @@ void *WIN_GL_GetProcAddress(_THIS, const char *proc) /* This is to pick up extensions */ func = _this->gl_data->wglGetProcAddress(proc); - if (func == NULL) { + if (!func) { /* This is probably a normal GL function */ func = GetProcAddress(_this->gl_config.dll_handle, proc); } @@ -383,7 +383,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) return SDL_FALSE; } - if (extensions == NULL) { + if (!extensions) { return SDL_FALSE; } @@ -395,7 +395,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) for (;;) { where = SDL_strstr(start, extension); - if (where == NULL) { + if (!where) { break; } @@ -690,7 +690,7 @@ int WIN_GL_SetupWindow(_THIS, SDL_Window *window) SDL_bool WIN_GL_UseEGL(_THIS) { - SDL_assert(_this->gl_data != NULL); + SDL_assert(_this->gl_data); SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES); return SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) || _this->gl_config.major_version == 1 || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor); /* No WGL extension for OpenGL ES 1.x profiles. */ @@ -829,15 +829,15 @@ int WIN_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) } /* sanity check that higher level handled this. */ - SDL_assert(window || (window == NULL && !context)); + SDL_assert(window || (!window && !context)); /* Some Windows drivers freak out if hdc is NULL, even when context is NULL, against spec. Since hdc is _supposed_ to be ignored if context is NULL, we either use the current GL window, or do nothing if we already have no current context. */ - if (window == NULL) { + if (!window) { window = SDL_GL_GetCurrentWindow(); - if (window == NULL) { + if (!window) { SDL_assert(SDL_GL_GetCurrentContext() == NULL); return 0; /* already done. */ } diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index d410141ea..cad4479f4 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -51,7 +51,7 @@ int WIN_GLES_LoadLibrary(_THIS, const char *path) #endif } - if (_this->egl_data == NULL) { + if (!_this->egl_data) { return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0); } @@ -106,7 +106,7 @@ int WIN_GLES_SetupWindow(_THIS, SDL_Window *window) SDL_Window *current_win = SDL_GL_GetCurrentWindow(); SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); - if (_this->egl_data == NULL) { + if (!_this->egl_data) { /* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */ #if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. */ SDL_assert(!_this->gl_config.driver_loaded); diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 9aa75d2cb..b00e44760 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -29,7 +29,7 @@ SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window) { int resized_properly; SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -77,8 +77,8 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo SDL_ShapeData *data; HRGN mask_region = NULL; - if ((shaper == NULL) || - (shape == NULL) || + if ((!shaper) || + (!shape) || ((shape->format->Amask == 0) && (shape_mode->mode != ShapeModeColorKey)) || (shape->w != shaper->window->w) || (shape->h != shaper->window->h)) { @@ -86,7 +86,7 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo } data = (SDL_ShapeData *)shaper->driverdata; - if (data->mask_tree != NULL) { + if (data->mask_tree) { SDL_FreeShapeTree(&data->mask_tree); } data->mask_tree = SDL_CalculateShapeTree(*shape_mode, shape); @@ -103,15 +103,15 @@ int Win32_ResizeWindowShape(SDL_Window *window) { SDL_ShapeData *data; - if (window == NULL) { + if (!window) { return -1; } data = (SDL_ShapeData *)window->shaper->driverdata; - if (data == NULL) { + if (!data) { return -1; } - if (data->mask_tree != NULL) { + if (data->mask_tree) { SDL_FreeShapeTree(&data->mask_tree); } if (window->shaper->hasshape == SDL_TRUE) { diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 5621293f5..6ff6fd43c 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -385,7 +385,7 @@ static void WIN_InitDPIAwareness(_THIS) { const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_DPI_AWARENESS); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "permonitorv2") == 0) { WIN_DeclareDPIAwarePerMonitorV2(_this); } else if (SDL_strcmp(hint, "permonitor") == 0) { @@ -540,7 +540,7 @@ int SDL_Direct3D9GetAdapterIndex(int displayIndex) SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); int adapterIndex = D3DADAPTER_DEFAULT; - if (pData == NULL) { + if (!pData) { SDL_SetError("Invalid display index"); adapterIndex = -1; /* make sure we return something invalid */ } else { @@ -623,12 +623,12 @@ SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputI IDXGIAdapter *pDXGIAdapter; IDXGIOutput *pDXGIOutput; - if (adapterIndex == NULL) { + if (!adapterIndex) { SDL_InvalidParamError("adapterIndex"); return SDL_FALSE; } - if (outputIndex == NULL) { + if (!outputIndex) { SDL_InvalidParamError("outputIndex"); return SDL_FALSE; } @@ -636,7 +636,7 @@ SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputI *adapterIndex = -1; *outputIndex = -1; - if (pData == NULL) { + if (!pData) { SDL_SetError("Invalid display index"); return SDL_FALSE; } diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index aa5f01823..17643f44a 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -48,10 +48,10 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = "vulkan-1.dll"; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -76,7 +76,7 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 371b79ee4..ea11132ec 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -179,7 +179,7 @@ static void WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL mon = MonitorFromRect(&screen_rect, MONITOR_DEFAULTTONEAREST); - if (videodata != NULL) { + if (videodata) { /* GetDpiForMonitor docs promise to return the same hdpi / vdpi */ if (videodata->GetDpiForMonitor(mon, MDT_EFFECTIVE_DPI, &frame_dpi, &unused) != S_OK) { frame_dpi = 96; @@ -300,7 +300,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, HWND hwnd, HWND parent, SD /* Allocate the window data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->window = window; @@ -477,7 +477,7 @@ static void CleanupWindowData(_THIS, SDL_Window *window) } } else { /* Restore any original event handler... */ - if (data->wndproc != NULL) { + if (data->wndproc) { #ifdef GWLP_WNDPROC SetWindowLongPtr(data->hwnd, GWLP_WNDPROC, (LONG_PTR)data->wndproc); @@ -607,7 +607,7 @@ int WIN_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) (void)SDL_sscanf(hint, "%p", (void **)&otherWindow); /* Do some error checking on the pointer */ - if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) { + if (otherWindow && otherWindow->magic == &_this->window_magic) { /* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */ if (otherWindow->flags & SDL_WINDOW_OPENGL) { window->flags |= SDL_WINDOW_OPENGL; @@ -1058,7 +1058,7 @@ void *WIN_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) filename_utf8 = WIN_StringToUTF8(data->ICMFileName); if (filename_utf8) { iccProfileData = SDL_LoadFile(filename_utf8, size); - if (iccProfileData == NULL) { + if (!iccProfileData) { SDL_SetError("Could not open ICC profile"); } SDL_free(filename_utf8); @@ -1224,7 +1224,7 @@ int SDL_HelperWindowCreate(void) CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL); - if (SDL_HelperWindow == NULL) { + if (!SDL_HelperWindow) { UnregisterClass(SDL_HelperWindowClassName, hInstance); return WIN_SetError("Unable to create Helper Window"); } @@ -1263,7 +1263,7 @@ void WIN_OnWindowEnter(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (data == NULL || !data->hwnd) { + if (!data || !data->hwnd) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/winrt/SDL_winrtgamebar.cpp b/src/video/winrt/SDL_winrtgamebar.cpp index fd71a55be..1db0d0e34 100644 --- a/src/video/winrt/SDL_winrtgamebar.cpp +++ b/src/video/winrt/SDL_winrtgamebar.cpp @@ -116,7 +116,7 @@ static void WINRT_HandleGameBarIsInputRedirected_MainThread() return; } gameBar = WINRT_GetGameBar(); - if (gameBar == NULL) { + if (!gameBar) { /* Shouldn't happen, but just in case... */ return; } @@ -167,11 +167,11 @@ void WINRT_QuitGameBar(_THIS) { SDL_VideoData *driverdata; IGameBarStatics_ *gameBar; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { return; } gameBar = WINRT_GetGameBar(); - if (gameBar == NULL) { + if (!gameBar) { return; } driverdata = (SDL_VideoData *)_this->driverdata; diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index 9a38e6ccc..594709dcb 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -116,13 +116,13 @@ static SDL_VideoDevice *WINRT_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return 0; @@ -182,7 +182,7 @@ static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const * * TODO, WinRT: consider reading in an app's .appxmanifest file, and apply its orientation when 'newValue == NULL'. */ - if ((oldValue == NULL) && (newValue == NULL)) { + if ((!oldValue) && (!newValue)) { return; } @@ -337,7 +337,7 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou } dxgiModes = (DXGI_MODE_DESC *)SDL_calloc(numModes, sizeof(DXGI_MODE_DESC)); - if (dxgiModes == NULL) { + if (!dxgiModes) { SDL_OutOfMemory(); goto done; } diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 5d28eecca..39198e74d 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -206,7 +206,7 @@ static char *GetSlectionText(_THIS, Atom selection_type) X11_XFree(src); } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index 818729970..f0b14feec 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -75,22 +75,22 @@ static void *X11_GetSym(const char *fnname, int *pHasModule) int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].lib != NULL) { + if (x11libs[i].lib) { fn = SDL_LoadFunction(x11libs[i].lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_X11 - if (fn != NULL) + if (fn) printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, fn); else printf("X11: Symbol '%s' NOT FOUND!\n", fnname); #endif - if (fn == NULL) { + if (!fn) { *pHasModule = 0; /* kill this module. */ } @@ -136,7 +136,7 @@ void SDL_X11_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].lib != NULL) { + if (x11libs[i].lib) { SDL_UnloadObject(x11libs[i].lib); x11libs[i].lib = NULL; } @@ -157,7 +157,7 @@ int SDL_X11_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].libname != NULL) { + if (x11libs[i].libname) { x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); } } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 08cede4e2..ec5433dfa 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -102,7 +102,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != NULL) { + if (ret) { X11_XFree(ret); } X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); @@ -224,7 +224,7 @@ static int X11_URIDecode(char *buf, int len) { int ri, wi, di; char decode = '\0'; - if (buf == NULL || len < 0) { + if (!buf || len < 0) { errno = EINVAL; return -1; } @@ -300,7 +300,7 @@ static char *X11_URIToLocal(char *uri) /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { char *hostname_end = SDL_strchr(uri + 1, '/'); - if (hostname_end != NULL) { + if (hostname_end) { char hostname[257]; if (gethostname(hostname, 255) == 0) { hostname[256] = '\0'; @@ -803,7 +803,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) XClientMessageEvent m; int i; - SDL_assert(videodata != NULL); + SDL_assert(videodata); display = videodata->display; /* Save the original keycode for dead keys, which are filtered out by @@ -906,7 +906,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) } } } - if (data == NULL) { + if (!data) { /* The window for KeymapNotify, etc events is 0 */ if (xevent->type == KeymapNotify) { #ifdef DEBUG_XEVENTS @@ -1570,7 +1570,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) char *name = X11_XGetAtomName(display, target); if (name) { char *token = SDL_strtokr((char *)p.data, "\r\n", &saveptr); - while (token != NULL) { + while (token) { if (SDL_strcmp("text/plain", name) == 0) { SDL_SendDropText(data->window, token); } else if (SDL_strcmp("text/uri-list", name) == 0) { diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 403dbd338..739c7b342 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -127,7 +127,7 @@ int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, #endif /* not NO_SHARED_MEMORY */ *pixels = SDL_malloc((size_t)h * (*pitch)); - if (*pixels == NULL) { + if (!*pixels) { return SDL_OutOfMemory(); } @@ -226,7 +226,7 @@ void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 12818ed69..8d0c6c8c8 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -451,7 +451,7 @@ void X11_StopTextInput(_THIS) void X11_SetTextInputRect(_THIS, const SDL_Rect *rect) { - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index 12e40f46d..c6dcaeb81 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -191,15 +191,15 @@ static int X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBoxD int num_missing = 0; data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont, &missing, &num_missing, NULL); - if (missing != NULL) { + if (missing) { X11_XFreeStringList(missing); } - if (data->font_set == NULL) { + if (!data->font_set) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFont); } } else { data->font_struct = X11_XLoadQueryFont(data->display, g_MessageBoxFontLatin1); - if (data->font_struct == NULL) { + if (!data->font_struct) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); } } @@ -240,12 +240,12 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) const SDL_MessageBoxData *messageboxdata = data->messageboxdata; /* Go over text and break linefeeds into separate lines. */ - if (messageboxdata != NULL && messageboxdata->message[0]) { + if (messageboxdata && messageboxdata->message[0]) { const char *text = messageboxdata->message; const int linecount = CountLinesOfText(text); TextLineData *plinedata = (TextLineData *)SDL_malloc(sizeof(TextLineData) * linecount); - if (plinedata == NULL) { + if (!plinedata) { return SDL_OutOfMemory(); } @@ -273,7 +273,7 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) text += length + 1; /* Break if there are no more linefeeds. */ - if (lf == NULL) { + if (!lf) { break; } } @@ -362,12 +362,12 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) /* Free SDL_MessageBoxData data. */ static void X11_MessageBoxShutdown(SDL_MessageBoxDataX11 *data) { - if (data->font_set != NULL) { + if (data->font_set) { X11_XFreeFontSet(data->display, data->font_set); data->font_set = NULL; } - if (data->font_struct != NULL) { + if (data->font_struct) { X11_XFreeFont(data->display, data->font_struct); data->font_struct = NULL; } @@ -762,9 +762,9 @@ static int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int #if SDL_SET_LOCALE origlocale = setlocale(LC_ALL, NULL); - if (origlocale != NULL) { + if (origlocale) { origlocale = SDL_strdup(origlocale); - if (origlocale == NULL) { + if (!origlocale) { return SDL_OutOfMemory(); } (void)setlocale(LC_ALL, ""); diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index e3c24b24b..ae4a4b24d 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -323,7 +323,7 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output } output_info = X11_XRRGetOutputInfo(dpy, res, outputid); - if (output_info == NULL || !output_info->crtc || output_info->connection == RR_Disconnected) { + if (!output_info || !output_info->crtc || output_info->connection == RR_Disconnected) { X11_XRRFreeOutputInfo(output_info); return 0; /* ignore this one. */ } @@ -335,7 +335,7 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output X11_XRRFreeOutputInfo(output_info); crtc = X11_XRRGetCrtcInfo(dpy, res, output_crtc); - if (crtc == NULL) { + if (!crtc) { return 0; /* oh well, ignore it. */ } @@ -351,12 +351,12 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output X11_XRRFreeCrtcInfo(crtc); displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return SDL_OutOfMemory(); } modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { SDL_free(displaydata); return SDL_OutOfMemory(); } @@ -410,14 +410,14 @@ static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent } } - SDL_assert((displayidx == -1) == (display == NULL)); + SDL_assert((displayidx == -1) == (!display)); if (ev->connection == RR_Disconnected) { /* output is going away */ - if (display != NULL) { + if (display) { SDL_DelVideoDisplay(displayidx); } } else if (ev->connection == RR_Connected) { /* output is coming online */ - if (display != NULL) { + if (display) { /* !!! FIXME: update rotation or current mode of existing display? */ } else { Display *dpy = ev->display; @@ -425,7 +425,7 @@ static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent XVisualInfo vinfo; if (get_visualinfo(dpy, screen, &vinfo) == 0) { XRRScreenResources *res = X11_XRRGetScreenResourcesCurrent(dpy, RootWindow(dpy, screen)); - if (res == NULL || res->noutput == 0) { + if (!res || res->noutput == 0) { if (res) { X11_XRRFreeScreenResources(res); } @@ -481,13 +481,13 @@ static int X11_InitModes_XRandR(_THIS) } res = X11_XRRGetScreenResourcesCurrent(dpy, RootWindow(dpy, screen)); - if (res == NULL || res->noutput == 0) { + if (!res || res->noutput == 0) { if (res) { X11_XRRFreeScreenResources(res); } res = X11_XRRGetScreenResources(dpy, RootWindow(dpy, screen)); - if (res == NULL) { + if (!res) { continue; } } @@ -525,7 +525,7 @@ static int GetXftDPI(Display *dpy) xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi"); - if (xdefault_resource == NULL) { + if (!xdefault_resource) { return 0; } @@ -578,12 +578,12 @@ static int X11_InitModes_StdXlib(_THIS) mode.refresh_rate = 0; /* don't know it, sorry. */ displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return SDL_OutOfMemory(); } modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { SDL_free(displaydata); return SDL_OutOfMemory(); } @@ -683,7 +683,7 @@ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display) if (output_info && output_info->connection != RR_Disconnected) { for (i = 0; i < output_info->nmode; ++i) { modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { continue; } mode.driverdata = modedata; @@ -750,18 +750,18 @@ int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *sdl_display, SDL_DisplayMode *mo Status status; res = X11_XRRGetScreenResources(display, RootWindow(display, data->screen)); - if (res == NULL) { + if (!res) { return SDL_SetError("Couldn't get XRandR screen resources"); } output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); - if (output_info == NULL || output_info->connection == RR_Disconnected) { + if (!output_info || output_info->connection == RR_Disconnected) { X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR output info"); } crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); - if (crtc == NULL) { + if (!crtc) { X11_XRRFreeOutputInfo(output_info); X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR crtc info"); diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 7c3d20216..c3ed9cc21 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -88,7 +88,7 @@ static Cursor X11_CreateXCursorCursor(SDL_Surface *surface, int hot_x, int hot_y XcursorImage *image; image = X11_XcursorImageCreate(surface->w, surface->h); - if (image == NULL) { + if (!image) { SDL_OutOfMemory(); return None; } @@ -121,13 +121,13 @@ static Cursor X11_CreatePixmapCursor(SDL_Surface *surface, int hot_x, int hot_y) size_t width_bytes = ((surface->w + 7) & ~((size_t)7)) / 8; data_bits = SDL_calloc(1, surface->h * width_bytes); - if (data_bits == NULL) { + if (!data_bits) { SDL_OutOfMemory(); return None; } mask_bits = SDL_calloc(1, surface->h * width_bytes); - if (mask_bits == NULL) { + if (!mask_bits) { SDL_free(data_bits); SDL_OutOfMemory(); return None; @@ -419,7 +419,7 @@ static Uint32 X11_GetGlobalMouseState(int *x, int *y) if (videodata->global_mouse_changed) { for (i = 0; i < num_screens; i++) { SDL_DisplayData *data = (SDL_DisplayData *)SDL_GetDisplayDriverData(i); - if (data != NULL) { + if (data) { Window root, child; int rootx, rooty, winx, winy; unsigned int mask; @@ -476,7 +476,7 @@ void X11_QuitMouse(_THIS) SDL_XInput2DeviceInfo *i; SDL_XInput2DeviceInfo *next; - for (i = data->mouse_device_info; i != NULL; i = next) { + for (i = data->mouse_device_info; i; i = next) { next = i->next; SDL_free(i); } diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 4a8d9462f..3d4dd4930 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -35,7 +35,7 @@ SDL_WindowShaper *X11_CreateShaper(SDL_Window *window) #if SDL_VIDEO_DRIVER_X11_XSHAPE if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ result = SDL_malloc(sizeof(SDL_WindowShaper)); - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -44,7 +44,7 @@ SDL_WindowShaper *X11_CreateShaper(SDL_Window *window) result->mode.parameters.binarizationCutoff = 1; result->userx = result->usery = 0; data = SDL_malloc(sizeof(SDL_ShapeData)); - if (data == NULL) { + if (!data) { SDL_free(result); SDL_OutOfMemory(); return NULL; @@ -69,17 +69,17 @@ int X11_ResizeWindowShape(SDL_Window *window) { SDL_ShapeData *data = window->shaper->driverdata; unsigned int bitmapsize = window->w / 8; - SDL_assert(data != NULL); + SDL_assert(data); if (window->w % 8 > 0) { bitmapsize += 1; } bitmapsize *= window->h; - if (data->bitmapsize != bitmapsize || data->bitmap == NULL) { + if (data->bitmapsize != bitmapsize || !data->bitmap) { data->bitmapsize = bitmapsize; SDL_free(data->bitmap); data->bitmap = SDL_malloc(data->bitmapsize); - if (data->bitmap == NULL) { + if (!data->bitmap) { return SDL_OutOfMemory(); } } @@ -98,7 +98,7 @@ int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowS SDL_WindowData *windowdata = NULL; Pixmap shapemask; - if (shaper == NULL || shape == NULL || shaper->driverdata == NULL) { + if (!shaper || !shape || !shaper->driverdata) { return -1; } diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index e2b36a849..5a23ab426 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -125,7 +125,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) if (!safety_net_triggered) { safety_net_triggered = SDL_TRUE; device = SDL_GetVideoDevice(); - if (device != NULL) { + if (device) { int i; for (i = 0; i < device->num_displays; i++) { SDL_VideoDisplay *display = &device->displays[i]; @@ -137,7 +137,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) } } - if (orig_x11_errhandler != NULL) { + if (orig_x11_errhandler) { return orig_x11_errhandler(d, e); /* probably terminate. */ } @@ -162,19 +162,19 @@ static SDL_VideoDevice *X11_CreateDevice(void) /* Open the display first to be sure that X11 is available */ x11_display = X11_XOpenDisplay(display); - if (x11_display == NULL) { + if (!x11_display) { SDL_X11_UnloadSymbols(); return NULL; } /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } data = (struct SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_free(device); SDL_OutOfMemory(); return NULL; @@ -189,7 +189,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) data->display = x11_display; data->request_display = X11_XOpenDisplay(display); - if (data->request_display == NULL) { + if (!data->request_display) { X11_XCloseDisplay(data->display); SDL_free(device->driverdata); SDL_free(device); diff --git a/src/video/x11/SDL_x11vulkan.c b/src/video/x11/SDL_x11vulkan.c index 07b4a8028..fd31aae6f 100644 --- a/src/video/x11/SDL_x11vulkan.c +++ b/src/video/x11/SDL_x11vulkan.c @@ -56,10 +56,10 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -83,7 +83,7 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { @@ -107,7 +107,7 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) goto fail; } else { const char *libX11XCBLibraryName = SDL_getenv("SDL_X11_XCB_LIBRARY"); - if (libX11XCBLibraryName == NULL) { + if (!libX11XCBLibraryName) { libX11XCBLibraryName = "libX11-xcb.so"; } videoData->vulkan_xlib_xcb_library = SDL_LoadObject(libX11XCBLibraryName); diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 2a2a160f8..5cdf73dae 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -256,7 +256,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created) /* Allocate the window data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->window = window; @@ -284,7 +284,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created) (numwindows + 1) * sizeof(*windowlist)); - if (windowlist == NULL) { + if (!windowlist) { SDL_free(data); return SDL_OutOfMemory(); } @@ -394,7 +394,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) #if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL const char *forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID); - if (forced_visual_id != NULL && forced_visual_id[0] != '\0') { + if (forced_visual_id && forced_visual_id[0] != '\0') { XVisualInfo *vi, template; int nvis; @@ -416,7 +416,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) #if SDL_VIDEO_OPENGL_GLX - && ( !_this->gl_data || X11_GL_UseEGL(_this) ) + && (!_this->gl_data || X11_GL_UseEGL(_this) ) #endif ) { vinfo = X11_GLES_GetVisual(_this, display, screen); @@ -428,7 +428,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) #endif } - if (vinfo == NULL) { + if (!vinfo) { return -1; } visual = vinfo->visual; @@ -465,7 +465,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) /* OK, we got a colormap, now fill it in as best as we can */ colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); - if (colorcells == NULL) { + if (!colorcells) { return SDL_OutOfMemory(); } ncolors = visual->map_entries; @@ -592,7 +592,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) wintype_name = "_NET_WM_WINDOW_TYPE_TOOLTIP"; } else if (window->flags & SDL_WINDOW_POPUP_MENU) { wintype_name = "_NET_WM_WINDOW_TYPE_POPUP_MENU"; - } else if (hint != NULL && *hint) { + } else if (hint && *hint) { wintype_name = hint; } else { wintype_name = "_NET_WM_WINDOW_TYPE_NORMAL"; @@ -639,7 +639,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) #if SDL_VIDEO_OPENGL_GLX - && ( !_this->gl_data || X11_GL_UseEGL(_this) ) + && (!_this->gl_data || X11_GL_UseEGL(_this) ) #endif ) { #if SDL_VIDEO_OPENGL_EGL @@ -1612,7 +1612,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != NULL) { + if (ret) { X11_XFree(ret); } X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); @@ -1662,7 +1662,7 @@ void *X11_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) } ret_icc_profile_data = SDL_malloc(real_nitems); - if (ret_icc_profile_data == NULL) { + if (!ret_icc_profile_data) { SDL_OutOfMemory(); return NULL; } @@ -1679,7 +1679,7 @@ void X11_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; - if (data == NULL) { + if (!data) { return; } data->mouse_grabbed = SDL_FALSE; @@ -1734,7 +1734,7 @@ void X11_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; - if (data == NULL) { + if (!data) { return; } @@ -1813,7 +1813,7 @@ SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display; - if (data == NULL) { + if (!data) { /* This sometimes happens in SDL_IBus_UpdateTextRect() while creating the window */ SDL_SetError("Window not initialized"); return SDL_FALSE; @@ -1860,7 +1860,7 @@ int X11_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) XWMHints *wmhints; wmhints = X11_XGetWMHints(display, data->xwindow); - if (wmhints == NULL) { + if (!wmhints) { return SDL_SetError("Couldn't get WM hints"); } diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c index 2189f231d..3c988bc3d 100644 --- a/src/video/x11/SDL_x11xfixes.c +++ b/src/video/x11/SDL_x11xfixes.c @@ -120,7 +120,7 @@ int X11_ConfineCursorWithFlags(_THIS, SDL_Window *window, const SDL_Rect *rect, X11_DestroyPointerBarrier(_this, data->active_cursor_confined_window); } - SDL_assert(window != NULL); + SDL_assert(window); wdata = (SDL_WindowData *)window->driverdata; /* If user did not specify an area to confine, destroy the barrier that was/is assigned to diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 4fe205b7e..2abb00817 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -188,10 +188,10 @@ static void xinput2_remove_device_info(SDL_VideoData *videodata, const int devic SDL_XInput2DeviceInfo *prev = NULL; SDL_XInput2DeviceInfo *devinfo; - for (devinfo = videodata->mouse_device_info; devinfo != NULL; devinfo = devinfo->next) { + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { - SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev == NULL) { + SDL_assert((devinfo == videodata->mouse_device_info) == (!prev)); + if (!prev) { videodata->mouse_device_info = devinfo->next; } else { prev->next = devinfo->next; @@ -212,10 +212,10 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, int axis = 0; int i; - for (devinfo = videodata->mouse_device_info; devinfo != NULL; devinfo = devinfo->next) { + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { - SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev != NULL) { /* move this to the front of the list, assuming we'll get more from this one. */ + SDL_assert((devinfo == videodata->mouse_device_info) == (!prev)); + if (prev) { /* move this to the front of the list, assuming we'll get more from this one. */ prev->next = devinfo->next; devinfo->next = videodata->mouse_device_info; videodata->mouse_device_info = devinfo; @@ -227,13 +227,13 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, /* don't know about this device yet, query and cache it. */ devinfo = (SDL_XInput2DeviceInfo *)SDL_calloc(1, sizeof(SDL_XInput2DeviceInfo)); - if (devinfo == NULL) { + if (!devinfo) { SDL_OutOfMemory(); return NULL; } xidevinfo = X11_XIQueryDevice(videodata->display, device_id, &i); - if (xidevinfo == NULL) { + if (!xidevinfo) { SDL_free(devinfo); return NULL; } @@ -287,7 +287,7 @@ int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie } devinfo = xinput2_get_device_info(videodata, rawev->deviceid); - if (devinfo == NULL) { + if (!devinfo) { return 0; /* oh well. */ } diff --git a/test/checkkeys.c b/test/checkkeys.c index 4efdc721e..d4e15846d 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 3db5dd2dc..22983b157 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 cfb0effac..4f91588b2 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 156767c20..18bb0ad74 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 70dd072d2..d7e7d408a 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 e4bd9ac09..35e65a99c 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 ae59cbcc8..2e0f09048 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 2150ed246..6f3448aa6 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 9fa7ef02d..19b1a9f58 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 b03524489..9cf48effe 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 5b681fcc5..9228b17d2 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_surface.c b/test/testautomation_surface.c index 41aa24142..e241d8b0d 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -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); diff --git a/test/testautomation_video.c b/test/testautomation_video.c index fb81cff2e..f340edcd8 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; } @@ -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; } diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index dc1c3718c..c76fed362 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -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;) { diff --git a/test/testdisplayinfo.c b/test/testdisplayinfo.c index 66cc5d875..5dd9543bc 100644 --- a/test/testdisplayinfo.c +++ b/test/testdisplayinfo.c @@ -20,7 +20,7 @@ static void print_mode(const char *prefix, const SDL_DisplayMode *mode) { - if (mode == NULL) { + if (!mode) { return; } diff --git a/test/testdraw2.c b/test/testdraw2.c index f660c2845..1bff58fbc 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -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;) { diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 8ff21a4c4..b46c91311 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -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; } diff --git a/test/testdropfile.c b/test/testdropfile.c index b80633365..1e3d299de 100644 --- a/test/testdropfile.c +++ b/test/testdropfile.c @@ -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; } diff --git a/test/testerror.c b/test/testerror.c index f3f11b661..956399620 100644 --- a/test/testerror.c +++ b/test/testerror.c @@ -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); } diff --git a/test/testfile.c b/test/testfile.c index 40d52ca22..8f68b1b8d 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -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)) { diff --git a/test/testfilesystem.c b/test/testfilesystem.c index f452d7761..cc5fdd3f0 100644 --- a/test/testfilesystem.c +++ b/test/testfilesystem.c @@ -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 { diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index e2bdebdec..19edb28e2 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -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; diff --git a/test/testgeometry.c b/test/testgeometry.c index 9742a1416..2dee988ae 100644 --- a/test/testgeometry.c +++ b/test/testgeometry.c @@ -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); } diff --git a/test/testgesture.c b/test/testgesture.c index f37635f33..f1510c065 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -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; } diff --git a/test/testgl2.c b/test/testgl2.c index b58798c32..1d34d4c1c 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -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;) { diff --git a/test/testgles.c b/test/testgles.c index 498dbce5c..dd7897403 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -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); } diff --git a/test/testgles2.c b/test/testgles2.c index 656e5e611..82740fa0f 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -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); } diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c index 91f49064a..534405f1a 100644 --- a/test/testgles2_sdf.c +++ b/test/testgles2_sdf.c @@ -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 { diff --git a/test/testhaptic.c b/test/testhaptic.c index fa4186376..e92181654 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -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(); diff --git a/test/testhittesting.c b/test/testhittesting.c index 92ddf8c42..94c5ea9ae 100644 --- a/test/testhittesting.c +++ b/test/testhittesting.c @@ -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 { diff --git a/test/testhotplug.c b/test/testhotplug.c index 1ac73a7fb..462667d95 100644 --- a/test/testhotplug.c +++ b/test/testhotplug.c @@ -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); diff --git a/test/testiconv.c b/test/testiconv.c index b2d13a6aa..3ae1a1b0d 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -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; } diff --git a/test/testime.c b/test/testime.c index 51f685b1e..00b63c6f1 100644 --- a/test/testime.c +++ b/test/testime.c @@ -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; } diff --git a/test/testintersections.c b/test/testintersections.c index f24d9fbf5..5fe0a6e04 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -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;) { diff --git a/test/testjoystick.c b/test/testjoystick.c index adb31dc14..12bd16e09 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -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; diff --git a/test/testloadso.c b/test/testloadso.c index f404a6813..ac6267c00 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -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; diff --git a/test/testlocale.c b/test/testlocale.c index f8ff1a37b..5a95114df 100644 --- a/test/testlocale.c +++ b/test/testlocale.c @@ -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; diff --git a/test/testlock.c b/test/testlock.c index 544ec322b..d2912dd5e 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -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); } diff --git a/test/testmouse.c b/test/testmouse.c index d1c4edc06..d871266a1 100644 --- a/test/testmouse.c +++ b/test/testmouse.c @@ -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; diff --git a/test/testnative.c b/test/testnative.c index e803b822d..5ff197bf2 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -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); } diff --git a/test/testnativew32.c b/test/testnativew32.c index e1574583d..37680a23f 100644 --- a/test/testnativew32.c +++ b/test/testnativew32.c @@ -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; diff --git a/test/testoffscreen.c b/test/testoffscreen.c index fa511e8ce..113c41fed 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -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; diff --git a/test/testoverlay2.c b/test/testoverlay2.c index a5dba6863..965339468 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -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); diff --git a/test/testplatform.c b/test/testplatform.c index 7e89d2f81..fba8a5f86 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -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; diff --git a/test/testrelative.c b/test/testrelative.c index 88ed0bf5a..582b8ffd8 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -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) { diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index de7bc019a..38d393e1c 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -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; } diff --git a/test/testrendertarget.c b/test/testrendertarget.c index 1ae609987..f042fe303 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -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;) { diff --git a/test/testresample.c b/test/testresample.c index 8bb603ac2..cf8e8e734 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -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); diff --git a/test/testrumble.c b/test/testrumble.c index d6288d592..1d71ad4b7 100644 --- a/test/testrumble.c +++ b/test/testrumble.c @@ -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(); diff --git a/test/testscale.c b/test/testscale.c index dca3d0960..ee4bd9c03 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -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; } diff --git a/test/testsensor.c b/test/testsensor.c index 3da7e015e..a122149ac 100644 --- a/test/testsensor.c +++ b/test/testsensor.c @@ -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; diff --git a/test/testshader.c b/test/testshader.c index 2371fcefb..47bce205c 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -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); diff --git a/test/testshape.c b/test/testshape.c index 4e3c12cdd..06f277817 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -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); diff --git a/test/testsprite2.c b/test/testsprite2.c index 01c614883..ba1ff1d36 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -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); } diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 16b4fa4a3..a255ebef9 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -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); } diff --git a/test/teststreaming.c b/test/teststreaming.c index 15c1aefea..a233e11a2 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -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); } diff --git a/test/testthread.c b/test/testthread.c index f6d967560..2370e6434 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -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); } diff --git a/test/testutils.c b/test/testutils.c index 20efef027..6d93afd84 100644 --- a/test/testutils.c +++ b/test/testutils.c @@ -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()); } } diff --git a/test/testviewport.c b/test/testviewport.c index 932f24832..f69ee9c83 100644 --- a/test/testviewport.c +++ b/test/testviewport.c @@ -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); } diff --git a/test/testvulkan.c b/test/testvulkan.c index acdde28fd..2c93e18f3 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -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; } diff --git a/test/testwm2.c b/test/testwm2.c index 7fc189bd7..aafa88830 100644 --- a/test/testwm2.c +++ b/test/testwm2.c @@ -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; } diff --git a/test/testyuv.c b/test/testyuv.c index e7373a8b1..5c2ff7fbe 100644 --- a/test/testyuv.c +++ b/test/testyuv.c @@ -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; }