SDL: Simplify flags testing (#7220)

From cb6b8b0132cdabe1e6ab6f76854ddfe0074c02a0 Mon Sep 17 00:00:00 2001
From: Sylvain Becker <[EMAIL REDACTED]>
Date: Fri, 3 Feb 2023 22:08:42 +0100
Subject: [PATCH] Simplify flags testing (#7220)

---
 src/SDL.c                                   | 38 +++++-----
 src/audio/SDL_audiotypecvt.c                | 80 ++++++++++-----------
 src/audio/directsound/SDL_directsound.c     |  4 +-
 src/core/linux/SDL_evdev.c                  |  2 +-
 src/cpuinfo/SDL_cpuinfo.c                   |  2 +-
 src/events/SDL_keyboard.c                   |  6 +-
 src/events/SDL_mouse.c                      |  6 +-
 src/events/SDL_windowevents.c               |  4 +-
 src/haptic/SDL_haptic.c                     | 10 +--
 src/joystick/hidapi/SDL_hidapi_gamecube.c   |  4 +-
 src/joystick/hidapi/SDL_hidapi_ps4.c        | 16 ++---
 src/joystick/hidapi/SDL_hidapi_ps5.c        | 18 ++---
 src/joystick/hidapi/SDL_hidapi_shield.c     |  2 +-
 src/joystick/hidapi/SDL_hidapi_steam.c      |  2 +-
 src/joystick/hidapi/SDL_hidapi_xboxone.c    |  4 +-
 src/joystick/windows/SDL_dinputjoystick.c   |  4 +-
 src/render/SDL_render.c                     |  4 +-
 src/render/direct3d/SDL_render_d3d.c        |  4 +-
 src/render/direct3d11/SDL_render_d3d11.c    |  2 +-
 src/render/direct3d12/SDL_render_d3d12.c    |  2 +-
 src/stdlib/SDL_iconv.c                      |  2 +-
 src/test/SDL_test_common.c                  | 16 ++---
 src/test/SDL_test_font.c                    |  2 +-
 src/thread/ngage/SDL_systhread.cpp          |  2 +-
 src/video/SDL_blit_0.c                      | 28 ++++----
 src/video/SDL_egl.c                         |  2 +-
 src/video/SDL_surface.c                     |  2 +-
 src/video/SDL_video.c                       | 32 ++++-----
 src/video/android/SDL_androidwindow.c       |  2 +-
 src/video/cocoa/SDL_cocoakeyboard.m         |  2 +-
 src/video/cocoa/SDL_cocoawindow.m           | 10 +--
 src/video/emscripten/SDL_emscriptenevents.c |  2 +-
 src/video/haiku/SDL_bwindow.cc              |  2 +-
 src/video/riscos/SDL_riscosevents.c         |  6 +-
 src/video/uikit/SDL_uikitview.m             |  4 +-
 src/video/vita/SDL_vitavideo.c              |  6 +-
 src/video/wayland/SDL_waylandvideo.c        |  2 +-
 src/video/wayland/SDL_waylandwindow.c       |  4 +-
 src/video/windows/SDL_windowsevents.c       | 30 ++++----
 src/video/windows/SDL_windowskeyboard.c     |  6 +-
 src/video/windows/SDL_windowswindow.c       | 16 ++---
 src/video/x11/SDL_x11events.c               | 14 ++--
 src/video/x11/SDL_x11window.c               | 22 +++---
 test/gamepadmap.c                           |  4 +-
 test/testgamepad.c                          |  2 +-
 test/testime.c                              |  2 +-
 46 files changed, 218 insertions(+), 218 deletions(-)

diff --git a/src/SDL.c b/src/SDL.c
index 48a4d1a43099..9d1d9354a580 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -175,18 +175,18 @@ int SDL_InitSubSystem(Uint32 flags)
     SDL_DBus_Init();
 #endif
 
-    if ((flags & SDL_INIT_GAMEPAD)) {
+    if (flags & SDL_INIT_GAMEPAD) {
         /* game controller implies joystick */
         flags |= SDL_INIT_JOYSTICK;
     }
 
-    if ((flags & (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO))) {
+    if (flags & (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO)) {
         /* video or joystick or audio implies events */
         flags |= SDL_INIT_EVENTS;
     }
 
 #if SDL_VIDEO_DRIVER_WINDOWS
-    if ((flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK))) {
+    if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
         if (SDL_HelperWindowCreate() < 0) {
             goto quit_and_error;
         }
@@ -198,7 +198,7 @@ int SDL_InitSubSystem(Uint32 flags)
 #endif
 
     /* Initialize the event subsystem */
-    if ((flags & SDL_INIT_EVENTS)) {
+    if (flags & SDL_INIT_EVENTS) {
 #if !SDL_EVENTS_DISABLED
         if (SDL_ShouldInitSubsystem(SDL_INIT_EVENTS)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS);
@@ -217,7 +217,7 @@ int SDL_InitSubSystem(Uint32 flags)
     }
 
     /* Initialize the timer subsystem */
-    if ((flags & SDL_INIT_TIMER)) {
+    if (flags & SDL_INIT_TIMER) {
 #if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
         if (SDL_ShouldInitSubsystem(SDL_INIT_TIMER)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_TIMER);
@@ -236,7 +236,7 @@ int SDL_InitSubSystem(Uint32 flags)
     }
 
     /* Initialize the video subsystem */
-    if ((flags & SDL_INIT_VIDEO)) {
+    if (flags & SDL_INIT_VIDEO) {
 #if !SDL_VIDEO_DISABLED
         if (SDL_ShouldInitSubsystem(SDL_INIT_VIDEO)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_VIDEO);
@@ -255,7 +255,7 @@ int SDL_InitSubSystem(Uint32 flags)
     }
 
     /* Initialize the audio subsystem */
-    if ((flags & SDL_INIT_AUDIO)) {
+    if (flags & SDL_INIT_AUDIO) {
 #if !SDL_AUDIO_DISABLED
         if (SDL_ShouldInitSubsystem(SDL_INIT_AUDIO)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_AUDIO);
@@ -274,7 +274,7 @@ int SDL_InitSubSystem(Uint32 flags)
     }
 
     /* Initialize the joystick subsystem */
-    if ((flags & SDL_INIT_JOYSTICK)) {
+    if (flags & SDL_INIT_JOYSTICK) {
 #if !SDL_JOYSTICK_DISABLED
         if (SDL_ShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_JOYSTICK);
@@ -292,7 +292,7 @@ int SDL_InitSubSystem(Uint32 flags)
 #endif
     }
 
-    if ((flags & SDL_INIT_GAMEPAD)) {
+    if (flags & SDL_INIT_GAMEPAD) {
 #if !SDL_JOYSTICK_DISABLED
         if (SDL_ShouldInitSubsystem(SDL_INIT_GAMEPAD)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_GAMEPAD);
@@ -311,7 +311,7 @@ int SDL_InitSubSystem(Uint32 flags)
     }
 
     /* Initialize the haptic subsystem */
-    if ((flags & SDL_INIT_HAPTIC)) {
+    if (flags & SDL_INIT_HAPTIC) {
 #if !SDL_HAPTIC_DISABLED
         if (SDL_ShouldInitSubsystem(SDL_INIT_HAPTIC)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_HAPTIC);
@@ -330,7 +330,7 @@ int SDL_InitSubSystem(Uint32 flags)
     }
 
     /* Initialize the sensor subsystem */
-    if ((flags & SDL_INIT_SENSOR)) {
+    if (flags & SDL_INIT_SENSOR) {
 #if !SDL_SENSOR_DISABLED
         if (SDL_ShouldInitSubsystem(SDL_INIT_SENSOR)) {
             SDL_IncrementSubsystemRefCount(SDL_INIT_SENSOR);
@@ -366,7 +366,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 {
     /* Shut down requested initialized subsystems */
 #if !SDL_SENSOR_DISABLED
-    if ((flags & SDL_INIT_SENSOR)) {
+    if (flags & SDL_INIT_SENSOR) {
         if (SDL_ShouldQuitSubsystem(SDL_INIT_SENSOR)) {
             SDL_QuitSensors();
         }
@@ -375,7 +375,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_JOYSTICK_DISABLED
-    if ((flags & SDL_INIT_GAMEPAD)) {
+    if (flags & SDL_INIT_GAMEPAD) {
         /* game controller implies joystick */
         flags |= SDL_INIT_JOYSTICK;
 
@@ -385,7 +385,7 @@ void SDL_QuitSubSystem(Uint32 flags)
         SDL_DecrementSubsystemRefCount(SDL_INIT_GAMEPAD);
     }
 
-    if ((flags & SDL_INIT_JOYSTICK)) {
+    if (flags & SDL_INIT_JOYSTICK) {
         /* joystick implies events */
         flags |= SDL_INIT_EVENTS;
 
@@ -397,7 +397,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_HAPTIC_DISABLED
-    if ((flags & SDL_INIT_HAPTIC)) {
+    if (flags & SDL_INIT_HAPTIC) {
         if (SDL_ShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
             SDL_QuitHaptics();
         }
@@ -406,7 +406,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_AUDIO_DISABLED
-    if ((flags & SDL_INIT_AUDIO)) {
+    if (flags & SDL_INIT_AUDIO) {
         /* audio implies events */
         flags |= SDL_INIT_EVENTS;
 
@@ -418,7 +418,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_VIDEO_DISABLED
-    if ((flags & SDL_INIT_VIDEO)) {
+    if (flags & SDL_INIT_VIDEO) {
         /* video implies events */
         flags |= SDL_INIT_EVENTS;
 
@@ -430,7 +430,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
-    if ((flags & SDL_INIT_TIMER)) {
+    if (flags & SDL_INIT_TIMER) {
         if (SDL_ShouldQuitSubsystem(SDL_INIT_TIMER)) {
             SDL_QuitTimers();
         }
@@ -439,7 +439,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_EVENTS_DISABLED
-    if ((flags & SDL_INIT_EVENTS)) {
+    if (flags & SDL_INIT_EVENTS) {
         if (SDL_ShouldQuitSubsystem(SDL_INIT_EVENTS)) {
             SDL_QuitEvents();
         }
diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c
index 25479cf13cbd..a82243ab15ff 100644
--- a/src/audio/SDL_audiotypecvt.c
+++ b/src/audio/SDL_audiotypecvt.c
@@ -293,10 +293,10 @@ static void SDLCALL SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma
 
     src -= 15;
     dst -= 15; /* adjust to read SSE blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128i *mmsrc = (const __m128i *)src;
         const __m128i zero = _mm_setzero_si128();
@@ -357,10 +357,10 @@ static void SDLCALL SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma
 
     src -= 15;
     dst -= 15; /* adjust to read SSE blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128i *mmsrc = (const __m128i *)src;
         const __m128i zero = _mm_setzero_si128();
@@ -423,10 +423,10 @@ static void SDLCALL SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm
 
     src -= 7;
     dst -= 7; /* adjust to read SSE blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128 divby32768 = _mm_set1_ps(DIVBY32768);
         while (i >= 8) {                                               /* 8 * 16-bit */
@@ -476,10 +476,10 @@ static void SDLCALL SDL_Convert_U16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm
 
     src -= 7;
     dst -= 7; /* adjust to read SSE blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128 divby32768 = _mm_set1_ps(DIVBY32768);
         const __m128 minus1 = _mm_set1_ps(-1.0f);
@@ -528,10 +528,10 @@ static void SDLCALL SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm
         *dst = ((float)(*src >> 8)) * DIVBY8388607;
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128 divby8388607 = _mm_set1_ps(DIVBY8388607);
         const __m128i *mmsrc = (const __m128i *)src;
@@ -578,10 +578,10 @@ static void SDLCALL SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128 one = _mm_set1_ps(1.0f);
         const __m128 negone = _mm_set1_ps(-1.0f);
@@ -641,10 +641,10 @@ static void SDLCALL SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128 one = _mm_set1_ps(1.0f);
         const __m128 negone = _mm_set1_ps(-1.0f);
@@ -704,10 +704,10 @@ static void SDLCALL SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         const __m128 one = _mm_set1_ps(1.0f);
         const __m128 negone = _mm_set1_ps(-1.0f);
@@ -765,10 +765,10 @@ static void SDLCALL SDL_Convert_F32_to_U16_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
         /* This calculates differently than the scalar path because SSE2 can't
            pack int32 data down to unsigned int16. _mm_packs_epi32 does signed
@@ -834,8 +834,8 @@ static void SDLCALL SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
-    SDL_assert(!i || ((((size_t)src) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
+    SDL_assert(!i || !(((size_t)src) & 15));
 
     {
         /* Aligned! Do SSE blocks as long as we have 16 bytes available. */
@@ -889,10 +889,10 @@ static void SDLCALL SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioForma
 
     src -= 15;
     dst -= 15; /* adjust to read NEON blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const int8_t *mmsrc = (const int8_t *)src;
         const float32x4_t divby128 = vdupq_n_f32(DIVBY128);
@@ -945,10 +945,10 @@ static void SDLCALL SDL_Convert_U8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioForma
 
     src -= 15;
     dst -= 15; /* adjust to read NEON blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const uint8_t *mmsrc = (const uint8_t *)src;
         const float32x4_t divby128 = vdupq_n_f32(DIVBY128);
@@ -1002,10 +1002,10 @@ static void SDLCALL SDL_Convert_S16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioForm
 
     src -= 7;
     dst -= 7; /* adjust to read NEON blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const float32x4_t divby32768 = vdupq_n_f32(DIVBY32768);
         while (i >= 8) {                                            /* 8 * 16-bit */
@@ -1051,10 +1051,10 @@ static void SDLCALL SDL_Convert_U16_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioForm
 
     src -= 7;
     dst -= 7; /* adjust to read NEON blocks from the start. */
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const float32x4_t divby32768 = vdupq_n_f32(DIVBY32768);
         const float32x4_t negone = vdupq_n_f32(-1.0f);
@@ -1099,10 +1099,10 @@ static void SDLCALL SDL_Convert_S32_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioForm
         *dst = ((float)(*src >> 8)) * DIVBY8388607;
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const float32x4_t divby8388607 = vdupq_n_f32(DIVBY8388607);
         const int32_t *mmsrc = (const int32_t *)src;
@@ -1149,10 +1149,10 @@ static void SDLCALL SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioForma
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const float32x4_t one = vdupq_n_f32(1.0f);
         const float32x4_t negone = vdupq_n_f32(-1.0f);
@@ -1214,10 +1214,10 @@ static void SDLCALL SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioForma
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const float32x4_t one = vdupq_n_f32(1.0f);
         const float32x4_t negone = vdupq_n_f32(-1.0f);
@@ -1280,10 +1280,10 @@ static void SDLCALL SDL_Convert_F32_to_S16_NEON(SDL_AudioCVT *cvt, SDL_AudioForm
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const float32x4_t one = vdupq_n_f32(1.0f);
         const float32x4_t negone = vdupq_n_f32(-1.0f);
@@ -1341,10 +1341,10 @@ static void SDLCALL SDL_Convert_F32_to_U16_NEON(SDL_AudioCVT *cvt, SDL_AudioForm
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
 
     /* Make sure src is aligned too. */
-    if ((((size_t)src) & 15) == 0) {
+    if (!(((size_t)src) & 15)) {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
         const float32x4_t one = vdupq_n_f32(1.0f);
         const float32x4_t negone = vdupq_n_f32(-1.0f);
@@ -1402,8 +1402,8 @@ static void SDLCALL SDL_Convert_F32_to_S32_NEON(SDL_AudioCVT *cvt, SDL_AudioForm
         }
     }
 
-    SDL_assert(!i || ((((size_t)dst) & 15) == 0));
-    SDL_assert(!i || ((((size_t)src) & 15) == 0));
+    SDL_assert(!i || !(((size_t)dst) & 15));
+    SDL_assert(!i || !(((size_t)src) & 15));
 
     {
         /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c
index 6001795d7817..65a467a04177 100644
--- a/src/audio/directsound/SDL_directsound.c
+++ b/src/audio/directsound/SDL_directsound.c
@@ -226,10 +226,10 @@ static void DSOUND_WaitDevice(_THIS)
 
         /* Try to restore a lost sound buffer */
         IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
-        if ((status & DSBSTATUS_BUFFERLOST)) {
+        if (status & DSBSTATUS_BUFFERLOST) {
             IDirectSoundBuffer_Restore(this->hidden->mixbuf);
             IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
-            if ((status & DSBSTATUS_BUFFERLOST)) {
+            if (status & DSBSTATUS_BUFFERLOST) {
                 break;
             }
         }
diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 24f744226c42..8fe643eb660d 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -251,7 +251,7 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
             return;
         }
 
-        if ((udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
+        if (udev_class & SDL_UDEV_DEVICE_JOYSTICK) {
             return;
         }
 
diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
index e66be970aa6f..942c3265fd03 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -476,7 +476,7 @@ static int CPU_haveNEON(void)
         AndroidCpuFamily cpu_family = android_getCpuFamily();
         if (cpu_family == ANDROID_CPU_FAMILY_ARM) {
             uint64_t cpu_features = android_getCpuFeatures();
-            if ((cpu_features & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
+            if (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON) {
                 return 1;
             }
         }
diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
index 8081e7001d14..32b8d3b49943 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -930,8 +930,8 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, SDL_KeyboardFlags flags
         state == SDL_PRESSED &&
         (keyboard->modstate & SDL_KMOD_ALT) &&
         keyboard->focus &&
-        (keyboard->focus->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0 &&
-        (keyboard->focus->flags & SDL_WINDOW_FULLSCREEN) != 0 &&
+        (keyboard->focus->flags & SDL_WINDOW_KEYBOARD_GRABBED) &&
+        (keyboard->focus->flags & SDL_WINDOW_FULLSCREEN) &&
         SDL_GetHintBoolean(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, SDL_TRUE)) {
         /* We will temporarily forfeit our grab by minimizing our window,
            allowing the user to escape the application */
@@ -1009,7 +1009,7 @@ SDL_HardwareKeyboardKeyPressed(void)
     SDL_Scancode scancode;
 
     for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) {
-        if ((keyboard->keysource[scancode] & KEYBOARD_HARDWARE) != 0) {
+        if (keyboard->keysource[scancode] & KEYBOARD_HARDWARE) {
             return SDL_TRUE;
         }
     }
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index d0418f847a75..fb8deb89e184 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -310,7 +310,7 @@ static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint3
     SDL_Mouse *mouse = SDL_GetMouse();
     SDL_bool inWindow = SDL_TRUE;
 
-    if (window && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) {
+    if (window && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
         if (x < 0.0f || y < 0.0f || x >= (float)window->w || y >= (float)window->h) {
             inWindow = SDL_FALSE;
         }
@@ -482,7 +482,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
                 return 0;
             }
         } else {
-            if (window && (window->flags & SDL_WINDOW_INPUT_FOCUS) != 0) {
+            if (window && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
                 if (mouse->WarpMouse) {
                     mouse->WarpMouse(window, center_x, center_y);
                 } else {
@@ -532,7 +532,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
 
     /* make sure that the pointers find themselves inside the windows,
        unless we have the mouse captured. */
-    if (window && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) {
+    if (window && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
         int x_min = 0, x_max = window->w - 1;
         int y_min = 0, y_max = window->h - 1;
         const SDL_Rect *confine = SDL_GetWindowMouseRect(window);
diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c
index 5deba6fd9195..befe1ff9713c 100644
--- a/src/events/SDL_windowevents.c
+++ b/src/events/SDL_windowevents.c
@@ -67,7 +67,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
             SDL_WINDOWPOS_ISUNDEFINED(data2)) {
             return 0;
         }
-        if ((window->flags & SDL_WINDOW_FULLSCREEN) == 0) {
+        if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
             window->windowed.x = data1;
             window->windowed.y = data2;
         }
@@ -78,7 +78,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
         window->y = data2;
         break;
     case SDL_EVENT_WINDOW_RESIZED:
-        if ((window->flags & SDL_WINDOW_FULLSCREEN) == 0) {
+        if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
             window->windowed.w = data1;
             window->windowed.h = data2;
         }
diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c
index 98a186379bf3..e3310c7d2162 100644
--- a/src/haptic/SDL_haptic.c
+++ b/src/haptic/SDL_haptic.c
@@ -585,7 +585,7 @@ int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
         return -1;
     }
 
-    if ((haptic->supported & SDL_HAPTIC_STATUS) == 0) {
+    if (!(haptic->supported & SDL_HAPTIC_STATUS)) {
         return SDL_SetError("Haptic: Device does not support status queries.");
     }
 
@@ -604,7 +604,7 @@ int SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
         return -1;
     }
 
-    if ((haptic->supported & SDL_HAPTIC_GAIN) == 0) {
+    if (!(haptic->supported & SDL_HAPTIC_GAIN)) {
         return SDL_SetError("Haptic: Device does not support setting gain.");
     }
 
@@ -646,7 +646,7 @@ int SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
         return -1;
     }
 
-    if ((haptic->supported & SDL_HAPTIC_AUTOCENTER) == 0) {
+    if (!(haptic->supported & SDL_HAPTIC_AUTOCENTER)) {
         return SDL_SetError("Haptic: Device does not support setting autocenter.");
     }
 
@@ -670,7 +670,7 @@ int SDL_HapticPause(SDL_Haptic *haptic)
         return -1;
     }
 
-    if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) {
+    if (!(haptic->supported & SDL_HAPTIC_PAUSE)) {
         return SDL_SetError("Haptic: Device does not support setting pausing.");
     }
 
@@ -686,7 +686,7 @@ int SDL_HapticUnpause(SDL_Haptic *haptic)
         return -1;
     }
 
-    if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) {
+    if (!(haptic->supported & SDL_HAPTIC_PAUSE)) {
         return 0; /* Not going to be paused, so we pretend it's unpaused. */
     }
 
diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c
index bbddf923d690..c108e5cc0254 100644
--- a/src/joystick/hidapi/SDL_hidapi_gamecube.c
+++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c
@@ -183,7 +183,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device)
                 ctx->wireless[i] = (curSlot[0] & 0x20) != 0;
 
                 /* Only allow rumble if the adapter's second USB cable is connected */
-                ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i];
+                ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) && !ctx->wireless[i];
 
                 if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
                     if (ctx->joysticks[i] == 0) {
@@ -312,7 +312,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device
         ctx->wireless[i] = (curSlot[0] & 0x20) != 0;
 
         /* Only allow rumble if the adapter's second USB cable is connected */
-        ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i];
+        ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) && !ctx->wireless[i];
 
         if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
             if (ctx->joysticks[i] == 0) {
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 0b4b3da6b805..5dba5a52fe23 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -317,16 +317,16 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
 #ifdef DEBUG_PS4_PROTOCOL
         HIDAPI_DumpPacket("PS4 capabilities: size = %d", data, size);
 #endif
-        if ((capabilities & 0x02) != 0) {
+        if (capabilities & 0x02) {
             ctx->sensors_supported = SDL_TRUE;
         }
-        if ((capabilities & 0x04) != 0) {
+        if (capabilities & 0x04) {
             ctx->lightbar_supported = SDL_TRUE;
         }
-        if ((capabilities & 0x08) != 0) {
+        if (capabilities & 0x08) {
             ctx->vibration_supported = SDL_TRUE;
         }
-        if ((capabilities & 0x40) != 0) {
+        if (capabilities & 0x40) {
             ctx->touchpad_supported = SDL_TRUE;
         }
 
@@ -895,7 +895,7 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
     /* Some fightsticks, ex: Victrix FS Pro will only this these digital trigger bits and not the analog values so this needs to run whenever the
        trigger is evaluated
     */
-    if ((packet->rgucButtonsHatAndCounter[1] & 0x0C) != 0) {
+    if (packet->rgucButtonsHatAndCounter[1] & 0x0C) {
         Uint8 data = packet->rgucButtonsHatAndCounter[1];
         packet->ucTriggerLeft = (data & 0x04) && packet->ucTriggerLeft == 0 ? 255 : packet->ucTriggerLeft;
         packet->ucTriggerRight = (data & 0x08) && packet->ucTriggerRight == 0 ? 255 : packet->ucTriggerRight;
@@ -940,12 +940,12 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
     }
 
     if (ctx->report_touchpad) {
-        touchpad_state = ((packet->ucTouchpadCounter1 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
+        touchpad_state = !(packet->ucTouchpadCounter1 & 0x80) ? SDL_PRESSED : SDL_RELEASED;
         touchpad_x = packet->rgucTouchpadData1[0] | (((int)packet->rgucTouchpadData1[1] & 0x0F) << 8);
         touchpad_y = (packet->rgucTouchpadData1[1] >> 4) | ((int)packet->rgucTouchpadData1[2] << 4);
         SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
 
-        touchpad_state = ((packet->ucTouchpadCounter2 & 0x80) == 0) ? SDL_PRESSED : SDL_RELEASED;
+        touchpad_state = !(packet->ucTouchpadCounter2 & 0x80) ? SDL_PRESSED : SDL_RELEASED;
         touchpad_x = packet->rgucTouchpadData2[0] | (((int)packet->rgucTouchpadData2[1] & 0x0F) << 8);
         touchpad_y = (packet->rgucTouchpadData2[1] >> 4) | ((int)packet->rgucTouchpadData2[2] << 4);
         SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
@@ -1007,7 +1007,7 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8
          * This is usually the ID over USB, but the DS4v2 that started shipping with the PS4 Slim will also send this
          * packet over BT with a size of 128
          */
-        if (size >= 64 && (data[31] & 0x04) == 0) {
+        if (size >= 64 && !(data[31] & 0x04)) {
             return SDL_TRUE;
         }
         break;
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index c30e72da9f39..a8485e6e7d97 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -433,19 +433,19 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
 #ifdef DEBUG_PS5_PROTOCOL
         HID

(Patch may be truncated, please check the link at the top of this post.)