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:
parent
8c6b9f4743
commit
4f438b70a2
106 changed files with 616 additions and 1189 deletions
|
@ -97,18 +97,16 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
|
||||
/* Set the thread attributes */
|
||||
if (pthread_attr_init(&type) != 0) {
|
||||
SDL_SetError("Couldn't initialize pthread attributes");
|
||||
return (-1);
|
||||
return SDL_SetError("Couldn't initialize pthread attributes");
|
||||
}
|
||||
pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
/* Create the thread and go! */
|
||||
if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
|
||||
SDL_SetError("Not enough resources to create thread");
|
||||
return (-1);
|
||||
return SDL_SetError("Not enough resources to create thread");
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -173,8 +171,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|||
/* Note that this fails if you're trying to set high priority
|
||||
and you don't have root permission. BUT DON'T RUN AS ROOT!
|
||||
*/
|
||||
SDL_SetError("setpriority() failed");
|
||||
return -1;
|
||||
return SDL_SetError("setpriority() failed");
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
|
@ -183,8 +180,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|||
pthread_t thread = pthread_self();
|
||||
|
||||
if (pthread_getschedparam(thread, &policy, &sched) < 0) {
|
||||
SDL_SetError("pthread_getschedparam() failed");
|
||||
return -1;
|
||||
return SDL_SetError("pthread_getschedparam() failed");
|
||||
}
|
||||
if (priority == SDL_THREAD_PRIORITY_LOW) {
|
||||
sched.sched_priority = sched_get_priority_min(policy);
|
||||
|
@ -196,8 +192,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|||
sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
|
||||
}
|
||||
if (pthread_setschedparam(thread, policy, &sched) < 0) {
|
||||
SDL_SetError("pthread_setschedparam() failed");
|
||||
return -1;
|
||||
return SDL_SetError("pthread_setschedparam() failed");
|
||||
}
|
||||
return 0;
|
||||
#endif /* linux */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue