use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError

This commit is contained in:
pionere
2022-01-17 16:26:02 +01:00
committed by Ryan C. Gordon
parent 4a17612bff
commit ebdd536676
36 changed files with 109 additions and 123 deletions

View File

@@ -70,8 +70,7 @@ int
SDL_CondSignal(SDL_cond * cond)
{
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
return SDL_InvalidParamError("cond");
}
cond->cpp_cond.notify_one();
@@ -84,8 +83,7 @@ int
SDL_CondBroadcast(SDL_cond * cond)
{
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
return SDL_InvalidParamError("cond");
}
cond->cpp_cond.notify_all();
@@ -118,13 +116,11 @@ int
SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
{
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
return SDL_InvalidParamError("cond");
}
if (!mutex) {
SDL_SetError("Passed a NULL mutex variable");
return -1;
return SDL_InvalidParamError("mutex");
}
try {
@@ -148,8 +144,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
}
}
} catch (std::system_error & ex) {
SDL_SetError("unable to wait on a C++ condition variable: code=%d; %s", ex.code(), ex.what());
return -1;
return SDL_SetError("unable to wait on a C++ condition variable: code=%d; %s", ex.code(), ex.what());
}
}

View File

@@ -65,16 +65,14 @@ int
SDL_mutexP(SDL_mutex * mutex)
{
if (mutex == NULL) {
SDL_SetError("Passed a NULL mutex");
return -1;
return SDL_InvalidParamError("mutex");
}
try {
mutex->cpp_mutex.lock();
return 0;
} catch (std::system_error & ex) {
SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what());
return -1;
return SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what());
}
}
@@ -84,7 +82,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
{
int retval = 0;
if (mutex == NULL) {
return SDL_SetError("Passed a NULL mutex");
return SDL_InvalidParamError("mutex");
}
if (mutex->cpp_mutex.try_lock() == false) {
@@ -99,8 +97,7 @@ int
SDL_mutexV(SDL_mutex * mutex)
{
if (mutex == NULL) {
SDL_SetError("Passed a NULL mutex");
return -1;
return SDL_InvalidParamError("mutex");
}
mutex->cpp_mutex.unlock();