SDL: Check standard error code return values as < 0 instead of == -1

From 037541a0e0c4320b5b2ab145c7236808918556e1 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 22 Aug 2024 06:53:25 -0700
Subject: [PATCH] Check standard error code return values as < 0 instead of ==
 -1

---
 src/audio/SDL_audio.c                            |  4 ++--
 src/audio/SDL_audiocvt.c                         |  6 +++---
 src/audio/SDL_wave.c                             | 10 +++++-----
 src/audio/wasapi/SDL_wasapi.c                    |  4 ++--
 src/audio/wasapi/SDL_wasapi_win32.c              |  2 +-
 .../mediafoundation/SDL_camera_mediafoundation.c |  6 +++---
 src/haptic/SDL_haptic.c                          |  2 +-
 src/hidapi/SDL_hidapi.c                          |  8 ++++----
 src/joystick/hidapi/SDL_hidapi_ps5.c             |  2 +-
 src/joystick/hidapi/SDL_hidapi_rumble.c          |  2 +-
 src/joystick/hidapi/SDL_hidapi_shield.c          |  2 +-
 src/joystick/hidapi/SDL_hidapi_wii.c             |  2 +-
 src/joystick/hidapi/SDL_hidapi_xboxone.c         |  4 ++--
 src/main/SDL_main_callbacks.c                    |  2 +-
 src/render/SDL_render.c                          |  6 +++---
 src/video/SDL_egl.c                              |  4 ++--
 src/video/SDL_yuv.c                              |  4 ++--
 test/loopwave.c                                  |  2 +-
 test/testaudiohotplug.c                          |  2 +-
 test/testaudiorecording.c                        |  4 ++--
 test/testfilesystem.c                            | 16 ++++++++--------
 test/testhittesting.c                            |  2 +-
 test/testhotplug.c                               |  2 +-
 test/testime.c                                   |  2 +-
 test/testmultiaudio.c                            |  2 +-
 test/testresample.c                              |  6 +++---
 test/testrumble.c                                |  6 +++---
 test/testsurround.c                              |  2 +-
 test/testurl.c                                   |  2 +-
 29 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index cb907807a0933..8b41836e351d6 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1723,7 +1723,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
             SDL_SetError("Device was already lost and can't accept new opens");
         } else if ((logdev = (SDL_LogicalAudioDevice *) SDL_calloc(1, sizeof (SDL_LogicalAudioDevice))) == NULL) {
             /* SDL_calloc already called SDL_OutOfMemory */
-        } else if (OpenPhysicalAudioDevice(device, spec) == -1) {  // if this is the first thing using this physical device, open at the OS level if necessary...
+        } else if (OpenPhysicalAudioDevice(device, spec) < 0) {  // if this is the first thing using this physical device, open at the OS level if necessary...
             SDL_free(logdev);
         } else {
             RefPhysicalAudioDevice(device);  // unref'd on successful SDL_CloseAudioDevice
@@ -2267,7 +2267,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
 
         if (needs_migration) {
             // New default physical device not been opened yet? Open at the OS level...
-            if (OpenPhysicalAudioDevice(new_default_device, &spec) == -1) {
+            if (OpenPhysicalAudioDevice(new_default_device, &spec) < 0) {
                 needs_migration = SDL_FALSE;  // uhoh, just leave everything on the old default, nothing to be done.
             }
         }
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 5f72fdc04f1f5..622d63149f23a 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -383,7 +383,7 @@ static int UpdateAudioStreamInputSpec(SDL_AudioStream *stream, const SDL_AudioSp
         return 0;
     }
 
-    if (SDL_ResetAudioQueueHistory(stream->queue, SDL_GetResamplerHistoryFrames()) != 0) {
+    if (SDL_ResetAudioQueueHistory(stream->queue, SDL_GetResamplerHistoryFrames()) < 0) {
         return -1;
     }
 
@@ -428,7 +428,7 @@ SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_
 
     OnAudioStreamCreated(retval);
 
-    if (SDL_SetAudioStreamFormat(retval, src_spec, dst_spec) == -1) {
+    if (SDL_SetAudioStreamFormat(retval, src_spec, dst_spec) < 0) {
         SDL_DestroyAudioStream(retval);
         return NULL;
     }
@@ -1338,7 +1338,7 @@ int SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data
         }
     }
 
-    if (retval == -1) {
+    if (retval < 0) {
         SDL_free(dst);
     } else {
         *dst_data = dst;
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index fd2f67af194fb..6472d1649abdc 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -703,14 +703,14 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
 
         /* Initialize decoder with the values from the block header. */
         result = MS_ADPCM_DecodeBlockHeader(&state);
-        if (result == -1) {
+        if (result < 0) {
             SDL_free(state.output.data);
             return -1;
         }
 
         /* Decode the block data. It stores the samples directly in the output. */
         result = MS_ADPCM_DecodeBlockData(&state);
-        if (result == -1) {
+        if (result < 0) {
             /* Unexpected end. Stop decoding and return partial data if necessary. */
             if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
                 SDL_free(state.output.data);
@@ -1105,7 +1105,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
             result = IMA_ADPCM_DecodeBlockData(&state);
         }
 
-        if (result == -1) {
+        if (result < 0) {
             /* Unexpected end. Stop decoding and return partial data if necessary. */
             if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
                 SDL_free(state.output.data);
@@ -1860,7 +1860,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
         }
 
         result = WaveNextChunk(src, chunk);
-        if (result == -1) {
+        if (result < 0) {
             /* Unexpected EOF. Corrupt file or I/O issues. */
             if (file->trunchint == TruncVeryStrict) {
                 return SDL_SetError("Unexpected end of WAVE file");
@@ -1985,7 +1985,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
 
     if (chunk->length > 0) {
         result = WaveReadChunkData(src, chunk);
-        if (result == -1) {
+        if (result < 0) {
             return -1;
         } else if (result == -2) {
             return SDL_SetError("Could not seek data of WAVE data chunk");
diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c
index 003d3ba268736..f1e71f59b68e5 100644
--- a/src/audio/wasapi/SDL_wasapi.c
+++ b/src/audio/wasapi/SDL_wasapi.c
@@ -157,7 +157,7 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
 
 static int ManagementThreadPrepare(void)
 {
-    if (WASAPI_PlatformInit() == -1) {
+    if (WASAPI_PlatformInit() < 0) {
         return -1;
     }
 
@@ -402,7 +402,7 @@ static SDL_bool RecoverWasapiDevice(SDL_AudioDevice *device)
     ResetWasapiDevice(device); // dump the lost device's handles.
 
     // This handles a non-default device that simply had its format changed in the Windows Control Panel.
-    if (ActivateWasapiDevice(device) == -1) {
+    if (ActivateWasapiDevice(device) < 0) {
         WASAPI_DisconnectDevice(device);
         return SDL_FALSE;
     }
diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c
index b2f3c95e0fd1f..95bf839d8b1c2 100644
--- a/src/audio/wasapi/SDL_wasapi_win32.c
+++ b/src/audio/wasapi/SDL_wasapi_win32.c
@@ -179,7 +179,7 @@ int WASAPI_ActivateDevice(SDL_AudioDevice *device)
     }
 
     SDL_assert(device->hidden->client != NULL);
-    if (WASAPI_PrepDevice(device) == -1) { // not async, fire it right away.
+    if (WASAPI_PrepDevice(device) < 0) { // not async, fire it right away.
         return -1;
     }
 
diff --git a/src/camera/mediafoundation/SDL_camera_mediafoundation.c b/src/camera/mediafoundation/SDL_camera_mediafoundation.c
index e8ab8a2f7d795..e392a18b24549 100644
--- a/src/camera/mediafoundation/SDL_camera_mediafoundation.c
+++ b/src/camera/mediafoundation/SDL_camera_mediafoundation.c
@@ -468,7 +468,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
             } else {
                 frame->pixels = pixels;
                 frame->pitch = (int) pitch;
-                if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer2, NULL) == -1) {
+                if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer2, NULL) < 0) {
                     retval = -1;
                 }
             }
@@ -480,7 +480,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
             } else {
                 frame->pixels = pixels;
                 frame->pitch = (int) pitch;
-                if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer, NULL) == -1) {
+                if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer, NULL) < 0) {
                     retval = -1;
                 }
             }
@@ -497,7 +497,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
                 }
                 frame->pixels = pixels;
                 frame->pitch = (int) pitch;
-                if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMFMediaBuffer, NULL) == -1) {
+                if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMFMediaBuffer, NULL) < 0) {
                     retval = -1;
                 }
             }
diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c
index be296261709ff..e392a2aa35d44 100644
--- a/src/haptic/SDL_haptic.c
+++ b/src/haptic/SDL_haptic.c
@@ -411,7 +411,7 @@ int SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect)
         if (haptic->effects[i].hweffect == NULL) {
 
             /* Now let the backend create the real effect */
-            if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) != 0) {
+            if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) < 0) {
                 return -1; /* Backend failed to create effect */
             }
 
diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c
index ee4abeec7510b..3a51c8ab5ec97 100644
--- a/src/hidapi/SDL_hidapi.c
+++ b/src/hidapi/SDL_hidapi.c
@@ -1303,7 +1303,7 @@ Uint32 SDL_hid_device_change_count(void)
     Uint32 counter = 0;
 
 #ifndef SDL_HIDAPI_DISABLED
-    if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
+    if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
         return 0;
     }
 
@@ -1414,7 +1414,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
     struct hid_device_info *dev;
     struct SDL_hid_device_info *devs = NULL, *last = NULL;
 
-    if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
+    if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
         return NULL;
     }
 
@@ -1504,7 +1504,7 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
 #if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
     void *pDevice = NULL;
 
-    if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
+    if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
         return NULL;
     }
 
@@ -1543,7 +1543,7 @@ SDL_hid_device *SDL_hid_open_path(const char *path)
 #if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
     void *pDevice = NULL;
 
-    if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
+    if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
         return NULL;
     }
 
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 5709df92d3445..ed66e4f98ad57 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -1079,7 +1079,7 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct
         SDL_memcpy(&data[report_size - sizeof(unCRC)], &unCRC, sizeof(unCRC));
     }
 
-    if (SDL_HIDAPI_LockRumble() != 0) {
+    if (SDL_HIDAPI_LockRumble() < 0) {
         return -1;
     }
 
diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c
index f33f96ba4aceb..44daf1873035c 100644
--- a/src/joystick/hidapi/SDL_hidapi_rumble.c
+++ b/src/joystick/hidapi/SDL_hidapi_rumble.c
@@ -256,7 +256,7 @@ int SDL_HIDAPI_SendRumble(SDL_HIDAPI_Device *device, const Uint8 *data, int size
         return SDL_SetError("Tried to send rumble with invalid size");
     }
 
-    if (SDL_HIDAPI_LockRumble() != 0) {
+    if (SDL_HIDAPI_LockRumble() < 0) {
         return -1;
     }
 
diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c
index a146aa9849acf..d44a80082ba63 100644
--- a/src/joystick/hidapi/SDL_hidapi_shield.c
+++ b/src/joystick/hidapi/SDL_hidapi_shield.c
@@ -145,7 +145,7 @@ static int HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd,
         return SDL_SetError("Command data exceeds HID report size");
     }
 
-    if (SDL_HIDAPI_LockRumble() != 0) {
+    if (SDL_HIDAPI_LockRumble() < 0) {
         return -1;
     }
 
diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c
index 470c9ec49e106..62ce9721f3427 100644
--- a/src/joystick/hidapi/SDL_hidapi_wii.c
+++ b/src/joystick/hidapi/SDL_hidapi_wii.c
@@ -218,7 +218,7 @@ static SDL_bool WriteOutput(SDL_DriverWii_Context *ctx, const Uint8 *data, int s
         return SDL_hid_write(ctx->device->dev, data, size) >= 0;
     } else {
         /* Use the rumble thread for general asynchronous writes */
-        if (SDL_HIDAPI_LockRumble() != 0) {
+        if (SDL_HIDAPI_LockRumble() < 0) {
             return SDL_FALSE;
         }
         return SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size) >= 0;
diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c
index 8c6d8a40ed226..ff03f5d563e2b 100644
--- a/src/joystick/hidapi/SDL_hidapi_xboxone.c
+++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c
@@ -235,7 +235,7 @@ static SDL_bool SendProtocolPacket(SDL_DriverXboxOne_Context *ctx, const Uint8 *
 
     ctx->send_time = SDL_GetTicks();
 
-    if (SDL_HIDAPI_LockRumble() != 0) {
+    if (SDL_HIDAPI_LockRumble() < 0) {
         return SDL_FALSE;
     }
     if (SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size) != size) {
@@ -470,7 +470,7 @@ static int HIDAPI_DriverXboxOne_UpdateRumble(SDL_DriverXboxOne_Context *ctx)
     /* We're no longer pending, even if we fail to send the rumble below */
     ctx->rumble_pending = SDL_FALSE;
 
-    if (SDL_HIDAPI_LockRumble() != 0) {
+    if (SDL_HIDAPI_LockRumble() < 0) {
         return -1;
     }
 
diff --git a/src/main/SDL_main_callbacks.c b/src/main/SDL_main_callbacks.c
index a92c70f57cc78..68ca4f425d371 100644
--- a/src/main/SDL_main_callbacks.c
+++ b/src/main/SDL_main_callbacks.c
@@ -99,7 +99,7 @@ SDL_AppResult SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func app
     const SDL_AppResult rc = appinit(&SDL_main_appstate, argc, argv);
     if (SDL_AtomicCompareAndSwap(&apprc, SDL_APP_CONTINUE, rc) && (rc == SDL_APP_CONTINUE)) { // bounce if SDL_AppInit already said abort, otherwise...
         // make sure we definitely have events initialized, even if the app didn't do it.
-        if (SDL_InitSubSystem(SDL_INIT_EVENTS) == -1) {
+        if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) {
             SDL_AtomicSet(&apprc, SDL_APP_FAILURE);
             return -1;
         }
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 28ae90a1fcd2a..ab9a2ad611c1e 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -351,7 +351,7 @@ static int FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture)
 
 int SDL_FlushRenderer(SDL_Renderer *renderer)
 {
-    if (FlushRenderCommands(renderer) == -1) {
+    if (FlushRenderCommands(renderer) < 0) {
         return -1;
     }
     renderer->InvalidateCachedState(renderer);
@@ -1001,7 +1001,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
 #else
         const int rc = SDL_SetError("SDL not built with software renderer");
 #endif
-        if (rc == -1) {
+        if (rc < 0) {
             goto error;
         }
     } else {
@@ -1034,7 +1034,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
             }
         }
 
-        if (rc == -1) {
+        if (rc < 0) {
             if (!name || !attempted) {
                 SDL_SetError("Couldn't find matching render driver");
             }
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index cc6569ccb379a..1c0737379cdb6 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -1228,7 +1228,7 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
 
     EGLSurface surface;
 
-    if (SDL_EGL_ChooseConfig(_this) != 0) {
+    if (SDL_EGL_ChooseConfig(_this) < 0) {
         return EGL_NO_SURFACE;
     }
 
@@ -1319,7 +1319,7 @@ SDL_EGL_CreateOffscreenSurface(SDL_VideoDevice *_this, int width, int height)
     attributes[1] = width;
     attributes[3] = height;
 
-    if (SDL_EGL_ChooseConfig(_this) != 0) {
+    if (SDL_EGL_ChooseConfig(_this) < 0) {
         return EGL_NO_SURFACE;
     }
 
diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c
index 818a661ff9c70..e1ed035890243 100644
--- a/src/video/SDL_yuv.c
+++ b/src/video/SDL_yuv.c
@@ -1174,7 +1174,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
 
         /* convert src/src_format to tmp/XBGR2101010 */
         ret = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_XBGR2101010, dst_colorspace, dst_properties, tmp, tmp_pitch);
-        if (ret == -1) {
+        if (ret < 0) {
             SDL_free(tmp);
             return ret;
         }
@@ -1198,7 +1198,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
 
         /* convert src/src_format to tmp/ARGB8888 */
         ret = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, dst_colorspace, dst_properties, tmp, tmp_pitch);
-        if (ret == -1) {
+        if (ret < 0) {
             SDL_free(tmp);
             return ret;
         }
diff --git a/test/loopwave.c b/test/loopwave.c
index f4c8d41ec9321..d148ef4499c07 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -93,7 +93,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
     }
 
     /* Load the wave file into memory */
-    if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == -1) {
+    if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
         SDL_free(filename);
         return SDL_APP_FAILURE;
diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c
index 4e9b437dac68f..e3f208dd2bb2d 100644
--- a/test/testaudiohotplug.c
+++ b/test/testaudiohotplug.c
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
     }
 
     /* Load the wave file into memory */
-    if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == -1) {
+    if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
         quit(1);
     }
diff --git a/test/testaudiorecording.c b/test/testaudiorecording.c
index 8d1fe43428d94..c5f7821545938 100644
--- a/test/testaudiorecording.c
+++ b/test/testaudiorecording.c
@@ -113,7 +113,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!\n", SDL_GetError());
         SDL_free(devices);
         return SDL_APP_FAILURE;
-    } else if (SDL_BindAudioStream(device, stream_out) == -1) {
+    } else if (SDL_BindAudioStream(device, stream_out) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for playback: %s!\n", SDL_GetError());
         SDL_free(devices);
         return SDL_APP_FAILURE;
@@ -137,7 +137,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
     if (!stream_in) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for recording: %s!\n", SDL_GetError());
         return SDL_APP_FAILURE;
-    } else if (SDL_BindAudioStream(device, stream_in) == -1) {
+    } else if (SDL_BindAudioStream(device, stream_in) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for recording: %s!\n", SDL_GetError());
         return SDL_APP_FAILURE;
     }
diff --git a/test/testfilesystem.c b/test/testfilesystem.c
index e24d9d89e0418..dbb16809c30af 100644
--- a/test/testfilesystem.c
+++ b/test/testfilesystem.c
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
         return 1;
     }
 
-    if (SDL_Init(0) == -1) {
+    if (SDL_Init(0) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
         return 1;
     }
@@ -130,19 +130,19 @@ int main(int argc, char *argv[])
         }
 
         /* !!! FIXME: put this in a subroutine and make it test more thoroughly (and put it in testautomation). */
-        if (SDL_CreateDirectory("testfilesystem-test") == -1) {
+        if (SDL_CreateDirectory("testfilesystem-test") < 0) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test') failed: %s", SDL_GetError());
-        } else if (SDL_CreateDirectory("testfilesystem-test/1") == -1) {
+        } else if (SDL_CreateDirectory("testfilesystem-test/1") < 0) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test/1') failed: %s", SDL_GetError());
-        } else if (SDL_CreateDirectory("testfilesystem-test/1") == -1) {  /* THIS SHOULD NOT FAIL! Making a directory that already exists should succeed here. */
+        } else if (SDL_CreateDirectory("testfilesystem-test/1") < 0) {  /* THIS SHOULD NOT FAIL! Making a directory that already exists should succeed here. */
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test/1') failed: %s", SDL_GetError());
-        } else if (SDL_RenamePath("testfilesystem-test/1", "testfilesystem-test/2") == -1) {
+        } else if (SDL_RenamePath("testfilesystem-test/1", "testfilesystem-test/2") < 0) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RenamePath('testfilesystem-test/1', 'testfilesystem-test/2') failed: %s", SDL_GetError());
-        } else if (SDL_RemovePath("testfilesystem-test/2") == -1) {
+        } else if (SDL_RemovePath("testfilesystem-test/2") < 0) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test/2') failed: %s", SDL_GetError());
-        } else if (SDL_RemovePath("testfilesystem-test") == -1) {
+        } else if (SDL_RemovePath("testfilesystem-test") < 0) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test') failed: %s", SDL_GetError());
-        } else if (SDL_RemovePath("testfilesystem-test") == -1) {  /* THIS SHOULD NOT FAIL! Removing a directory that is already gone should succeed here. */
+        } else if (SDL_RemovePath("testfilesystem-test") < 0) {  /* THIS SHOULD NOT FAIL! Removing a directory that is already gone should succeed here. */
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test') failed: %s", SDL_GetError());
         }
 
diff --git a/test/testhittesting.c b/test/testhittesting.c
index 63e7e3d9c9e4c..739dcd7495af9 100644
--- a/test/testhittesting.c
+++ b/test/testhittesting.c
@@ -99,7 +99,7 @@ int main(int argc, char **argv)
     }
 
     for (i = 0; i < state->num_windows; i++) {
-        if (SDL_SetWindowHitTest(state->windows[i], hitTest, NULL) == -1) {
+        if (SDL_SetWindowHitTest(state->windows[i], hitTest, NULL) < 0) {
             SDL_Log("Enabling hit-testing failed for window %d: %s", i, SDL_GetError());
             SDL_Quit();
             return 1;
diff --git a/test/testhotplug.c b/test/testhotplug.c
index ec635c1bf4fe3..2333bd30005ef 100644
--- a/test/testhotplug.c
+++ b/test/testhotplug.c
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
                             haptic = SDL_OpenHapticFromJoystick(joystick);
                             if (haptic) {
                                 SDL_Log("Joy Haptic Opened\n");
-                                if (SDL_InitHapticRumble(haptic) != 0) {
+                                if (SDL_InitHapticRumble(haptic) < 0) {
                                     SDL_Log("Could not init Rumble!: %s\n", SDL_GetError());
                                     SDL_CloseHaptic(haptic);
                                     haptic = NULL;
diff --git a/test/testime.c b/test/testime.c
index f6cc4f0368d18..a688b4d6d3521 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -361,7 +361,7 @@ static int unifont_load_texture(Uint32 textureID)
         }
         unifontTexture[UNIFONT_NUM_TEXTURES * i + textureID] = tex;
         SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
-        if (SDL_UpdateTexture(tex, NULL, textureRGBA, UNIFONT_TEXTURE_PITCH) != 0) {
+        if (SDL_UpdateTexture(tex, NULL, textureRGBA, UNIFONT_TEXTURE_PITCH) < 0) {
             SDL_Log("unifont error: Failed to update texture %" SDL_PRIu32 " data for renderer %d.\n", textureID, i);
         }
     }
diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c
index 98bab13e38069..da44212a18cfb 100644
--- a/test/testmultiaudio.c
+++ b/test/testmultiaudio.c
@@ -185,7 +185,7 @@ int main(int argc, char **argv)
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio playback devices!");
     } else {
         /* Load the wave file into memory */
-        if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == -1) {
+        if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) < 0) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename,
                          SDL_GetError());
         } else {
diff --git a/test/testresample.c b/test/testresample.c
index 19ed756176a7d..687e5fbd64798 100644
--- a/test/testresample.c
+++ b/test/testresample.c
@@ -95,13 +95,13 @@ int main(int argc, char **argv)
         goto end;
     }
 
-    if (SDL_Init(SDL_INIT_AUDIO) == -1) {
+    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
         ret = 2;
         goto end;
     }
 
-    if (SDL_LoadWAV(file_in, &spec, &data, &len) == -1) {
+    if (SDL_LoadWAV(file_in, &spec, &data, &len) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", file_in, SDL_GetError());
         ret = 3;
         goto end;
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
     SDL_WriteU32LE(io, dst_len);                                /* size */
     SDL_WriteIO(io, dst_buf, dst_len);
 
-    if (SDL_CloseIO(io) == -1) {
+    if (SDL_CloseIO(io) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "closing '%s' failed: %s\n", file_out, SDL_GetError());
         ret = 6;
         goto end;
diff --git a/test/testrumble.c b/test/testrumble.c
index d57463fba3582..ba1201ce36c38 100644
--- a/test/testrumble.c
+++ b/test/testrumble.c
@@ -136,12 +136,12 @@ int main(int argc, char **argv)
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n");
         return 1;
     }
-    if (SDL_InitHapticRumble(haptic) != 0) {
+    if (SDL_InitHapticRumble(haptic) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError());
         return 1;
     }
     SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n");
-    if (SDL_PlayHapticRumble(haptic, 0.5, 5000) != 0) {
+    if (SDL_PlayHapticRumble(haptic, 0.5, 5000) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
         return 1;
     }
@@ -150,7 +150,7 @@ int main(int argc, char **argv)
     SDL_StopHapticRumble(haptic);
     SDL_Delay(2000);
     SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n");
-    if (SDL_PlayHapticRumble(haptic, 0.3f, 5000) != 0) {
+    if (SDL_PlayHapticRumble(haptic, 0.3f, 5000) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
         return 1;
     }
diff --git a/test/testsurround.c b/test/testsurround.c
index 7796001e48f98..be1911fe7e124 100644
--- a/test/testsurround.c
+++ b/test/testsurround.c
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
 
         SDL_Log("Testing audio device: %s\n", devname);
 
-        if (SDL_GetAudioDeviceFormat(devices[i], &spec, NULL) != 0) {
+        if (SDL_GetAudioDeviceFormat(devices[i], &spec, NULL) < 0) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioDeviceFormat() failed: %s\n", SDL_GetError());
             continue;
         }
diff --git a/test/testurl.c b/test/testurl.c
index 8b4f1caa767d3..7898de38a6e75 100644
--- a/test/testurl.c
+++ b/test/testurl.c
@@ -25,7 +25,7 @@ static void tryOpenURL(const char *url)
 int main(int argc, char **argv)
 {
     int i;
-    if (SDL_Init(SDL_INIT_VIDEO) == -1) {
+    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
         SDL_Log("SDL_Init failed: %s\n", SDL_GetError());
         return 1;
     }