SDL: Change return type from void to int, for functions that set an error

From c5c94a6be6bfaccec9c41f6326bd4be6b2db8aea Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Mon, 6 Feb 2023 20:24:12 +0100
Subject: [PATCH] Change return type from void to int, for functions that set
 an error (SDL_SetError(), SDL_OutOfMemory(), SDL_Unsupported(),
 SDL_InvalidParam())

Update prototype to forward errors to generic layer, for the functions:
MoveCursor, WarpMouse, GL_DeleteContext, GetDisplayModes.

Check invalid parameter in SDL_SetTextInputRect() generic layer.
---
 include/SDL3/SDL_audio.h                      |   4 +-
 include/SDL3/SDL_hidapi.h                     |   4 +-
 include/SDL3/SDL_joystick.h                   |   8 +-
 include/SDL3/SDL_keyboard.h                   |   4 +-
 include/SDL3/SDL_mouse.h                      |   4 +-
 include/SDL3/SDL_pixels.h                     |   8 +-
 include/SDL3/SDL_rect.h                       |   8 +-
 include/SDL3/SDL_render.h                     |  17 ++-
 include/SDL3/SDL_video.h                      |  80 ++++++++---
 src/audio/SDL_audiocvt.c                      |   6 +-
 src/audio/SDL_mixer.c                         |   9 +-
 src/core/linux/SDL_udev.c                     |   8 +-
 src/core/linux/SDL_udev.h                     |   2 +-
 src/dynapi/SDL_dynapi_procs.h                 |  68 ++++-----
 src/events/SDL_mouse.c                        |   8 +-
 src/events/SDL_mouse_c.h                      |   4 +-
 src/hidapi/SDL_hidapi.c                       |   5 +-
 src/joystick/SDL_gamepad.c                    |  21 ++-
 src/joystick/SDL_joystick.c                   |  12 +-
 src/joystick/windows/SDL_rawinputjoystick.c   |  19 ++-
 src/joystick/windows/SDL_rawinputjoystick_c.h |   2 +-
 src/locale/SDL_syslocale.h                    |   2 +-
 src/locale/android/SDL_syslocale.c            |   3 +-
 src/locale/dummy/SDL_syslocale.c              |   4 +-
 src/locale/emscripten/SDL_syslocale.c         |   3 +-
 src/locale/haiku/SDL_syslocale.cc             |   9 +-
 src/locale/macos/SDL_syslocale.m              |   3 +-
 src/locale/n3ds/SDL_syslocale.c               |   3 +-
 src/locale/unix/SDL_syslocale.c               |   6 +-
 src/locale/vita/SDL_syslocale.c               |   3 +-
 src/locale/windows/SDL_syslocale.c            |   9 +-
 src/locale/winrt/SDL_syslocale.c              |   3 +-
 src/render/SDL_render.c                       |  26 ++--
 src/video/SDL_egl.c                           |   5 +-
 src/video/SDL_egl_c.h                         |   2 +-
 src/video/SDL_pixels.c                        |  16 +--
 src/video/SDL_rect_impl.h                     |  16 +--
 src/video/SDL_sysvideo.h                      |   6 +-
 src/video/SDL_video.c                         | 133 +++++++++++-------
 src/video/android/SDL_androidkeyboard.c       |   9 +-
 src/video/android/SDL_androidkeyboard.h       |   2 +-
 src/video/cocoa/SDL_cocoakeyboard.h           |   2 +-
 src/video/cocoa/SDL_cocoakeyboard.m           |   9 +-
 src/video/cocoa/SDL_cocoamodes.h              |   2 +-
 src/video/cocoa/SDL_cocoamodes.m              |   3 +-
 src/video/cocoa/SDL_cocoamouse.m              |   4 +-
 src/video/cocoa/SDL_cocoaopengl.h             |   2 +-
 src/video/cocoa/SDL_cocoaopengl.m             |   3 +-
 src/video/cocoa/SDL_cocoaopengles.h           |   2 +-
 src/video/cocoa/SDL_cocoaopengles.m           |   3 +-
 src/video/emscripten/SDL_emscriptenopengles.c |   3 +-
 src/video/emscripten/SDL_emscriptenopengles.h |   2 +-
 src/video/haiku/SDL_bmodes.cc                 |   3 +-
 src/video/haiku/SDL_bmodes.h                  |   2 +-
 src/video/haiku/SDL_bopengl.cc                |   3 +-
 src/video/haiku/SDL_bopengl.h                 |   2 +-
 src/video/kmsdrm/SDL_kmsdrmmouse.c            |  29 ++--
 src/video/kmsdrm/SDL_kmsdrmmouse.h            |   2 +-
 src/video/kmsdrm/SDL_kmsdrmvideo.c            |   3 +-
 src/video/kmsdrm/SDL_kmsdrmvideo.h            |   4 +-
 src/video/n3ds/SDL_n3dsvideo.c                |   8 +-
 src/video/psp/SDL_pspevents.c                 |   9 +-
 src/video/psp/SDL_pspgl.c                     |  11 +-
 src/video/psp/SDL_pspvideo.c                  |   3 +-
 src/video/psp/SDL_pspvideo.h                  |   4 +-
 src/video/raspberry/SDL_rpimouse.c            |  10 +-
 src/video/raspberry/SDL_rpivideo.h            |   4 +-
 src/video/riscos/SDL_riscosmodes.c            |  16 +--
 src/video/riscos/SDL_riscosmodes.h            |   2 +-
 src/video/uikit/SDL_uikitmodes.h              |   2 +-
 src/video/uikit/SDL_uikitmodes.m              |   3 +-
 src/video/uikit/SDL_uikitopengles.h           |   2 +-
 src/video/uikit/SDL_uikitopengles.m           |   3 +-
 src/video/uikit/SDL_uikitviewcontroller.h     |   2 +-
 src/video/uikit/SDL_uikitviewcontroller.m     |   8 +-
 src/video/vita/SDL_vitagles.c                 |  10 +-
 src/video/vita/SDL_vitavideo.h                |   4 +-
 src/video/vivante/SDL_vivantevideo.h          |   2 +-
 src/video/wayland/SDL_waylandkeyboard.c       |   9 +-
 src/video/wayland/SDL_waylandkeyboard.h       |   2 +-
 src/video/wayland/SDL_waylandmouse.c          |   7 +-
 src/video/wayland/SDL_waylandopengles.c       |   3 +-
 src/video/wayland/SDL_waylandopengles.h       |   2 +-
 src/video/wayland/SDL_waylandvideo.c          |   6 +-
 src/video/windows/SDL_windowskeyboard.c       |  22 ++-
 src/video/windows/SDL_windowskeyboard.h       |   2 +-
 src/video/windows/SDL_windowsmodes.c          |   3 +-
 src/video/windows/SDL_windowsmodes.h          |   2 +-
 src/video/windows/SDL_windowsmouse.c          |   5 +-
 src/video/windows/SDL_windowsopengl.c         |   5 +-
 src/video/windows/SDL_windowsopengl.h         |   2 +-
 src/video/windows/SDL_windowsopengles.c       |   3 +-
 src/video/windows/SDL_windowsopengles.h       |   2 +-
 src/video/x11/SDL_x11keyboard.c               |   8 +-
 src/video/x11/SDL_x11keyboard.h               |   2 +-
 src/video/x11/SDL_x11modes.c                  |   4 +-
 src/video/x11/SDL_x11modes.h                  |   2 +-
 src/video/x11/SDL_x11mouse.c                  |   7 +-
 src/video/x11/SDL_x11opengl.c                 |   9 +-
 src/video/x11/SDL_x11opengl.h                 |   2 +-
 100 files changed, 471 insertions(+), 388 deletions(-)

