瀏覽代碼

Code cleanup now that SDL_bool is equivalent to a C boolean expression

Sam Lantinga 1 年之前
父節點
當前提交
f3261fedcc
共有 53 個文件被更改,包括 133 次插入138 次删除
  1. 2 2
      src/SDL.c
  2. 1 1
      src/SDL_hashtable.c
  3. 8 8
      src/atomic/SDL_atomic.c
  4. 2 2
      src/atomic/SDL_spinlock.c
  5. 16 16
      src/audio/SDL_audio.c
  6. 1 1
      src/audio/SDL_audiocvt.c
  7. 1 1
      src/audio/alsa/SDL_alsa_audio.c
  8. 1 1
      src/audio/coreaudio/SDL_coreaudio.m
  9. 4 4
      src/audio/emscripten/SDL_emscriptenaudio.c
  10. 4 4
      src/audio/pulseaudio/SDL_pulseaudio.c
  11. 1 1
      src/audio/wasapi/SDL_wasapi_winrt.cpp
  12. 3 4
      src/core/android/SDL_android.c
  13. 1 1
      src/core/linux/SDL_dbus.c
  14. 1 1
      src/core/linux/SDL_ibus.c
  15. 1 1
      src/events/SDL_events.c
  16. 2 2
      src/events/SDL_mouse.c
  17. 7 7
      src/file/SDL_rwops.c
  18. 1 1
      src/haptic/windows/SDL_xinputhaptic.c
  19. 1 1
      src/joystick/SDL_joystick.c
  20. 1 1
      src/joystick/hidapi/SDL_hidapi_ps4.c
  21. 1 1
      src/joystick/hidapi/SDL_hidapi_ps5.c
  22. 2 2
      src/joystick/hidapi/SDL_hidapi_switch.c
  23. 4 4
      src/joystick/hidapi/SDL_hidapi_wii.c
  24. 2 2
      src/joystick/hidapi/SDL_hidapi_xbox360.c
  25. 1 1
      src/joystick/hidapi/SDL_hidapi_xboxone.c
  26. 1 1
      src/joystick/windows/SDL_rawinputjoystick.c
  27. 2 2
      src/joystick/windows/SDL_windowsjoystick.c
  28. 1 1
      src/joystick/windows/SDL_xinputjoystick.c
  29. 1 1
      src/render/direct3d/SDL_render_d3d.c
  30. 1 1
      src/sensor/SDL_sensor.c
  31. 1 1
      src/stdlib/SDL_string.c
  32. 3 3
      src/test/SDL_test_common.c
  33. 5 5
      src/video/SDL_shape.c
  34. 15 15
      src/video/SDL_video.c
  35. 1 1
      src/video/emscripten/SDL_emscriptenvideo.c
  36. 1 1
      src/video/gdk/SDL_gdktextinput.cpp
  37. 1 1
      src/video/haiku/SDL_bclipboard.cc
  38. 3 3
      src/video/wayland/SDL_waylandevents.c
  39. 1 1
      src/video/wayland/SDL_waylandtouch.c
  40. 1 1
      src/video/wayland/SDL_waylandvideo.c
  41. 2 2
      src/video/wayland/SDL_waylandwindow.c
  42. 2 2
      src/video/windows/SDL_windowsevents.c
  43. 2 2
      src/video/windows/SDL_windowskeyboard.c
  44. 1 4
      src/video/windows/SDL_windowsopengl.c
  45. 1 2
      src/video/windows/SDL_windowsvideo.c
  46. 1 1
      src/video/x11/SDL_x11video.c
  47. 1 1
      src/video/x11/SDL_x11xinput2.c
  48. 1 1
      test/checkkeys.c
  49. 1 1
      test/checkkeysthreads.c
  50. 8 8
      test/testatomic.c
  51. 3 3
      test/testaudio.c
  52. 2 2
      test/testaudiostreamdynamicresample.c
  53. 1 1
      test/testshader.c

+ 2 - 2
src/SDL.c

@@ -137,7 +137,7 @@ static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem)
 {
     const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
     SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
-    return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) ? SDL_TRUE : SDL_FALSE;
+    return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0));
 }
 
 /* Private helper to check if a system needs to be quit. */
@@ -151,7 +151,7 @@ static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
     /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
      * isn't zero.
      */
-    return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
+    return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit);
 }
 
 void SDL_SetMainReady(void)

+ 1 - 1
src/SDL_hashtable.c

@@ -256,7 +256,7 @@ SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *data)
     } else if (!a || !b) {
         return SDL_FALSE;  // one pointer is NULL (and first test shows they aren't the same pointer), must not match.
     }
-    return (SDL_strcmp((const char *)a, (const char *)b) == 0) ? SDL_TRUE : SDL_FALSE;  // Check against actual string contents.
+    return (SDL_strcmp((const char *)a, (const char *)b) == 0);  // Check against actual string contents.
 }
 
 // We assume we can fit the ID in the key directly

+ 8 - 8
src/atomic/SDL_atomic.c

@@ -128,13 +128,13 @@ SDL_bool SDL_AtomicCAS(SDL_AtomicInt *a, int oldval, int newval)
     SDL_COMPILE_TIME_ASSERT(atomic_cas, sizeof(long) == sizeof(a->value));
     return _InterlockedCompareExchange((long *)&a->value, (long)newval, (long)oldval) == (long)oldval;
 #elif defined(HAVE_WATCOM_ATOMICS)
-    return (SDL_bool)_SDL_cmpxchg_watcom(&a->value, newval, oldval);
+    return _SDL_cmpxchg_watcom(&a->value, newval, oldval);
 #elif defined(HAVE_GCC_ATOMICS)
-    return (SDL_bool)__sync_bool_compare_and_swap(&a->value, oldval, newval);
+    return __sync_bool_compare_and_swap(&a->value, oldval, newval);
 #elif defined(__MACOS__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */
-    return (SDL_bool)OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value);
+    return OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value);
 #elif defined(__SOLARIS__)
-    return (SDL_bool)((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
+    return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
 #elif defined(EMULATE_CAS)
     SDL_bool retval = SDL_FALSE;
 
@@ -156,15 +156,15 @@ SDL_bool SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
 #ifdef HAVE_MSC_ATOMICS
     return _InterlockedCompareExchangePointer(a, newval, oldval) == oldval;
 #elif defined(HAVE_WATCOM_ATOMICS)
-    return (SDL_bool)_SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval);
+    return _SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval);
 #elif defined(HAVE_GCC_ATOMICS)
     return __sync_bool_compare_and_swap(a, oldval, newval);
 #elif defined(__MACOS__) && defined(__LP64__)  /* this is deprecated in 10.12 sdk; favor gcc atomics. */
-    return (SDL_bool)OSAtomicCompareAndSwap64Barrier((int64_t)oldval, (int64_t)newval, (int64_t *)a);
+    return OSAtomicCompareAndSwap64Barrier((int64_t)oldval, (int64_t)newval, (int64_t *)a);
 #elif defined(__MACOS__) && !defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */
