mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-30 15:08:31 +00:00
Changed SDL_ClearError() to always return 0.
This will provide a quick and easy way of clearing the error when a function succeeds, if we want to do that in a more widespread way. For now we guarantee that SDL_Init() will never have an error set when it returns successfully. Fixes https://github.com/libsdl-org/SDL/issues/8421
This commit is contained in:
@@ -105,12 +105,14 @@ extern DECLSPEC const char *SDLCALL SDL_GetError(void);
|
|||||||
/**
|
/**
|
||||||
* Clear any previous error message for this thread.
|
* Clear any previous error message for this thread.
|
||||||
*
|
*
|
||||||
|
* \returns 0
|
||||||
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
* \sa SDL_GetError
|
* \sa SDL_GetError
|
||||||
* \sa SDL_SetError
|
* \sa SDL_SetError
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
extern DECLSPEC int SDLCALL SDL_ClearError(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name Internal error functions
|
* \name Internal error functions
|
||||||
|
@@ -400,7 +400,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
|
|
||||||
(void)flags_initialized; /* make static analysis happy, since this only gets used in error cases. */
|
(void)flags_initialized; /* make static analysis happy, since this only gets used in error cases. */
|
||||||
|
|
||||||
return 0;
|
return SDL_ClearError();
|
||||||
|
|
||||||
quit_and_error:
|
quit_and_error:
|
||||||
SDL_QuitSubSystem(flags_initialized);
|
SDL_QuitSubSystem(flags_initialized);
|
||||||
|
@@ -78,13 +78,14 @@ const char *SDL_GetError(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ClearError(void)
|
int SDL_ClearError(void)
|
||||||
{
|
{
|
||||||
SDL_error *error = SDL_GetErrBuf(SDL_FALSE);
|
SDL_error *error = SDL_GetErrBuf(SDL_FALSE);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
error->error = SDL_ErrorCodeNone;
|
error->error = SDL_ErrorCodeNone;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Very common errors go here */
|
/* Very common errors go here */
|
||||||
|
@@ -107,7 +107,7 @@ SDL_DYNAPI_PROC(void,SDL_CleanupTLS,(void),(),)
|
|||||||
SDL_DYNAPI_PROC(int,SDL_ClearAudioStream,(SDL_AudioStream *a),(a),return)
|
SDL_DYNAPI_PROC(int,SDL_ClearAudioStream,(SDL_AudioStream *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_ClearClipboardData,(void),(),return)
|
SDL_DYNAPI_PROC(int,SDL_ClearClipboardData,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_ClearComposition,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_ClearComposition,(void),(),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_ClearError,(void),(),)
|
SDL_DYNAPI_PROC(int,SDL_ClearError,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_ClearProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
|
SDL_DYNAPI_PROC(int,SDL_ClearProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_CloseAudioDevice,(SDL_AudioDeviceID a),(a),)
|
SDL_DYNAPI_PROC(void,SDL_CloseAudioDevice,(SDL_AudioDeviceID a),(a),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_CloseCamera,(SDL_Camera *a),(a),)
|
SDL_DYNAPI_PROC(void,SDL_CloseCamera,(SDL_Camera *a),(a),)
|
||||||
|
Reference in New Issue
Block a user