diff --git a/include/SDL3/SDL_audio.h b/include/SDL3/SDL_audio.h
index 583befa51a01..202c8277c42e 100644
--- a/include/SDL3/SDL_audio.h
+++ b/include/SDL3/SDL_audio.h
@@ -851,10 +851,12 @@ extern DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream);
  * \param len the length of the audio buffer in bytes
  * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
  *               for full audio volume
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
+extern DECLSPEC int SDLCALL SDL_MixAudioFormat(Uint8 * dst,
                                                 const Uint8 * src,
                                                 SDL_AudioFormat format,
                                                 Uint32 len, int volume);
diff --git a/include/SDL3/SDL_hidapi.h b/include/SDL3/SDL_hidapi.h
index c26f86b4ba37..ff616c67d101 100644
--- a/include/SDL3/SDL_hidapi.h
+++ b/include/SDL3/SDL_hidapi.h
@@ -377,10 +377,12 @@ extern DECLSPEC int SDLCALL SDL_hid_get_feature_report(SDL_hid_device *dev, unsi
  * Close a HID device.
  *
  * \param dev A device handle returned from SDL_hid_open().
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_hid_close(SDL_hid_device *dev);
+extern DECLSPEC int SDLCALL SDL_hid_close(SDL_hid_device *dev);
 
 /**
  * Get The Manufacturer String from a HID device.
diff --git a/include/SDL3/SDL_joystick.h b/include/SDL3/SDL_joystick.h
index 2891bf4ad94f..e17e3f9366ec 100644
--- a/include/SDL3/SDL_joystick.h
+++ b/include/SDL3/SDL_joystick.h
@@ -493,10 +493,12 @@ extern DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick);
  * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
  * \param player_index Player index to assign to this joystick, or -1 to clear
  *                     the player index and turn off player LEDs.
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
+extern DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
 
 /**
  * Get the implementation-dependent GUID for the joystick.
@@ -966,12 +968,14 @@ extern DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const
  * Close a joystick previously opened with SDL_OpenJoystick().
  *
  * \param joystick The joystick device to close
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_OpenJoystick
  */
-extern DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
+extern DECLSPEC int SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
 
 /**
  * Get the battery level of a joystick as SDL_JoystickPowerLevel.
diff --git a/include/SDL3/SDL_keyboard.h b/include/SDL3/SDL_keyboard.h
index eb6ab3fdece0..3ecc49a0c05a 100644
--- a/include/SDL3/SDL_keyboard.h
+++ b/include/SDL3/SDL_keyboard.h
@@ -310,12 +310,14 @@ extern DECLSPEC SDL_bool SDLCALL SDL_TextInputShown(void);
  *
  * \param rect the SDL_Rect structure representing the rectangle to receive
  *             text (ignored if NULL)
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_StartTextInput
  */
-extern DECLSPEC void SDLCALL SDL_SetTextInputRect(const SDL_Rect *rect);
+extern DECLSPEC int SDLCALL SDL_SetTextInputRect(const SDL_Rect *rect);
 
 /**
  * Check whether the platform has screen keyboard support.
diff --git a/include/SDL3/SDL_mouse.h b/include/SDL3/SDL_mouse.h
index 83a7d165c8fd..c90d53d7c88c 100644
--- a/include/SDL3/SDL_mouse.h
+++ b/include/SDL3/SDL_mouse.h
@@ -364,13 +364,15 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
  * this is desired for any reason.
  *
  * \param cursor a cursor to make active
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_CreateCursor
  * \sa SDL_GetCursor
  */
-extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
+extern DECLSPEC int SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
 
 /**
  * Get the active cursor.
diff --git a/include/SDL3/SDL_pixels.h b/include/SDL3/SDL_pixels.h
index 705add6fbfde..ffb6217b066f 100644
--- a/include/SDL3/SDL_pixels.h
+++ b/include/SDL3/SDL_pixels.h
@@ -416,12 +416,14 @@ extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_CreatePixelFormat(Uint32 pixel_for
  * Free an SDL_PixelFormat structure allocated by SDL_CreatePixelFormat().
  *
  * \param format the SDL_PixelFormat structure to free
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_CreatePixelFormat
  */
-extern DECLSPEC void SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
+extern DECLSPEC int SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
 
 /**
  * Create a palette structure with the specified number of color entries.
@@ -478,12 +480,14 @@ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
  * Free a palette created with SDL_CreatePalette().
  *
  * \param palette the SDL_Palette structure to be freed
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_CreatePalette
  */
-extern DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
+extern DECLSPEC int SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
 
 /**
  * Map an RGB triple to an opaque pixel value for a given pixel format.
diff --git a/include/SDL3/SDL_rect.h b/include/SDL3/SDL_rect.h
index af62fdb7455a..7d93d17847dd 100644
--- a/include/SDL3/SDL_rect.h
+++ b/include/SDL3/SDL_rect.h
@@ -172,10 +172,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersection(const SDL_Rect * A,
  * \param B an SDL_Rect structure representing the second rectangle
  * \param result an SDL_Rect structure filled in with the union of rectangles
  *               `A` and `B`
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_GetRectUnion(const SDL_Rect * A,
+extern DECLSPEC int SDLCALL SDL_GetRectUnion(const SDL_Rect * A,
                                            const SDL_Rect * B,
                                            SDL_Rect * result);
 
@@ -311,10 +313,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersectionFloat(const SDL_FRect *
  * \param B an SDL_FRect structure representing the second rectangle
  * \param result an SDL_FRect structure filled in with the union of rectangles
  *               `A` and `B`
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_GetRectUnionFloat(const SDL_FRect * A,
+extern DECLSPEC int SDLCALL SDL_GetRectUnionFloat(const SDL_FRect * A,
                                             const SDL_FRect * B,
                                             SDL_FRect * result);
 
diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h
index 8205b2d87835..9a20f8664e88 100644
--- a/include/SDL3/SDL_render.h
+++ b/include/SDL3/SDL_render.h
@@ -783,11 +783,14 @@ extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
  *
  * \param texture a texture locked by SDL_LockTexture()
  *
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
+ *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_LockTexture
  */
-extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
+extern DECLSPEC int SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
 
 /**
  * Set a texture as the current rendering target.
@@ -1408,6 +1411,8 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer,
  * pixel.
  *
  * \param renderer the rendering context
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \threadsafety You may only call this function on the main thread.
  *
@@ -1425,7 +1430,7 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer,
  * \sa SDL_SetRenderDrawBlendMode
  * \sa SDL_SetRenderDrawColor
  */
-extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
+extern DECLSPEC int SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
 
 /**
  * Destroy the specified texture.
@@ -1434,13 +1439,15 @@ extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
  * to "Invalid texture".
  *
  * \param texture the texture to destroy
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_CreateTexture
  * \sa SDL_CreateTextureFromSurface
  */
-extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
+extern DECLSPEC int SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
 
 /**
  * Destroy the rendering context for a window and free associated textures.
@@ -1449,12 +1456,14 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
  * the SDL error message to "Invalid renderer". See SDL_GetError().
  *
  * \param renderer the rendering context
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_CreateRenderer
  */
-extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
+extern DECLSPEC int SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
 
 /**
  * Force the rendering context to flush any pending commands to the underlying
diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h
index d35d61951b65..6731c9a058d8 100644
--- a/include/SDL3/SDL_video.h
+++ b/include/SDL3/SDL_video.h
@@ -821,12 +821,14 @@ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *
  *          `SDL_WINDOWPOS_UNDEFINED`
  * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
  *          `SDL_WINDOWPOS_UNDEFINED`
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetWindowPosition
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
+extern DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
 
 /**
  * Get the position of a window, in screen coordinates.
@@ -837,12 +839,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, in
  * \param window the window to query
  * \param x a pointer filled in with the x position of the window, may be NULL
  * \param y a pointer filled in with the y position of the window, may be NULL
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_SetWindowPosition
  */
-extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
+extern DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
 
 /**
  * Set the size of a window's client area, in screen coordinates.
@@ -880,6 +884,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
  * \param window the window to query the width and height from
  * \param w a pointer filled in with the width of the window, may be NULL
  * \param h a pointer filled in with the height of the window, may be NULL
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
@@ -887,7 +893,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
  * \sa SDL_GetWindowSizeInPixels
  * \sa SDL_SetWindowSize
  */
-extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
+extern DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
 
 /**
  * Get the size of a window's borders (decorations) around the client area, in
@@ -934,13 +940,15 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *to
  * \param w a pointer to variable for storing the width in pixels, may be NULL
  * \param h a pointer to variable for storing the height in pixels, may be
  *          NULL
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_CreateWindow
  * \sa SDL_GetWindowSize
  */
-extern DECLSPEC void SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
+extern DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
 
 /**
  * Set the minimum size of a window's client area, in screen coordinates.
@@ -966,13 +974,15 @@ extern DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min
  *          NULL
  * \param h a pointer filled in with the minimum height of the window, may be
  *          NULL
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetWindowMaximumSize
  * \sa SDL_SetWindowMinimumSize
  */
-extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
+extern DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
 
 /**
  * Set the maximum size of a window's client area, in screen coordinates.
@@ -998,13 +1008,15 @@ extern DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max
  *          NULL
  * \param h a pointer filled in with the maximum height of the window, may be
  *          NULL
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetWindowMinimumSize
  * \sa SDL_SetWindowMaximumSize
  */
-extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
+extern DECLSPEC int SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
 
 /**
  * Set the border state of a window.
@@ -1017,12 +1029,14 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w
  *
  * \param window the window of which to change the border state
  * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetWindowFlags
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
+extern DECLSPEC int SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
 
 /**
  * Set the user-resizable state of a window.
@@ -1035,12 +1049,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool
  *
  * \param window the window of which to change the resizable state
  * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetWindowFlags
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
+extern DECLSPEC int SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
 
 /**
  * Set the window to always be above the others.
@@ -1051,80 +1067,94 @@ extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool
  * \param window The window of which to change the always on top state
  * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
  *               disable
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetWindowFlags
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
+extern DECLSPEC int SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
 
 /**
  * Show a window.
  *
  * \param window the window to show
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_HideWindow
  * \sa SDL_RaiseWindow
  */
-extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window *window);
+extern DECLSPEC int SDLCALL SDL_ShowWindow(SDL_Window *window);
 
 /**
  * Hide a window.
  *
  * \param window the window to hide
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_ShowWindow
  */
-extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window *window);
+extern DECLSPEC int SDLCALL SDL_HideWindow(SDL_Window *window);
 
 /**
  * Raise a window above other windows and set the input focus.
  *
  * \param window the window to raise
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window *window);
+extern DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
 
 /**
  * Make a window as large as possible.
  *
  * \param window the window to maximize
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_MinimizeWindow
  * \sa SDL_RestoreWindow
  */
-extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window *window);
+extern DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
 
 /**
  * Minimize a window to an iconic representation.
  *
  * \param window the window to minimize
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_MaximizeWindow
  * \sa SDL_RestoreWindow
  */
-extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window *window);
+extern DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
 
 /**
  * Restore the size and position of a minimized or maximized window.
  *
  * \param window the window to restore
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_MaximizeWindow
  * \sa SDL_MinimizeWindow
  */
-extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window *window);
+extern DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
 
 /**
  * Set a window's fullscreen state.
@@ -1222,13 +1252,15 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, con
  *
  * \param window the window for which the input grab mode should be set
  * \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GetGrabbedWindow
  * \sa SDL_GetWindowGrab
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
+extern DECLSPEC int SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
 
 /**
  * Set a window's keyboard grab mode.
@@ -1251,6 +1283,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grab
  *
  * \param window The window for which the keyboard grab mode should be set.
  * \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
@@ -1258,7 +1292,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grab
  * \sa SDL_SetWindowMouseGrab
  * \sa SDL_SetWindowGrab
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
+extern DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
 
 /**
  * Set a window's mouse grab mode.
@@ -1267,6 +1301,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_b
  *
  * \param window The window for which the mouse grab mode should be set.
  * \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release.
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
@@ -1274,7 +1310,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_b
  * \sa SDL_SetWindowKeyboardGrab
  * \sa SDL_SetWindowGrab
  */
-extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
+extern DECLSPEC int SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
 
 /**
  * Get a window's input grab mode.
@@ -1521,13 +1557,15 @@ extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperati
  * the SDL error message to "Invalid window". See SDL_GetError().
  *
  * \param window the window to destroy
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_CreateWindow
  * \sa SDL_CreateWindowFrom
  */
-extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
+extern DECLSPEC int SDLCALL SDL_DestroyWindow(SDL_Window *window);
 
 
 /**
@@ -1933,12 +1971,14 @@ extern DECLSPEC int SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
  * Delete an OpenGL context.
  *
  * \param context the OpenGL context to be deleted
+ * \returns 0 on success or a negative error code on failure; call
+ *          SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
  * \sa SDL_GL_CreateContext
  */
-extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
+extern DECLSPEC int SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
 
 /* @} *//* OpenGL support functions */
 
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 7878f6eea0fd..895e9cf6a674 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -564,7 +564,7 @@ static void SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_Au
 
 #endif /* HAVE_LIBSAMPLERATE_H */
 
-static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
+static int SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
 {
     /* !!! FIXME in 2.1: there are ten slots in the filter list, and the theoretical maximum we use is six (seven with NULL terminator).
        !!! FIXME in 2.1:   We need to store data for this resampler, because the cvt structure doesn't store the original sample rates,
@@ -592,8 +592,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF
     /* we keep no streaming state here, so pad with silence on both ends. */
     padding = (float *)SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof(float));
     if (padding == NULL) {
-        SDL_OutOfMemory();
-        return;
+        return SDL_OutOfMemory();
     }
 
     cvt->len_cvt = SDL_ResampleAudio(chans, inrate, outrate, padding, padding, src, srclen, dst, dstlen);
@@ -605,6 +604,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF
     if (cvt->filters[++cvt->filter_index]) {
         cvt->filters[cvt->filter_index](cvt, format);
     }
+    return 0;
 }
 
 /* !!! FIXME: We only have this macro salsa because SDL_AudioCVT doesn't
diff --git a/src/audio/SDL_mixer.c b/src/audio

(Patch may be truncated, please check the link at the top of this post.)