-    return (SDL_bool)OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t *)a);
+    return OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t *)a);
 #elif defined(__SOLARIS__)
-    return (SDL_bool)(atomic_cas_ptr(a, oldval, newval) == oldval);
+    return (atomic_cas_ptr(a, oldval, newval) == oldval);
 #elif defined(EMULATE_CAS)
     SDL_bool retval = SDL_FALSE;
 

+ 2 - 2
src/atomic/SDL_spinlock.c

@@ -139,11 +139,11 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
 
 #elif defined(__SOLARIS__) && defined(_LP64)
     /* Used for Solaris with non-gcc compilers. */
-    return (SDL_bool)((int)atomic_cas_64((volatile uint64_t *)lock, 0, 1) == 0);
+    return ((int)atomic_cas_64((volatile uint64_t *)lock, 0, 1) == 0);
 
 #elif defined(__SOLARIS__) && !defined(_LP64)
     /* Used for Solaris with non-gcc compilers. */
-    return (SDL_bool)((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0);
+    return ((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0);
 #elif defined(PS2)
     uint32_t oldintr;
     SDL_bool res = SDL_FALSE;

+ 16 - 16
src/audio/SDL_audio.c

@@ -190,7 +190,7 @@ static SDL_bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device)
         !device->logical_devices->postmix && // there isn't a postmix callback
         device->logical_devices->bound_streams &&  // there's a bound stream
         !device->logical_devices->bound_streams->next_binding  // there's only _ONE_ bound stream.
-    ) ? SDL_TRUE : SDL_FALSE;
+    );
 }
 
 // should hold device->lock before calling.
@@ -320,7 +320,7 @@ static SDL_LogicalAudioDevice *ObtainLogicalAudioDevice(SDL_AudioDeviceID devid,
     SDL_LogicalAudioDevice *logdev = NULL;
 
     // bit #1 of devid is set for physical devices and unset for logical.
-    const SDL_bool islogical = (devid & (1<<1)) ? SDL_FALSE : SDL_TRUE;
+    const SDL_bool islogical = !(devid & (1<<1));
     if (islogical) {  // don't bother looking if it's not a logical device id value.
         SDL_LockRWLockForReading(current_audio.device_hash_lock);
         SDL_FindInHashTable(current_audio.device_hash, (const void *) (uintptr_t) devid, (const void **) &logdev);
@@ -349,7 +349,7 @@ static SDL_AudioDevice *ObtainPhysicalAudioDevice(SDL_AudioDeviceID devid)  // !
     SDL_AudioDevice *device = NULL;
 
     // bit #1 of devid is set for physical devices and unset for logical.
-    const SDL_bool islogical = (devid & (1<<1)) ? SDL_FALSE : SDL_TRUE;
+    const SDL_bool islogical = !(devid & (1<<1));
     if (islogical) {
         ObtainLogicalAudioDevice(devid, &device);
     } else if (!SDL_GetCurrentAudioDriver()) {  // (the `islogical` path, above, checks this in ObtainLogicalAudioDevice.)
@@ -371,7 +371,7 @@ static SDL_AudioDevice *ObtainPhysicalAudioDevice(SDL_AudioDeviceID devid)  // !
 
 static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceID devid)  // !!! FIXME: SDL_ACQUIRE
 {
-    const SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) || (devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE)) ? SDL_TRUE : SDL_FALSE;
+    const SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) || (devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE));
     if (!wants_default) {
         return ObtainPhysicalAudioDevice(devid);
     }
@@ -623,7 +623,7 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
 
     SDL_LockRWLockForReading(current_audio.device_hash_lock);
     const SDL_AudioDeviceID devid = device->instance_id;
-    const SDL_bool is_default_device = ((devid == current_audio.default_output_device_id) || (devid == current_audio.default_capture_device_id)) ? SDL_TRUE : SDL_FALSE;
+    const SDL_bool is_default_device = ((devid == current_audio.default_output_device_id) || (devid == current_audio.default_capture_device_id));
     SDL_UnlockRWLock(current_audio.device_hash_lock);
 
     const SDL_bool first_disconnect = SDL_AtomicCAS(&device->zombie, 0, 1);
@@ -763,8 +763,8 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool iscapture)
         const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
         // bit #0 of devid is set for output devices and unset for capture.
         // bit #1 of devid is set for physical devices and unset for logical.
-        const SDL_bool devid_iscapture = (devid & (1 << 0)) ? SDL_FALSE : SDL_TRUE;
-        const SDL_bool isphysical = (devid & (1 << 1)) ? SDL_TRUE : SDL_FALSE;
+        const SDL_bool devid_iscapture = !(devid & (1 << 0));
+        const SDL_bool isphysical = (devid & (1 << 1));
         if (isphysical && (devid_iscapture == iscapture) && (devid < highest)) {
             highest = devid;
             retval = (SDL_AudioDevice *) value;
@@ -784,7 +784,7 @@ static Uint32 HashAudioDeviceID(const void *key, void *data)
 
 static SDL_bool MatchAudioDeviceID(const void *a, const void *b, void *data)
 {
-    return (a == b) ? SDL_TRUE : SDL_FALSE;  // they're simple Uint32 values cast to pointers.
+    return (a == b);
 }
 
 static void NukeAudioDeviceHashItem(const void *key, const void *value, void *data)
@@ -966,7 +966,7 @@ void SDL_QuitAudio(void)
     while (SDL_IterateHashTable(device_hash, &key, &value, &iter)) {
         // bit #1 of devid is set for physical devices and unset for logical.
         const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
-        const SDL_bool isphysical = (devid & (1<<1)) ? SDL_TRUE : SDL_FALSE;
+        const SDL_bool isphysical = (devid & (1<<1));
         if (isphysical) {
             DestroyPhysicalAudioDevice((SDL_AudioDevice *) value);
         }
@@ -1273,8 +1273,8 @@ static SDL_AudioDeviceID *GetAudioDevices(int *reqcount, SDL_bool iscapture)
                 const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
                 // bit #0 of devid is set for output devices and unset for capture.
                 // bit #1 of devid is set for physical devices and unset for logical.
-                const SDL_bool devid_iscapture = (devid & (1<<0)) ? SDL_FALSE : SDL_TRUE;
-                const SDL_bool isphysical = (devid & (1<<1)) ? SDL_TRUE : SDL_FALSE;
+                const SDL_bool devid_iscapture = !(devid & (1<<0));
+                const SDL_bool isphysical = (devid & (1<<1));
                 if (isphysical && (devid_iscapture == iscapture)) {
                     SDL_assert(devs_seen < num_devices);
                     retval[devs_seen++] = devid;
@@ -1320,7 +1320,7 @@ SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_
     while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) {
         const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
         // bit #1 of devid is set for physical devices and unset for logical.
-        const SDL_bool isphysical = (devid & (1<<1)) ? SDL_TRUE : SDL_FALSE;
+        const SDL_bool isphysical = (devid & (1<<1));
         if (isphysical) {
             SDL_AudioDevice *device = (SDL_AudioDevice *) value;
             if (callback(device, userdata)) {  // found it?
@@ -1577,11 +1577,11 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
         return 0;
     }
 
-    SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) || (devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE)) ? SDL_TRUE : SDL_FALSE;
+    SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) || (devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE));
 
     // this will let you use a logical device to make a new logical device on the parent physical device. Could be useful?
     SDL_AudioDevice *device = NULL;
