SDL: SDL_rwops.c: simplify `foo <= 0` checks to `!foo` with unsigned types.

From 565ef63873c2dfa85e1e80db9dfbefbd9a8c67db Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 4 Jan 2022 11:40:04 +0300
Subject: [PATCH] SDL_rwops.c: simplify `foo <= 0` checks to `!foo` with
 unsigned types.

---
 Makefile.os2         |  3 ---
 src/file/SDL_rwops.c | 22 ++++++++++------------
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/Makefile.os2 b/Makefile.os2
index ae3ba6fb01d..fb6289e5d29 100644
--- a/Makefile.os2
+++ b/Makefile.os2
@@ -122,9 +122,6 @@ SDL_syscond.obj: "src/thread/generic/SDL_syscond.c"
 SDL_cpuinfo.obj: SDL_cpuinfo.c
     wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
 
-SDL_rwops.obj: SDL_rwops.c
-    wcc386 $(CFLAGS) -wcd=136 -fo=$^@ $<
-
 SDL_wave.obj: SDL_wave.c
     wcc386 $(CFLAGS) -wcd=124 -fo=$^@ $<
 
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index 8c92018da55..5187fae0417 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -166,8 +166,7 @@ vita_file_size(SDL_RWops * context)
         return SDL_SetError("vita_file_size: invalid context/file not opened");
     }
 
-    if (sceIoGetstatByFd(context->hidden.vitaio.h, &st) < 0)
-    {
+    if (sceIoGetstatByFd(context->hidden.vitaio.h, &st) < 0) {
         return SDL_SetError("vita_file_size: could not get file size");
     }
     return st.st_size;
@@ -215,9 +214,9 @@ vita_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
 
     total_need = size * maxnum;
 
-    if (!context || context->hidden.vitaio.h < 0
-        || !total_need)
+    if (!context || context->hidden.vitaio.h < 0 || !total_need) {
         return 0;
+    }
 
     if (context->hidden.vitaio.buffer.left > 0) {
         void *data = (char *) context->hidden.vitaio.buffer.data +
@@ -261,9 +260,9 @@ vita_file_write(SDL_RWops * context, const void *ptr, size_t size,
 
     total_bytes = size * num;
 
-    if (!context || context->hidden.vitaio.h < 0
-        || total_bytes <= 0 || !size)
+    if (!context || context->hidden.vitaio.h < 0 || !size || !total_bytes) {
         return 0;
+    }
 
     if (context->hidden.vitaio.buffer.left) {
         sceIoLseek(context->hidden.vitaio.h, -(SceOff)context->hidden.vitaio.buffer.left, SCE_SEEK_CUR);
@@ -433,9 +432,9 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
 
     total_need = size * maxnum;
 
-    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
-        || !total_need)
+    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) {
         return 0;
+    }
 
     if (context->hidden.windowsio.buffer.left > 0) {
         void *data = (char *) context->hidden.windowsio.buffer.data +
@@ -488,9 +487,9 @@ windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
 
     total_bytes = size * num;
 
-    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
-        || total_bytes <= 0 || !size)
+    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) {
         return 0;
+    }
 
     if (context->hidden.windowsio.buffer.left) {
         SetFilePointer(context->hidden.windowsio.h,
@@ -709,8 +708,7 @@ mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
     size_t mem_available;
 
     total_bytes = (maxnum * size);
-    if ((maxnum <= 0) || (size <= 0)
-        || ((total_bytes / maxnum) != size)) {
+    if (!maxnum || !size || ((total_bytes / maxnum) != size)) {
         return 0;
     }