From e2e5e670bf40a1b0d9ef11caa1183811ccefc498 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Thu, 9 Feb 2023 16:53:47 +0100
Subject: [PATCH] Remove returns int from Destroy/Close/Unlock functions
---
include/SDL3/SDL_audio.h | 8 ++------
include/SDL3/SDL_pixels.h | 8 ++------
include/SDL3/SDL_render.h | 8 ++------
include/SDL3/SDL_video.h | 4 +---
src/audio/SDL_audio.c | 10 ++++------
src/dynapi/SDL_dynapi_procs.h | 14 +++++++-------
src/render/SDL_render.c | 9 ++++-----
src/video/SDL_pixels.c | 15 +++++++--------
src/video/SDL_video.c | 5 ++---
9 files changed, 31 insertions(+), 50 deletions(-)
diff --git a/include/SDL3/SDL_audio.h b/include/SDL3/SDL_audio.h
index 1d308e4f6984..09223a62f254 100644
--- a/include/SDL3/SDL_audio.h
+++ b/include/SDL3/SDL_audio.h
@@ -1094,14 +1094,12 @@ extern DECLSPEC int SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
* This function should be paired with a previous SDL_LockAudioDevice() call.
*
* \param dev the ID of the device to be unlocked
- * \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_LockAudioDevice
*/
-extern DECLSPEC int SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
+extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
/* @} *//* Audio lock functions */
/**
@@ -1121,14 +1119,12 @@ extern DECLSPEC int SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
* for reuse in a new SDL_OpenAudioDevice() call immediately.
*
* \param dev an audio device previously opened with SDL_OpenAudioDevice()
- * \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_OpenAudioDevice
*/
-extern DECLSPEC int SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
+extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
/**
* Convert some audio data of one format to another format.
diff --git a/include/SDL3/SDL_pixels.h b/include/SDL3/SDL_pixels.h
index ffb6217b066f..705add6fbfde 100644
--- a/include/SDL3/SDL_pixels.h
+++ b/include/SDL3/SDL_pixels.h
@@ -416,14 +416,12 @@ 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 int SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
+extern DECLSPEC void SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
/**
* Create a palette structure with the specified number of color entries.
@@ -480,14 +478,12 @@ 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 int SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
+extern DECLSPEC void 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_render.h b/include/SDL3/SDL_render.h
index 9a20f8664e88..bcefdec1688d 100644
--- a/include/SDL3/SDL_render.h
+++ b/include/SDL3/SDL_render.h
@@ -1439,15 +1439,13 @@ extern DECLSPEC int 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 int SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
+extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
/**
* Destroy the rendering context for a window and free associated textures.
@@ -1456,14 +1454,12 @@ extern DECLSPEC int 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 int SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
+extern DECLSPEC void 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 371e265c1625..b161013def3c 100644
--- a/include/SDL3/SDL_video.h
+++ b/include/SDL3/SDL_video.h
@@ -1527,15 +1527,13 @@ 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 int SDLCALL SDL_DestroyWindow(SDL_Window *window);
+extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
/**
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 1feb8e92f38d..6abba6b679db 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1553,25 +1553,23 @@ int SDL_LockAudioDevice(SDL_AudioDeviceID devid)
return 0;
}
-int SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
+void SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
{
/* Obtain a lock on the mixing buffers */
SDL_AudioDevice *device = get_audio_device(devid);
if (!device) {
- return SDL_InvalidParamError("devid");
+ return;
}
current_audio.impl.UnlockDevice(device);
- return 0;
}
-int SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
+void SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
{
SDL_AudioDevice *device = get_audio_device(devid);
if (!device) {
- return SDL_InvalidParamError("devid");
+ return;
}
close_audio_device(device);
- return 0;
}
void SDL_QuitAudio(void)
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 9cab0d0ac3de..4b6cf251faae 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -144,7 +144,7 @@ SDL_DYNAPI_PROC(void,SDL_ClearComposition,(void),(),)
SDL_DYNAPI_PROC(void,SDL_ClearError,(void),(),)
SDL_DYNAPI_PROC(void,SDL_ClearHints,(void),(),)
SDL_DYNAPI_PROC(int,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_CloseAudioDevice,(SDL_AudioDeviceID a),(a),return)
+SDL_DYNAPI_PROC(void,SDL_CloseAudioDevice,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseGamepad,(SDL_Gamepad *a),(a),)
SDL_DYNAPI_PROC(int,SDL_CloseJoystick,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_CloseSensor,(SDL_Sensor *a),(a),)
@@ -184,13 +184,13 @@ SDL_DYNAPI_PROC(Uint32,SDL_DequeueAudio,(SDL_AudioDeviceID a, void *b, Uint32 c)
SDL_DYNAPI_PROC(void,SDL_DestroyAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyCond,(SDL_cond *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyMutex,(SDL_mutex *a),(a),)
-SDL_DYNAPI_PROC(int,SDL_DestroyPalette,(SDL_Palette *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_DestroyRenderer,(SDL_Renderer *a),(a),return)
+SDL_DYNAPI_PROC(void,SDL_DestroyPalette,(SDL_Palette *a),(a),)
+SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),)
+SDL_DYNAPI_PROC(void,SDL_DestroyRenderer,(SDL_Renderer *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroySemaphore,(SDL_sem *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroySurface,(SDL_Surface *a),(a),)
-SDL_DYNAPI_PROC(int,SDL_DestroyTexture,(SDL_Texture *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_DestroyWindow,(SDL_Window *a),(a),return)
+SDL_DYNAPI_PROC(void,SDL_DestroyTexture,(SDL_Texture *a),(a),)
+SDL_DYNAPI_PROC(void,SDL_DestroyWindow,(SDL_Window *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DetachThread,(SDL_Thread *a),(a),)
SDL_DYNAPI_PROC(int,SDL_DetachVirtualJoystick,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(void,SDL_DisableScreenSaver,(void),(),)
@@ -722,7 +722,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_TextInputShown,(void),(),return)
SDL_DYNAPI_PROC(SDL_threadID,SDL_ThreadID,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_TryLockMutex,(SDL_mutex *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_UnloadObject,(void *a),(a),)
-SDL_DYNAPI_PROC(int,SDL_UnlockAudioDevice,(SDL_AudioDeviceID a),(a),return)
+SDL_DYNAPI_PROC(void,SDL_UnlockAudioDevice,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(void,SDL_UnlockJoysticks,(void),(),)
SDL_DYNAPI_PROC(int,SDL_UnlockMutex,(SDL_mutex *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_UnlockSurface,(SDL_Surface *a),(a),)
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 7f0b2d8292da..9048da9acf90 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -4089,9 +4089,9 @@ static int SDL_DestroyTextureInternal(SDL_Texture *texture, SDL_bool is_destroyi
return 0;
}
-int SDL_DestroyTexture(SDL_Texture *texture)
+void SDL_DestroyTexture(SDL_Texture *texture)
{
- return SDL_DestroyTextureInternal(texture, SDL_FALSE /* is_destroying */);
+ SDL_DestroyTextureInternal(texture, SDL_FALSE /* is_destroying */);
}
static void SDL_DiscardAllCommands(SDL_Renderer *renderer)
@@ -4116,9 +4116,9 @@ static void SDL_DiscardAllCommands(SDL_Renderer *renderer)
}
}
-int SDL_DestroyRenderer(SDL_Renderer *renderer)
+void SDL_DestroyRenderer(SDL_Renderer *renderer)
{
- CHECK_RENDERER_MAGIC(renderer, -1);
+ CHECK_RENDERER_MAGIC(renderer,);
SDL_DelEventWatch(SDL_RendererEventWatch, renderer);
@@ -4147,7 +4147,6 @@ int SDL_DestroyRenderer(SDL_Renderer *renderer)
/* Free the renderer instance */
renderer->DestroyRenderer(renderer);
- return 0;
}
int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index fd04d2d86b1d..6919af4bca29 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -623,19 +623,19 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
return 0;
}
-int SDL_DestroyPixelFormat(SDL_PixelFormat *format)
+void SDL_DestroyPixelFormat(SDL_PixelFormat *format)
{
SDL_PixelFormat *prev;
if (format == NULL) {
- return SDL_InvalidParamError("format");
+ return;
}
SDL_AtomicLock(&formats_lock);
if (--format->refcount > 0) {
SDL_AtomicUnlock(&formats_lock);
- return 0;
+ return;
}
/* Remove this format from our list */
@@ -656,7 +656,7 @@ int SDL_DestroyPixelFormat(SDL_PixelFormat *format)
SDL_DestroyPalette(format->palette);
}
SDL_free(format);
- return 0;
+ return;
}
SDL_Palette *
@@ -744,17 +744,16 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors,
return status;
}
-int SDL_DestroyPalette(SDL_Palette *palette)
+void SDL_DestroyPalette(SDL_Palette *palette)
{
if (palette == NULL) {
- return SDL_InvalidParamError("palette");
+ return;
}
if (--palette->refcount > 0) {
- return 0;
+ return;
}
SDL_free(palette->colors);
SDL_free(palette);
- return 0;
}
/*
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index bf702aab4acb..94811edb880f 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -3128,11 +3128,11 @@ SDL_Window *SDL_GetFocusWindow(void)
return NULL;
}
-int SDL_DestroyWindow(SDL_Window *window)
+void SDL_DestroyWindow(SDL_Window *window)
{
SDL_VideoDisplay *display;
- CHECK_WINDOW_MAGIC(window, -1);
+ CHECK_WINDOW_MAGIC(window,);
window->is_destroying = SDL_TRUE;
@@ -3209,7 +3209,6 @@ int SDL_DestroyWindow(SDL_Window *window)
}
SDL_free(window);
- return 0;
}
SDL_bool SDL_ScreenSaverEnabled()