-    const SDL_bool islogical = (wants_default || (devid & (1<<1))) ? SDL_FALSE : SDL_TRUE;
+    const SDL_bool islogical = (!wants_default && !(devid & (1<<1)));
     if (!islogical) {
         device = ObtainPhysicalAudioDeviceDefaultAllowed(devid);
     } else {
@@ -1700,7 +1700,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac
 
 int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams)
 {
-    const SDL_bool islogical = (devid & (1<<1)) ? SDL_FALSE : SDL_TRUE;
+    const SDL_bool islogical = !(devid & (1<<1));
     SDL_AudioDevice *device = NULL;
     SDL_LogicalAudioDevice *logdev = NULL;
     int retval = 0;
@@ -1969,7 +1969,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
     // change the official default over right away, so new opens will go to the new device.
     SDL_LockRWLockForWriting(current_audio.device_hash_lock);
     const SDL_AudioDeviceID current_devid = iscapture ? current_audio.default_capture_device_id : current_audio.default_output_device_id;
-    const SDL_bool is_already_default = (new_default_device->instance_id == current_devid) ? SDL_TRUE : SDL_FALSE;
+    const SDL_bool is_already_default = (new_default_device->instance_id == current_devid);
     if (!is_already_default) {
         if (iscapture) {
             current_audio.default_capture_device_id = new_default_device->instance_id;

+ 1 - 1
src/audio/SDL_audiocvt.c

@@ -207,7 +207,7 @@ static SDL_bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt)
 
 static SDL_bool SDL_IsSupportedChannelCount(const int channels)
 {
-    return ((channels >= 1) && (channels <= 8)) ? SDL_TRUE : SDL_FALSE;
+    return ((channels >= 1) && (channels <= 8));
 }
 
 

+ 1 - 1
src/audio/alsa/SDL_alsa_audio.c

@@ -818,7 +818,7 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_output, SDL_bool *has_de
                 }
 
                 // only want physical hardware interfaces
-                const SDL_bool is_default = (has_default == i) ? SDL_TRUE : SDL_FALSE;
+                const SDL_bool is_default = (has_default == i);
                 if (is_default || (match != NULL && 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);

+ 1 - 1
src/audio/coreaudio/SDL_coreaudio.m

@@ -185,7 +185,7 @@ static void RefreshPhysicalDevices(void)
 
             CFIndex len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr), kCFStringEncodingUTF8);
             char *name = (char *)SDL_malloc(len + 1);
-            SDL_bool usable = ((name != NULL) && (CFStringGetCString(cfstr, name, len + 1, kCFStringEncodingUTF8))) ? SDL_TRUE : SDL_FALSE;
+            SDL_bool usable = ((name != NULL) && (CFStringGetCString(cfstr, name, len + 1, kCFStringEncodingUTF8)));
 
             CFRelease(cfstr);
 

+ 4 - 4
src/audio/emscripten/SDL_emscriptenaudio.c

@@ -321,7 +321,7 @@ static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
             return true;
         }
         return false;
-    }) ? SDL_TRUE : SDL_FALSE;
+    });
 
     if (!available) {
         SDL_SetError("No audio context available");
@@ -334,10 +334,10 @@ static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl)
             return true;
         }
         return false;
-    }) ? SDL_TRUE : SDL_FALSE;
+    });
 
-    impl->HasCaptureSupport = capture_available ? SDL_TRUE : SDL_FALSE;
-    impl->OnlyHasDefaultCaptureDevice = capture_available ? SDL_TRUE : SDL_FALSE;
+    impl->HasCaptureSupport = capture_available;
+    impl->OnlyHasDefaultCaptureDevice = capture_available;
 
     return available;
 }

+ 4 - 4
src/audio/pulseaudio/SDL_pulseaudio.c

@@ -832,14 +832,14 @@ static SDL_bool FindAudioDeviceByIndex(SDL_AudioDevice *device, void *userdata)
 {
     const uint32_t idx = (uint32_t) (uintptr_t) userdata;
     const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle;
-    return (handle->device_index == idx) ? SDL_TRUE : SDL_FALSE;
+    return (handle->device_index == idx);
 }
 
 static SDL_bool FindAudioDeviceByPath(SDL_AudioDevice *device, void *userdata)
 {
     const char *path = (const char *) userdata;
     const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle;
-    return (SDL_strcmp(handle->device_path, path) == 0) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_strcmp(handle->device_path, path) == 0);
 }
 
 // This is called when PulseAudio has a device connected/removed/changed.
@@ -925,8 +925,8 @@ static int SDLCALL HotplugThread(void *data)
         SDL_free(current_default_source);
 
         // set these to true if we didn't handle the change OR there was _another_ change while we were working unlocked.
-        default_sink_changed = (default_sink_changed || check_default_sink) ? SDL_TRUE : SDL_FALSE;
-        default_source_changed = (default_source_changed || check_default_source) ? SDL_TRUE : SDL_FALSE;
+        default_sink_changed = (default_sink_changed || check_default_sink);
+        default_source_changed = (default_source_changed || check_default_source);
     }
 
     if (op) {

+ 1 - 1
src/audio/wasapi/SDL_wasapi_winrt.cpp

@@ -55,7 +55,7 @@ static Platform::String ^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4
 
 static SDL_bool FindWinRTAudioDeviceCallback(SDL_AudioDevice *device, void *userdata)
 {
-    return (SDL_wcscmp((LPCWSTR) device->handle, (LPCWSTR) userdata) == 0) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_wcscmp((LPCWSTR) device->handle, (LPCWSTR) userdata) == 0);
 }
 
 static SDL_AudioDevice *FindWinRTAudioDevice(LPCWSTR devid)

+ 3 - 4
src/core/android/SDL_android.c

@@ -1011,7 +1011,7 @@ SDL_JAVA_AUDIO_INTERFACE(addAudioDevice)(JNIEnv *env, jclass jcls, jboolean is_c
         void *handle = (void *)((size_t)device_id);
         if (!SDL_FindPhysicalAudioDeviceByHandle(handle)) {
             const char *utf8name = (*env)->GetStringUTFChars(env, name, NULL);
-            SDL_AddAudioDevice(is_capture ? SDL_TRUE : SDL_FALSE, SDL_strdup(utf8name), NULL, handle);
+            SDL_AddAudioDevice(is_capture, SDL_strdup(utf8name), NULL, handle);
             (*env)->ReleaseStringUTFChars(env, name, utf8name);
         }
     }
@@ -1072,7 +1072,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
     const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
     const char *desc = (*env)->GetStringUTFChars(env, device_desc, NULL);
 
