Make SDL_SetError and friends unconditionally return -1.

This lets us change things like this...

    if (Failed) {
        SDL_SetError("We failed");
        return -1;
    }

...into this...

    if (Failed) {
        return SDL_SetError("We failed");
    }


 Fixes Bugzilla #1778.
This commit is contained in:
Ryan C. Gordon 2013-03-31 12:48:50 -04:00
parent 8c6b9f4743
commit 4f438b70a2
106 changed files with 616 additions and 1189 deletions

View file

@ -67,14 +67,12 @@ SDL_CondSignal(SDL_cond * cond)
int retval;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
return SDL_SetError("Passed a NULL condition variable");
}
retval = 0;
if (pthread_cond_signal(&cond->cond) != 0) {
SDL_SetError("pthread_cond_signal() failed");
retval = -1;
return SDL_SetError("pthread_cond_signal() failed");
}
return retval;
}
@ -86,14 +84,12 @@ SDL_CondBroadcast(SDL_cond * cond)
int retval;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
return SDL_SetError("Passed a NULL condition variable");
}
retval = 0;
if (pthread_cond_broadcast(&cond->cond) != 0) {
SDL_SetError("pthread_cond_broadcast() failed");
retval = -1;
return SDL_SetError("pthread_cond_broadcast() failed");
}
return retval;
}
@ -106,8 +102,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
struct timespec abstime;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
return SDL_SetError("Passed a NULL condition variable");
}
gettimeofday(&delta, NULL);
@ -131,9 +126,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
case 0:
break;
default:
SDL_SetError("pthread_cond_timedwait() failed");
retval = -1;
break;
retval = SDL_SetError("pthread_cond_timedwait() failed");
}
return retval;
}
@ -144,19 +137,12 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
int
SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
{
int retval;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
return SDL_SetError("Passed a NULL condition variable");
} else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
return SDL_SetError("pthread_cond_wait() failed");
}
retval = 0;
if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
SDL_SetError("pthread_cond_wait() failed");
retval = -1;
}
return retval;
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */