SDL_image: Updated for SDL3 change of SDL_SetError returning SDL_FALSE, not -1

From c9d7d4b84adfb27b49e236b9ea53163cfc1705fd Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 27 Aug 2024 22:39:20 +0300
Subject: [PATCH] Updated for SDL3 change of SDL_SetError returning SDL_FALSE,
 not -1

---
 examples/showimage.c |  3 ++-
 src/IMG_avif.c       |  6 ++++--
 src/IMG_jpg.c        |  9 ++++++---
 src/IMG_png.c        | 15 ++++++++++-----
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/examples/showimage.c b/examples/showimage.c
index ccc114f4..671cb2b5 100644
--- a/examples/showimage.c
+++ b/examples/showimage.c
@@ -182,7 +182,8 @@ int main(int argc, char *argv[])
                 } else if (ext && SDL_strcasecmp(ext, ".png") == 0) {
                     result = IMG_SavePNG(surface, saveFile);
                 } else {
-                    result = SDL_SetError("Unknown save file type");
+                    SDL_SetError("Unknown save file type");
+                    result = -1;
                 }
                 if (result < 0) {
                     SDL_Log("Couldn't save %s: %s\n", saveFile, SDL_GetError());
diff --git a/src/IMG_avif.c b/src/IMG_avif.c
index 2e89cd2e..c61cdd3d 100644
--- a/src/IMG_avif.c
+++ b/src/IMG_avif.c
@@ -751,7 +751,8 @@ int IMG_SaveAVIF_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int qu
     int result = -1;
 
     if (!dst) {
-        return IMG_SetError("Passed NULL dst");
+        IMG_SetError("Passed NULL dst");
+        return -1;
     }
 
 #ifdef SDL_IMAGE_SAVE_AVIF
@@ -761,7 +762,8 @@ int IMG_SaveAVIF_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int qu
 #else
     (void) surface;
     (void) quality;
-    result = IMG_SetError("SDL_image built without AVIF save support");
+    IMG_SetError("SDL_image built without AVIF save support");
+    result = -1;
 #endif
 
     if (closeio) {
diff --git a/src/IMG_jpg.c b/src/IMG_jpg.c
index e781c48c..2bda404e 100644
--- a/src/IMG_jpg.c
+++ b/src/IMG_jpg.c
@@ -497,7 +497,8 @@ static int JPEG_SaveJPEG_IO(struct savejpeg_vars *vars, SDL_Surface *jpeg_surfac
         /* If we get here, libjpeg found an error */
         lib.jpeg_destroy_compress(&vars->cinfo);
         SDL_SeekIO(dst, vars->original_offset, SDL_IO_SEEK_SET);
-        return IMG_SetError("Error saving JPEG with libjpeg");
+        IMG_SetError("Error saving JPEG with libjpeg");
+        return -1;
     }
 
     lib.jpeg_create_compress(&vars->cinfo);
@@ -771,7 +772,8 @@ int IMG_SaveJPG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int qua
     (void)quality;
 
     if (!dst) {
-        return IMG_SetError("Passed NULL dst");
+        IMG_SetError("Passed NULL dst");
+        return -1;
     }
 
 #if SDL_IMAGE_SAVE_JPG
@@ -788,7 +790,8 @@ int IMG_SaveJPG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int qua
 #endif
 
 #else
-    result = IMG_SetError("SDL_image built without JPEG save support");
+    IMG_SetError("SDL_image built without JPEG save support");
+    result = -1;
 #endif
 
     if (closeio) {
diff --git a/src/IMG_png.c b/src/IMG_png.c
index d5bfebff..a291a4ba 100644
--- a/src/IMG_png.c
+++ b/src/IMG_png.c
@@ -613,7 +613,8 @@ static int LIBPNG_SavePNG_IO(struct savepng_vars *vars, SDL_Surface *surface, SD
 
     vars->png_ptr = lib.png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
     if (vars->png_ptr == NULL) {
-        return IMG_SetError("Couldn't allocate memory for PNG file or incompatible PNG dll");
+        IMG_SetError("Couldn't allocate memory for PNG file or incompatible PNG dll");
+        return -1;
     }
 
     vars->info_ptr = lib.png_create_info_struct(vars->png_ptr);
@@ -768,7 +769,8 @@ static int IMG_SavePNG_IO_miniz(SDL_Surface *surface, SDL_IOStream *dst)
     int result = -1;
 
     if (!dst) {
-        return IMG_SetError("Passed NULL dst");
+        IMG_SetError("Passed NULL dst");
+        return -1;
     }
 
     if (surface->format == png_format) {
@@ -786,7 +788,8 @@ static int IMG_SavePNG_IO_miniz(SDL_Surface *surface, SDL_IOStream *dst)
         }
         mz_free(png); /* calls SDL_free() */
     } else {
-        return IMG_SetError("Failed to convert and save image");
+        IMG_SetError("Failed to convert and save image");
+        return -1;
     }
     return result;
 }
@@ -809,7 +812,8 @@ int IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio)
     int result = -1;
 
     if (!dst) {
-        return IMG_SetError("Passed NULL dst");
+        IMG_SetError("Passed NULL dst");
+        return -1;
     }
 
 #if SDL_IMAGE_SAVE_PNG
@@ -826,7 +830,8 @@ int IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio)
 #endif
 
 #else
-    result = IMG_SetError("SDL_image built without PNG save support");
+    IMG_SetError("SDL_image built without PNG save support");
+    result = -1;
 #endif
 
     if (closeio) {