-    retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, is_accelerometer ? SDL_TRUE : SDL_FALSE, button_mask, naxes, axis_mask, nhats);
+    retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, is_accelerometer, button_mask, naxes, axis_mask, nhats);
 
     (*env)->ReleaseStringUTFChars(env, device_name, name);
     (*env)->ReleaseStringUTFChars(env, device_desc, desc);
@@ -2057,8 +2057,7 @@ char *Android_JNI_GetClipboardText(void)
 SDL_bool Android_JNI_HasClipboardText(void)
 {
     JNIEnv *env = Android_JNI_GetEnv();
-    jboolean retval = (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
-    return (retval == JNI_TRUE) ? SDL_TRUE : SDL_FALSE;
+    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
 }
 
 /* returns 0 on success or -1 on error (others undefined then)

+ 1 - 1
src/core/linux/SDL_dbus.c

@@ -508,7 +508,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
                                      DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
                 return SDL_FALSE;
             }
-            return (screensaver_cookie != 0) ? SDL_TRUE : SDL_FALSE;
+            return (screensaver_cookie != 0);
         } else {
             if (!SDL_DBus_CallVoidMethod(bus_name, path, interface, "UnInhibit", DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
                 return SDL_FALSE;

+ 1 - 1
src/core/linux/SDL_ibus.c

@@ -696,7 +696,7 @@ SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
 
     SDL_IBus_UpdateTextRect(NULL);
 
-    return result ? SDL_TRUE : SDL_FALSE;
+    return (result != 0);
 }
 
 void SDL_IBus_UpdateTextRect(const SDL_Rect *rect)

+ 1 - 1
src/events/SDL_events.c

@@ -1036,7 +1036,7 @@ int SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
     SDL_Window *wakeup_window;
     Uint64 start, expiration;
-    SDL_bool include_sentinel = (timeoutNS == 0) ? SDL_TRUE : SDL_FALSE;
+    SDL_bool include_sentinel = (timeoutNS == 0);
     int result;
 
     /* If there isn't a poll sentinel event pending, pump events and add one */

+ 2 - 2
src/events/SDL_mouse.c

@@ -392,7 +392,7 @@ int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseI
 {
     if (window && !relative) {
         SDL_Mouse *mouse = SDL_GetMouse();
-        if (!SDL_UpdateMouseFocus(window, x, y, GetButtonState(mouse, SDL_TRUE), (mouseID == SDL_TOUCH_MOUSEID) ? SDL_FALSE : SDL_TRUE)) {
+        if (!SDL_UpdateMouseFocus(window, x, y, GetButtonState(mouse, SDL_TRUE), (mouseID != SDL_TOUCH_MOUSEID))) {
             return 0;
         }
     }
@@ -656,7 +656,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
         event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
         event.motion.which = mouseID;
         /* Set us pending (or clear during a normal mouse movement event) as having triggered */
-        mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID) ? SDL_TRUE : SDL_FALSE;
+        mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID);
         event.motion.state = GetButtonState(mouse, SDL_TRUE);
         event.motion.x = mouse->x;
         event.motion.y = mouse->y;

+ 7 - 7
src/file/SDL_rwops.c

@@ -952,13 +952,13 @@ SDL_bool SDL_ReadS64BE(SDL_RWops *src, Sint64 *value)
 
 SDL_bool SDL_WriteU8(SDL_RWops *dst, Uint8 value)
 {
-    return (SDL_RWwrite(dst, &value, sizeof(value)) == sizeof(value)) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_RWwrite(dst, &value, sizeof(value)) == sizeof(value));
 }
 
 SDL_bool SDL_WriteU16LE(SDL_RWops *dst, Uint16 value)
 {
     const Uint16 swapped = SDL_SwapLE16(value);
-    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped)) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
 }
 
 SDL_bool SDL_WriteS16LE(SDL_RWops *dst, Sint16 value)
@@ -969,7 +969,7 @@ SDL_bool SDL_WriteS16LE(SDL_RWops *dst, Sint16 value)
 SDL_bool SDL_WriteU16BE(SDL_RWops *dst, Uint16 value)
 {
     const Uint16 swapped = SDL_SwapBE16(value);
-    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped)) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
 }
 
 SDL_bool SDL_WriteS16BE(SDL_RWops *dst, Sint16 value)
@@ -980,7 +980,7 @@ SDL_bool SDL_WriteS16BE(SDL_RWops *dst, Sint16 value)
 SDL_bool SDL_WriteU32LE(SDL_RWops *dst, Uint32 value)
 {
     const Uint32 swapped = SDL_SwapLE32(value);
-    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped)) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
 }
 
 SDL_bool SDL_WriteS32LE(SDL_RWops *dst, Sint32 value)
@@ -991,7 +991,7 @@ SDL_bool SDL_WriteS32LE(SDL_RWops *dst, Sint32 value)
 SDL_bool SDL_WriteU32BE(SDL_RWops *dst, Uint32 value)
 {
     const Uint32 swapped = SDL_SwapBE32(value);
-    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped)) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
 }
 
 SDL_bool SDL_WriteS32BE(SDL_RWops *dst, Sint32 value)
@@ -1002,7 +1002,7 @@ SDL_bool SDL_WriteS32BE(SDL_RWops *dst, Sint32 value)
 SDL_bool SDL_WriteU64LE(SDL_RWops *dst, Uint64 value)
 {
     const Uint64 swapped = SDL_SwapLE64(value);
-    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped)) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
 }
 
 SDL_bool SDL_WriteS64LE(SDL_RWops *dst, Sint64 value)
@@ -1013,7 +1013,7 @@ SDL_bool SDL_WriteS64LE(SDL_RWops *dst, Sint64 value)
 SDL_bool SDL_WriteU64BE(SDL_RWops *dst, Uint64 value)
 {
     const Uint64 swapped = SDL_SwapBE64(value);
-    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped)) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
 }
 
 SDL_bool SDL_WriteS64BE(SDL_RWops *dst, Sint64 value)

+ 1 - 1
src/haptic/windows/SDL_xinputhaptic.c

@@ -43,7 +43,7 @@ static SDL_bool loaded_xinput = SDL_FALSE;
 int SDL_XINPUT_HapticInit(void)
 {
     if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) {
-        loaded_xinput = (WIN_LoadXInputDLL() == 0) ? SDL_TRUE : SDL_FALSE;
+        loaded_xinput = (WIN_LoadXInputDLL() == 0);
     }
 
     /* If the joystick subsystem is active, it will manage adding XInput haptic devices */

+ 1 - 1
src/joystick/SDL_joystick.c

@@ -181,7 +181,7 @@ void SDL_UnlockJoysticks(void)
 
 SDL_bool SDL_JoysticksLocked(void)
 {
-    return (SDL_joysticks_locked > 0) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_joysticks_locked > 0);
 }
 
 void SDL_AssertJoysticksLocked(void)

+ 1 - 1
src/joystick/hidapi/SDL_hidapi_ps4.c

