SDL: filesystem: SDL_EnumerateDirectory should return -1 or 0.

From 91924857468b73511ac2e41221060874a9315604 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 18 Mar 2024 15:31:35 -0400
Subject: [PATCH] filesystem: SDL_EnumerateDirectory should return -1 or 0.

The callback requesting a non-error stop should not return a special value.
---
 include/SDL3/SDL_filesystem.h   | 5 ++++-
 src/filesystem/SDL_filesystem.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/SDL3/SDL_filesystem.h b/include/SDL3/SDL_filesystem.h
index 239a6513d0e6f..36ce139a7c235 100644
--- a/include/SDL3/SDL_filesystem.h
+++ b/include/SDL3/SDL_filesystem.h
@@ -265,7 +265,10 @@ typedef struct SDL_PathInfo
  */
 extern DECLSPEC int SDLCALL SDL_CreateDirectory(const char *path);
 
-/* Callback for directory enumeration. Return 1 to keep enumerating, 0 to stop enumerating (no error), -1 to stop enumerating and report an error. `dirname` is the directory being enumerated, `fname` is the enumerated entry. */
+/* Callback for directory enumeration. Return 1 to keep enumerating,
+   0 to stop enumerating (no error), -1 to stop enumerating and
+   report an error. `dirname` is the directory being enumerated,
+   `fname` is the enumerated entry. */
 typedef int (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, const char *dirname, const char *fname);
 
 /**
diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c
index 2a8667ffa71e4..951d52f0446ce 100644
--- a/src/filesystem/SDL_filesystem.c
+++ b/src/filesystem/SDL_filesystem.c
@@ -56,7 +56,7 @@ int SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback call
     } else if (!callback) {
         return SDL_InvalidParamError("callback");
     }
-    return SDL_SYS_EnumerateDirectory(path, path, callback, userdata);
+    return (SDL_SYS_EnumerateDirectory(path, path, callback, userdata) < 0) ? -1 : 0;
 }
 
 int SDL_GetPathInfo(const char *path, SDL_PathInfo *info)