SDL: Backport simplify flags PR #7220

From 17515f4aef5cf7df21e78bb05c1a055c6bbc978f Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Sat, 4 Feb 2023 15:51:37 +0100
Subject: [PATCH] Backport simplify flags PR #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                 |  2 +-
 src/events/SDL_mouse.c                    |  6 +-
 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/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                |  2 +-
 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_video.c                     | 14 ++--
 src/video/android/SDL_androidwindow.c     |  2 +-
 src/video/cocoa/SDL_cocoakeyboard.m       |  2 +-
 src/video/cocoa/SDL_cocoawindow.m         |  8 +--
 src/video/riscos/SDL_riscosevents.c       |  8 +--
 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     |  2 +-
 src/video/windows/SDL_windowsevents.c     | 30 ++++-----
 src/video/windows/SDL_windowskeyboard.c   |  6 +-
 src/video/windows/SDL_windowswindow.c     |  6 +-
 src/video/x11/SDL_x11events.c             |  6 +-
 src/video/x11/SDL_x11window.c             |  9 +--
 test/controllermap.c                      |  4 +-
 test/testime.c                            |  2 +-
 40 files changed, 176 insertions(+), 175 deletions(-)

diff --git a/src/SDL.c b/src/SDL.c
index 28ab83245643..10cbeaaa0582 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -182,12 +182,12 @@ int SDL_InitSubSystem(Uint32 flags)
     SDL_DBus_Init();
 #endif
 
-    if ((flags & SDL_INIT_GAMECONTROLLER)) {
+    if (flags & SDL_INIT_GAMECONTROLLER) {
         /* 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;
     }
@@ -197,7 +197,7 @@ int SDL_InitSubSystem(Uint32 flags)
 #endif
 
 #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;
         }
@@ -209,7 +209,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_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
             if (SDL_EventsInit() < 0) {
@@ -225,7 +225,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_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
             if (SDL_TimerInit() < 0) {
@@ -241,7 +241,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_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
             if (SDL_VideoInit(NULL) < 0) {
@@ -257,7 +257,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_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
             if (SDL_AudioInit(NULL) < 0) {
@@ -273,7 +273,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_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
             if (SDL_JoystickInit() < 0) {
@@ -288,7 +288,7 @@ int SDL_InitSubSystem(Uint32 flags)
 #endif
     }
 
-    if ((flags & SDL_INIT_GAMECONTROLLER)) {
+    if (flags & SDL_INIT_GAMECONTROLLER) {
 #if !SDL_JOYSTICK_DISABLED
         if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
             if (SDL_GameControllerInit() < 0) {
@@ -304,7 +304,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_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
             if (SDL_HapticInit() < 0) {
@@ -320,7 +320,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_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
             if (SDL_SensorInit() < 0) {
@@ -360,7 +360,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_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
             SDL_SensorQuit();
         }
@@ -369,7 +369,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_JOYSTICK_DISABLED
-    if ((flags & SDL_INIT_GAMECONTROLLER)) {
+    if (flags & SDL_INIT_GAMECONTROLLER) {
         /* game controller implies joystick */
         flags |= SDL_INIT_JOYSTICK;
 
@@ -379,7 +379,7 @@ void SDL_QuitSubSystem(Uint32 flags)
         SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
     }
 
-    if ((flags & SDL_INIT_JOYSTICK)) {
+    if (flags & SDL_INIT_JOYSTICK) {
         /* joystick implies events */
         flags |= SDL_INIT_EVENTS;
 
@@ -391,7 +391,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_HAPTIC_DISABLED
-    if ((flags & SDL_INIT_HAPTIC)) {
+    if (flags & SDL_INIT_HAPTIC) {
         if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
             SDL_HapticQuit();
         }
@@ -400,7 +400,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;
 
@@ -412,7 +412,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;
 
@@ -424,7 +424,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_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
             SDL_TimerQuit();
         }
@@ -433,7 +433,7 @@ void SDL_QuitSubSystem(Uint32 flags)
 #endif
 
 #if !SDL_EVENTS_DISABLED
-    if ((flags & SDL_INIT_EVENTS)) {
+    if (flags & SDL_INIT_EVENTS) {
         if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
             SDL_EventsQuit();
         }
diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c
index 372b88853d09..7ffa4dd19e94 100644
--- a/src/audio/SDL_audiotypecvt.c
+++ b/src/audio/SDL_audiotypecvt.c
@@ -294,10 +294,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();
@@ -358,10 +358,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();
@@ -424,10 +424,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 */
@@ -477,10 +477,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);
@@ -529,10 +529,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;
@@ -579,10 +579,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);
@@ -642,10 +642,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);
@@ -705,10 +705,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);
@@ -766,10 +766,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
@@ -835,8 +835,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. */
@@ -890,10 +890,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);
@@ -946,10 +946,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);
@@ -1003,10 +1003,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 */
@@ -1052,10 +1052,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);
@@ -1100,10 +1100,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;
@@ -1150,10 +1150,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);
@@ -1215,10 +1215,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);
@@ -1281,10 +1281,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);
@@ -1342,10 +1342,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);
@@ -1403,8 +1403,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 9d6621bfa18e..d93b064524f3 100644
--- a/src/audio/directsound/SDL_directsound.c
+++ b/src/audio/directsound/SDL_directsound.c
@@ -229,10 +229,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 32d3ee88b341..bd4567c22122 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -254,7 +254,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 6e4f1d0c0397..65e86a420bad 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -498,7 +498,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 21e81806fe28..9f802213abce 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -997,7 +997,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 a359c8e38f58..fa0a582e7cb5 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -319,7 +319,7 @@ static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, int x, int y, Uint32 bu
     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)) {
         int w, h;
         SDL_GetWindowSize(window, &w, &h);
         if (x < 0 || y < 0 || x >= w || y >= h) {
@@ -509,7 +509,7 @@ static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, i
                 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 {
@@ -559,7 +559,7 @@ static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, i
 
     /* 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 = 0;
         int y_min = 0, y_max = 0;
         const SDL_Rect *confine = SDL_GetWindowMouseRect(window);
diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c
index 9c37f1ad12f6..f3b931a8d467 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 b80c5ac0a9e7..b4c7e694c710 100644
--- a/src/joystick/hidapi/SDL_hidapi_gamecube.c
+++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c
@@ -188,7 +188,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] == -1) {
@@ -313,7 +313,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] == -1) {
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 1781f9d98c9f..ab288357207b 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -321,16 +321,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;
         }
 
@@ -899,7 +899,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;
@@ -944,12 +944,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_PrivateJoystickTouchpad(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_PrivateJoystickTouchpad(joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
@@ -1016,7 +1016,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 3e63607af291..389556ae7ee4 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -437,19 +437,19 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
 #ifdef DEBUG_PS5_PROTOCOL
         HIDAPI_DumpPacket("PS5 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;
         }
-        if ((capabilities2 & 0x80) != 0) {
+        if (capabilities2 & 0x80) {
             ctx->playerled_supported = SDL_TRUE;
         }
 
@@ -1239,12 +1239,12 @@ static void HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
     int touchpad_x, touchpad_y;
 
     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_PrivateJoystickTouchpad(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_PrivateJoystickTouchpad(joystick, 0, 1, touchpad_state, touchpad_x * TOUCHPAD_SCALEX, touchpad_y * TOUCHPAD_SCALEY, touchpad_state ? 1.0f : 0.0f);
@@ -1

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