@@ -1131,7 +1131,7 @@ static SDL_bool VerifyCRC(Uint8 *data, int size)
                          packetCRC[1],
                          packetCRC[2],
                          packetCRC[3]);
-    return (unCRC == unPacketCRC) ? SDL_TRUE : SDL_FALSE;
+    return (unCRC == unPacketCRC);
 }
 
 static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 *data, int size)

+ 1 - 1
src/joystick/hidapi/SDL_hidapi_ps5.c

@@ -1429,7 +1429,7 @@ static SDL_bool VerifyCRC(Uint8 *data, int size)
                          packetCRC[1],
                          packetCRC[2],
                          packetCRC[3]);
-    return (unCRC == unPacketCRC) ? SDL_TRUE : SDL_FALSE;
+    return (unCRC == unPacketCRC);
 }
 
 static SDL_bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 *data, int size)

+ 2 - 2
src/joystick/hidapi/SDL_hidapi_switch.c

@@ -1192,7 +1192,7 @@ static SDL_bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device,
         return SDL_FALSE;
     }
 
-    return (type == SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO) ? SDL_TRUE : SDL_FALSE;
+    return (type == SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO);
 }
 
 static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
@@ -1466,7 +1466,7 @@ static int HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *
         SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]);
     }
 
-    ctx->m_bRumbleActive = (low_frequency_rumble || high_frequency_rumble) ? SDL_TRUE : SDL_FALSE;
+    ctx->m_bRumbleActive = (low_frequency_rumble || high_frequency_rumble);
 
     if (!WriteRumble(ctx)) {
         return SDL_SetError("Couldn't send rumble packet");

+ 4 - 4
src/joystick/hidapi/SDL_hidapi_wii.c

@@ -505,8 +505,8 @@ static void UpdatePowerLevelWii(SDL_Joystick *joystick, Uint8 batteryLevelByte)
 
 static void UpdatePowerLevelWiiU(SDL_Joystick *joystick, Uint8 extensionBatteryByte)
 {
-    SDL_bool charging = extensionBatteryByte & 0x08 ? SDL_FALSE : SDL_TRUE;
-    SDL_bool pluggedIn = extensionBatteryByte & 0x04 ? SDL_FALSE : SDL_TRUE;
+    SDL_bool charging = !(extensionBatteryByte & 0x08);
+    SDL_bool pluggedIn = !(extensionBatteryByte & 0x04);
     Uint8 batteryLevel = extensionBatteryByte >> 4;
 
     /* Not sure if all Wii U Pro controllers act like this, but on mine
@@ -814,7 +814,7 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
 static int HIDAPI_DriverWii_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
 {
     SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context;
-    SDL_bool active = (low_frequency_rumble || high_frequency_rumble) ? SDL_TRUE : SDL_FALSE;
+    SDL_bool active = (low_frequency_rumble || high_frequency_rumble);
 
     if (active != ctx->m_bRumbleActive) {
         Uint8 data[2];
@@ -1407,7 +1407,7 @@ static void GetExtensionData(WiiButtonData *dst, const Uint8 *src, int size)
 static void HandleStatus(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick)
 {
     SDL_bool hadExtension = ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_None;
-    SDL_bool hasExtension = ctx->m_rgucReadBuffer[3] & 2 ? SDL_TRUE : SDL_FALSE;
+    SDL_bool hasExtension = (ctx->m_rgucReadBuffer[3] & 2) ? SDL_TRUE : SDL_FALSE;
     WiiButtonData data;
     SDL_zero(data);
     GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1);

+ 2 - 2
src/joystick/hidapi/SDL_hidapi_xbox360.c

@@ -94,9 +94,9 @@ static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device
     if (SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
         return SDL_FALSE;
     }
-    return (type == SDL_GAMEPAD_TYPE_XBOX360 || type == SDL_GAMEPAD_TYPE_XBOXONE) ? SDL_TRUE : SDL_FALSE;
+    return (type == SDL_GAMEPAD_TYPE_XBOX360 || type == SDL_GAMEPAD_TYPE_XBOXONE);
 #else
-    return (type == SDL_GAMEPAD_TYPE_XBOX360) ? SDL_TRUE : SDL_FALSE;
+    return (type == SDL_GAMEPAD_TYPE_XBOX360);
 #endif
 }
 

+ 1 - 1
src/joystick/hidapi/SDL_hidapi_xboxone.c

@@ -351,7 +351,7 @@ static SDL_bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device
         return SDL_FALSE;
     }
 #endif
-    return (type == SDL_GAMEPAD_TYPE_XBOXONE) ? SDL_TRUE : SDL_FALSE;
+    return (type == SDL_GAMEPAD_TYPE_XBOXONE);
 }
 
 static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device)

+ 1 - 1
src/joystick/windows/SDL_rawinputjoystick.c

@@ -331,7 +331,7 @@ static void RAWINPUT_UpdateXInput()
     if (xinput_device_change) {
         for (user_index = 0; user_index < XUSER_MAX_COUNT; user_index++) {
             XINPUT_CAPABILITIES capabilities;
-            xinput_state[user_index].connected = (XINPUTGETCAPABILITIES(user_index, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) ? SDL_TRUE : SDL_FALSE;
+            xinput_state[user_index].connected = (XINPUTGETCAPABILITIES(user_index, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS);
         }
         xinput_device_change = SDL_FALSE;
         xinput_state_dirty = SDL_TRUE;

+ 2 - 2
src/joystick/windows/SDL_windowsjoystick.c

@@ -336,7 +336,7 @@ static SDL_bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data,
         }
     }
     SDL_LockMutex(mutex);
-    return (lastret != -1) ? SDL_TRUE : SDL_FALSE;
+    return (lastret != -1);
 }
 
 #endif /* !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */
@@ -377,7 +377,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
                 for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
                     XINPUT_CAPABILITIES capabilities;
                     const DWORD result = XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities);
-                    const SDL_bool available = (result == ERROR_SUCCESS) ? SDL_TRUE : SDL_FALSE;
+                    const SDL_bool available = (result == ERROR_SUCCESS);
                     if (bOpenedXInputDevices[userId] != available) {
                         s_bWindowsDeviceChanged = SDL_TRUE;
                         bOpenedXInputDevices[userId] = available;

+ 1 - 1
src/joystick/windows/SDL_xinputjoystick.c

@@ -377,7 +377,7 @@ int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic
         return SDL_SetError("Failed to obtain XInput device capabilities. Device disconnected?");
     }
     SDL_zero(state);
-    joystick->hwdata->bXInputHaptic = (XINPUTSETSTATE(userId, &state) == ERROR_SUCCESS) ? SDL_TRUE : SDL_FALSE;
+    joystick->hwdata->bXInputHaptic = (XINPUTSETSTATE(userId, &state) == ERROR_SUCCESS);
     joystick->hwdata->userid = userId;
 
     /* The XInput API has a hard coded button/axis mapping, so we just match it */

+ 1 - 1
src/render/direct3d/SDL_render_d3d.c

@@ -1186,7 +1186,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
             const SDL_Rect *viewport = &data->drawstate.viewport;
             const int backw = istarget ? renderer->target->w : data->pparams.BackBufferWidth;
             const int backh = istarget ? renderer->target->h : data->pparams.BackBufferHeight;
-            const SDL_bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh)) ? SDL_TRUE : SDL_FALSE;
+            const SDL_bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh));
 
             if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) {
                 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE);

+ 1 - 1
src/sensor/SDL_sensor.c

@@ -115,7 +115,7 @@ void SDL_UnlockSensors(void)
 
 SDL_bool SDL_SensorsLocked(void)
 {
-    return (SDL_sensors_locked > 0) ? SDL_TRUE : SDL_FALSE;
+    return (SDL_sensors_locked > 0);
 }
 
 void SDL_AssertSensorsLocked(void)

+ 1 - 1
src/stdlib/SDL_string.c

@@ -1227,7 +1227,7 @@ static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len)
         }
     }
     if (invert) {
-        result = result ? SDL_FALSE : SDL_TRUE;
+        result = !result;
     }
     return result;
 }

+ 3 - 3
src/test/SDL_test_common.c

@@ -2273,7 +2273,7 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
                 /* Ctrl-G toggle mouse grab */
                 SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
                 if (window) {
-                    SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window) ? SDL_TRUE : SDL_FALSE);
+                    SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window));
                 }
             }
             break;
@@ -2282,7 +2282,7 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
                 /* Ctrl-K toggle keyboard grab */
                 SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
                 if (window) {
-                    SDL_SetWindowKeyboardGrab(window, !SDL_GetWindowKeyboardGrab(window) ? SDL_TRUE : SDL_FALSE);
+                    SDL_SetWindowKeyboardGrab(window, !SDL_GetWindowKeyboardGrab(window));
                 }
             }
             break;
@@ -2311,7 +2311,7 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
         case SDLK_r:
             if (withControl) {
                 /* Ctrl-R toggle mouse relative mode */
-                SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode() ? SDL_TRUE : SDL_FALSE);
+                SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode());
             }
             break;
         case SDLK_t:

+ 5 - 5
src/video/SDL_shape.c

@@ -52,7 +52,7 @@ SDL_bool SDL_IsShapedWindow(const SDL_Window *window)
     if (window == NULL) {
         return SDL_FALSE;
     }
-    return (SDL_bool)(window->shaper != NULL);
+    return (window->shaper != NULL);
 }
 
 /* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */
@@ -125,17 +125,17 @@ static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SD
             }
             switch (mode.mode) {
             case (ShapeModeDefault):
-                pixel_opaque = (a >= 1 ? SDL_TRUE : SDL_FALSE);
+                pixel_opaque = (a >= 1);
                 break;
             case (ShapeModeBinarizeAlpha):
-                pixel_opaque = (a >= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE);
+                pixel_opaque = (a >= mode.parameters.binarizationCutoff);
                 break;
             case (ShapeModeReverseBinarizeAlpha):
-                pixel_opaque = (a <= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE);
+                pixel_opaque = (a <= mode.parameters.binarizationCutoff);
                 break;
             case (ShapeModeColorKey):
                 key = mode.parameters.colorKey;
-                pixel_opaque = ((key.r != r || key.g != g || key.b != b) ? SDL_TRUE : SDL_FALSE);
+                pixel_opaque = (key.r != r || key.g != g || key.b != b);
                 break;
             }
             if (last_opaque == -1) {

+ 15 - 15
src/video/SDL_video.c

@@ -228,7 +228,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
     SDL_RendererInfo info;
     SDL_PropertiesID props = SDL_GetWindowProperties(window);
     SDL_WindowTextureData *data = (SDL_WindowTextureData *)SDL_GetProperty(props, SDL_WINDOWTEXTUREDATA);
-    const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE;
+    const SDL_bool transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE;
     int i;
     int w, h;
 
@@ -598,7 +598,7 @@ SDL_VideoDevice *SDL_GetVideoDevice(void)
 
 SDL_bool SDL_OnVideoThread(void)
 {
-    return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE;
+    return (_this && SDL_ThreadID() == _this->thread);
 }
 
 SDL_bool SDL_IsVideoContextExternal(void)
@@ -2485,15 +2485,15 @@ int SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered)
     CHECK_WINDOW_MAGIC(window, -1);
     CHECK_WINDOW_NOT_POPUP(window, -1);
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
-        const int want = (bordered != SDL_FALSE); /* normalize the flag. */
-        const int have = !(window->flags & SDL_WINDOW_BORDERLESS);
+        const SDL_bool want = (bordered != SDL_FALSE); /* normalize the flag. */
+        const SDL_bool have = !(window->flags & SDL_WINDOW_BORDERLESS);
         if ((want != have) && (_this->SetWindowBordered)) {
             if (want) {
                 window->flags &= ~SDL_WINDOW_BORDERLESS;
             } else {
                 window->flags |= SDL_WINDOW_BORDERLESS;
             }
-            _this->SetWindowBordered(_this, window, (SDL_bool)want);
+            _this->SetWindowBordered(_this, window, want);
         }
     }
     return 0;
@@ -2504,15 +2504,15 @@ int SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable)
     CHECK_WINDOW_MAGIC(window, -1);
     CHECK_WINDOW_NOT_POPUP(window, -1);
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
-        const int want = (resizable != SDL_FALSE); /* normalize the flag. */
-        const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
+        const SDL_bool want = (resizable != SDL_FALSE); /* normalize the flag. */
+        const SDL_bool have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
         if ((want != have) && (_this->SetWindowResizable)) {
             if (want) {
                 window->flags |= SDL_WINDOW_RESIZABLE;
             } else {
                 window->flags &= ~SDL_WINDOW_RESIZABLE;
             }
-            _this->SetWindowResizable(_this, window, (SDL_bool)want);
+            _this->SetWindowResizable(_this, window, want);
         }
     }
     return 0;
@@ -2523,15 +2523,15 @@ int SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top)
     CHECK_WINDOW_MAGIC(window, -1);
     CHECK_WINDOW_NOT_POPUP(window, -1);
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
-        const int want = (on_top != SDL_FALSE); /* normalize the flag. */
-        const int have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0);
+        const SDL_bool want = (on_top != SDL_FALSE); /* normalize the flag. */
+        const SDL_bool have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0);
         if ((want != have) && (_this->SetWindowAlwaysOnTop)) {
             if (want) {
                 window->flags |= SDL_WINDOW_ALWAYS_ON_TOP;
             } else {
                 window->flags &= ~SDL_WINDOW_ALWAYS_ON_TOP;
             }
-            _this->SetWindowAlwaysOnTop(_this, window, (SDL_bool)want);
+            _this->SetWindowAlwaysOnTop(_this, window, want);
         }
     }
     return 0;
@@ -3154,15 +3154,15 @@ int SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable)
 {
     CHECK_WINDOW_MAGIC(window, -1);
 
-    const int want = (focusable != SDL_FALSE); /* normalize the flag. */
-    const int have = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE);
+    const SDL_bool want = (focusable != SDL_FALSE); /* normalize the flag. */
+    const SDL_bool have = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE);
     if ((want != have) && (_this->SetWindowFocusable)) {
         if (want) {
             window->flags &= ~SDL_WINDOW_NOT_FOCUSABLE;
         } else {
             window->flags |= SDL_WINDOW_NOT_FOCUSABLE;
         }
-        _this->SetWindowFocusable(_this, window, (SDL_bool)want);
+        _this->SetWindowFocusable(_this, window, want);
     }
 
     return 0;
@@ -3621,7 +3621,7 @@ SDL_bool SDL_ScreenSaverEnabled(void)
     if (_this == NULL) {
         return SDL_TRUE;
     }
-    return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE;
+    return !_this->suspend_screensaver;
 }
 
 int SDL_EnableScreenSaver(void)

+ 1 - 1
src/video/emscripten/SDL_emscriptenvideo.c

@@ -293,7 +293,7 @@ static void Emscripten_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *w
 
         if (fullscreen) {
             EmscriptenFullscreenStrategy strategy;
-            SDL_bool is_fullscreen_desktop = window->fullscreen_exclusive ? SDL_FALSE : SDL_TRUE;
+            SDL_bool is_fullscreen_desktop = !window->fullscreen_exclusive;
             int res;
 
             strategy.scaleMode = is_fullscreen_desktop ? EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH : EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT;

+ 1 - 1
src/video/gdk/SDL_gdktextinput.cpp

@@ -230,7 +230,7 @@ SDL_bool GDK_IsTextInputShown(SDL_VideoDevice *_this)
      * just below the text box, so technically
      * this is true whenever the window is shown.
      */
-    return (g_TextBlock != NULL) ? SDL_TRUE : SDL_FALSE;
+    return (g_TextBlock != NULL);
 }
 
 SDL_bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this)

+ 1 - 1
src/video/haiku/SDL_bclipboard.cc

@@ -79,7 +79,7 @@ SDL_bool HAIKU_HasClipboardText(SDL_VideoDevice *_this) {
     SDL_bool result = SDL_FALSE;
     char *text = HAIKU_GetClipboardText(_this);
     if (text) {
-        result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
+        result = (text[0] != '\0');
         SDL_free(text);
     }
     return result;

+ 3 - 3
src/video/wayland/SDL_waylandevents.c

@@ -2530,13 +2530,13 @@ static void tablet_tool_handle_button(void *data, struct zwp_tablet_tool_v2 *too
     switch (button) {
     /* see %{_includedir}/linux/input-event-codes.h */
     case 0x14b: /* BTN_STYLUS */
-        input->btn_stylus = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE;
+        input->btn_stylus = (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED);
         break;
     case 0x14c: /* BTN_STYLUS2 */
-        input->btn_stylus2 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE;
+        input->btn_stylus2 = (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED);
         break;
     case 0x149: /* BTN_STYLUS3 */
-        input->btn_stylus3 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE;
+        input->btn_stylus3 = (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED);
         break;
     }
 

+ 1 - 1
src/video/wayland/SDL_waylandtouch.c

@@ -108,7 +108,7 @@ static void touch_handle_touch(void *data,
     case QtWaylandTouchPointPressed:
     case QtWaylandTouchPointReleased:
         SDL_SendTouch(Wayland_GetTouchTimestamp(viddata->input, time), deviceId, (SDL_FingerID)id,
-                      window, (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE, xf, yf, pressuref);
+                      window, (touchState == QtWaylandTouchPointPressed), xf, yf, pressuref);
         break;
     case QtWaylandTouchPointMoved:
         SDL_SendTouchMotion(Wayland_GetTouchTimestamp(viddata->input, time), deviceId, (SDL_FingerID)id,

+ 1 - 1
src/video/wayland/SDL_waylandvideo.c

@@ -598,7 +598,7 @@ static void display_handle_done(void *data,
 
     if (driverdata->display == 0) {
         /* First time getting display info, create the VideoDisplay */
-        SDL_bool send_event = driverdata->videodata->initializing ? SDL_FALSE : SDL_TRUE;
+        SDL_bool send_event = !driverdata->videodata->initializing;
         if (driverdata->physical_width >= driverdata->physical_height) {
             driverdata->placeholder.natural_orientation = SDL_ORIENTATION_LANDSCAPE;
         } else {

+ 2 - 2
src/video/wayland/SDL_waylandwindow.c

@@ -1346,7 +1346,7 @@ int Wayland_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysW
     } else
 #endif
         if (viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) {
-        SDL_bool popup = (data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) ? SDL_TRUE : SDL_FALSE;
+        SDL_bool popup = (data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP);
         info->info.wl.xdg_surface = data->shell_surface.xdg.surface;
         info->info.wl.xdg_toplevel = popup ? NULL : data->shell_surface.xdg.roleobj.toplevel;
         if (popup) {
@@ -1894,7 +1894,7 @@ void Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window,
 
     /* Don't send redundant fullscreen set/unset events. */
     if (wind->is_fullscreen != fullscreen) {
-        wind->fullscreen_was_positioned = fullscreen ? SDL_TRUE : SDL_FALSE;
+        wind->fullscreen_was_positioned = fullscreen;
         SetFullscreen(window, fullscreen ? output : NULL);
     } else if (wind->is_fullscreen) {
         /*

+ 2 - 2
src/video/windows/SDL_windowsevents.c

@@ -486,8 +486,8 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
 {
     SDL_WindowData *data = window->driverdata;
     HWND hwnd = data->hwnd;
-    SDL_bool had_focus = (SDL_GetKeyboardFocus() == window) ? SDL_TRUE : SDL_FALSE;
-    SDL_bool has_focus = (GetForegroundWindow() == hwnd) ? SDL_TRUE : SDL_FALSE;
+    SDL_bool had_focus = (SDL_GetKeyboardFocus() == window);
+    SDL_bool has_focus = (GetForegroundWindow() == hwnd);
 
     if (had_focus == has_focus || has_focus != expect_focus) {
         return;

+ 2 - 2
src/video/windows/SDL_windowskeyboard.c

@@ -735,7 +735,7 @@ static void IME_UpdateInputLocale(SDL_VideoData *videodata)
     }
 
     videodata->ime_hkl = hklnext;
-    videodata->ime_candvertical = (PRIMLANG() == LANG_KOREAN || LANG() == LANG_CHS) ? SDL_FALSE : SDL_TRUE;
+    videodata->ime_candvertical = (PRIMLANG() != LANG_KOREAN && LANG() != LANG_CHS);
 }
 
 static void IME_ClearComposition(SDL_VideoData *videodata)
@@ -766,7 +766,7 @@ static SDL_bool IME_IsTextInputShown(SDL_VideoData *videodata)
         return SDL_FALSE;
     }
 
-    return videodata->ime_uicontext != 0 ? SDL_TRUE : SDL_FALSE;
+    return videodata->ime_uicontext != 0;
 }
 
 static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)

+ 1 - 4
src/video/windows/SDL_windowsopengl.c

@@ -897,7 +897,6 @@ SDL_bool WIN_GL_SetPixelFormatFrom(SDL_VideoDevice *_this, SDL_Window *fromWindo
 {
     HDC hfromdc = fromWindow->driverdata->hdc;
     HDC htodc = toWindow->driverdata->hdc;
-    BOOL result;
 
     /* get the pixel format of the fromWindow */
     int pixel_format = GetPixelFormat(hfromdc);
@@ -906,9 +905,7 @@ SDL_bool WIN_GL_SetPixelFormatFrom(SDL_VideoDevice *_this, SDL_Window *fromWindo
     DescribePixelFormat(hfromdc, pixel_format, sizeof(pfd), &pfd);
 
     /* set the pixel format of the toWindow */
-    result = SetPixelFormat(htodc, pixel_format, &pfd);
-
-    return result ? SDL_TRUE : SDL_FALSE;
+    return SetPixelFormat(htodc, pixel_format, &pfd);
 }
 
 #endif /* SDL_VIDEO_OPENGL_WGL */

+ 1 - 2
src/video/windows/SDL_windowsvideo.c

@@ -717,8 +717,7 @@ SDL_bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this)
 
     if (data->AreDpiAwarenessContextsEqual && data->GetThreadDpiAwarenessContext) {
         /* Windows 10, version 1607 */
-        return (SDL_bool)data->AreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2,
-                                                            data->GetThreadDpiAwarenessContext());
+        return data->AreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, data->GetThreadDpiAwarenessContext());
     }
 #endif
     return SDL_FALSE;

+ 1 - 1
src/video/x11/SDL_x11video.c

@@ -459,7 +459,7 @@ void X11_VideoQuit(SDL_VideoDevice *_this)
 
 SDL_bool X11_UseDirectColorVisuals(void)
 {
-    return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE;
+    return (SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") == NULL);
 }
 
 #endif /* SDL_VIDEO_DRIVER_X11 */

+ 1 - 1
src/video/x11/SDL_x11xinput2.c

@@ -246,7 +246,7 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata,
     for (i = 0; i < xidevinfo->num_classes; i++) {
         const XIValuatorClassInfo *v = (const XIValuatorClassInfo *)xidevinfo->classes[i];
         if (v->type == XIValuatorClass) {
-            devinfo->relative[axis] = (v->mode == XIModeRelative) ? SDL_TRUE : SDL_FALSE;
+            devinfo->relative[axis] = (v->mode == XIModeRelative);
             devinfo->minval[axis] = v->min;
             devinfo->maxval[axis] = v->max;
             if (++axis >= 2) {

+ 1 - 1
test/checkkeys.c

@@ -165,7 +165,7 @@ static void loop(void)
         switch (event.type) {
         case SDL_EVENT_KEY_DOWN:
         case SDL_EVENT_KEY_UP:
-            PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
+            PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED), (event.key.repeat > 0));
             if (event.type == SDL_EVENT_KEY_DOWN) {
                 switch (event.key.keysym.sym) {
                 case SDLK_BACKSPACE:

+ 1 - 1
test/checkkeysthreads.c

@@ -179,7 +179,7 @@ static void loop(void)
         switch (event.type) {
         case SDL_EVENT_KEY_DOWN:
         case SDL_EVENT_KEY_UP:
-            PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
+            PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED), (event.key.repeat > 0));
             break;
         case SDL_EVENT_TEXT_EDITING:
             PrintText("EDIT", event.text.text);

+ 8 - 8
test/testatomic.c

@@ -50,28 +50,28 @@ static void RunBasicTest(void)
     SDL_Log("\natomic -----------------------------------------\n\n");
 
     SDL_AtomicSet(&v, 0);
-    tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE;
+    tfret = SDL_AtomicSet(&v, 10) == 0;
     SDL_Log("AtomicSet(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
-    tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE;
+    tfret = SDL_AtomicAdd(&v, 10) == 10;
     SDL_Log("AtomicAdd(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 
     SDL_AtomicSet(&v, 0);
     SDL_AtomicIncRef(&v);
-    tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE;
+    tfret = (SDL_AtomicGet(&v) == 1);
     SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     SDL_AtomicIncRef(&v);
-    tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE;
+    tfret = (SDL_AtomicGet(&v) == 2);
     SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
-    tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
+    tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE);
     SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
-    tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
+    tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE);
     SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 
     SDL_AtomicSet(&v, 10);
-    tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
+    tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE);
     SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     value = SDL_AtomicGet(&v);
-    tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
+    tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE);
     SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 }
 

+ 3 - 3
test/testaudio.c

@@ -833,7 +833,7 @@ static void UpdateVisualizer(SDL_Renderer *renderer, SDL_Texture *visualizer, co
 
 static void LogicalDeviceThing_ontick(Thing *thing, Uint64 now)
 {
-    const SDL_bool ismousedover = (thing == mouseover_thing) ? SDL_TRUE : SDL_FALSE;
+    const SDL_bool ismousedover = (thing == mouseover_thing);
 
     if (!thing->data.logdev.visualizer || !thing->data.logdev.postmix_lock) {  /* need these to work, skip if they failed. */
         return;
@@ -1173,8 +1173,8 @@ int SDL_AppEvent(const SDL_Event *event)
 
         case SDL_EVENT_KEY_DOWN:
         case SDL_EVENT_KEY_UP:
-            ctrl_held = ((event->key.keysym.mod & SDL_KMOD_CTRL) != 0) ? SDL_TRUE : SDL_FALSE;
-            alt_held = ((event->key.keysym.mod & SDL_KMOD_ALT) != 0) ? SDL_TRUE : SDL_FALSE;
+            ctrl_held = ((event->key.keysym.mod & SDL_KMOD_CTRL) != 0);
+            alt_held = ((event->key.keysym.mod & SDL_KMOD_ALT) != 0);
             break;
 
         case SDL_EVENT_DROP_FILE:

+ 2 - 2
test/testaudiostreamdynamicresample.c

@@ -233,9 +233,9 @@ static void loop(void)
                     SDL_PauseAudioDevice(state->audio_id);
                 }
             } else if (sym == SDLK_w) {
-                auto_loop = auto_loop ? SDL_FALSE : SDL_TRUE;
+                auto_loop = !auto_loop;
             } else if (sym == SDLK_e) {
-                auto_flush = auto_flush ? SDL_FALSE : SDL_TRUE;
+                auto_flush = !auto_flush;
             } else if (sym == SDLK_a) {
                 SDL_ClearAudioStream(stream);
                 SDL_Log("Cleared audio stream");

+ 1 - 1
test/testshader.c

@@ -222,7 +222,7 @@ static SDL_bool CompileShaderProgram(ShaderData *data)
     }
     glUseProgramObjectARB(0);
 
-    return (glGetError() == GL_NO_ERROR) ? SDL_TRUE : SDL_FALSE;
+    return (glGetError() == GL_NO_ERROR);
 }
 
 static void DestroyShaderProgram(ShaderData *data)