Cleanup add brace (#6545)

* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line

(cherry picked from commit 6a2200823c to reduce conflicts merging between SDL2 and SDL3)
This commit is contained in:
Sylvain Becker
2022-11-27 17:38:43 +01:00
committed by Sam Lantinga
parent 0739d237ad
commit fb0ce375f0
386 changed files with 6103 additions and 4637 deletions

View File

@@ -42,7 +42,7 @@ SDL_TLSGet(SDL_TLSID id)
SDL_TLSData *storage;
storage = SDL_SYS_GetTLSData();
if (!storage || id == 0 || id > storage->limit) {
if (storage == NULL || id == 0 || id > storage->limit) {
return NULL;
}
return storage->array[id-1].data;
@@ -58,13 +58,13 @@ SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *))
}
storage = SDL_SYS_GetTLSData();
if (!storage || (id > storage->limit)) {
if (storage == NULL || (id > storage->limit)) {
unsigned int i, oldlimit, newlimit;
oldlimit = storage ? storage->limit : 0;
newlimit = (id + TLS_ALLOC_CHUNKSIZE);
storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage)+(newlimit-1)*sizeof(storage->array[0]));
if (!storage) {
if (storage == NULL) {
return SDL_OutOfMemory();
}
storage->limit = newlimit;
@@ -127,14 +127,14 @@ SDL_Generic_GetTLSData(void)
SDL_TLSData *storage = NULL;
#if !SDL_THREADS_DISABLED
if (!SDL_generic_TLS_mutex) {
if (SDL_generic_TLS_mutex == NULL) {
static SDL_SpinLock tls_lock;
SDL_AtomicLock(&tls_lock);
if (!SDL_generic_TLS_mutex) {
if (SDL_generic_TLS_mutex == NULL) {
SDL_mutex *mutex = SDL_CreateMutex();
SDL_MemoryBarrierRelease();
SDL_generic_TLS_mutex = mutex;
if (!SDL_generic_TLS_mutex) {
if (SDL_generic_TLS_mutex == NULL) {
SDL_AtomicUnlock(&tls_lock);
return NULL;
}
@@ -183,7 +183,7 @@ SDL_Generic_SetTLSData(SDL_TLSData *storage)
}
prev = entry;
}
if (!entry) {
if (entry == NULL) {
entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry));
if (entry) {
entry->thread = thread;
@@ -194,7 +194,7 @@ SDL_Generic_SetTLSData(SDL_TLSData *storage)
}
SDL_UnlockMutex(SDL_generic_TLS_mutex);
if (!entry) {
if (entry == NULL) {
return SDL_OutOfMemory();
}
return 0;
@@ -262,7 +262,7 @@ SDL_GetErrBuf(void)
if (errbuf == ALLOCATION_IN_PROGRESS) {
return SDL_GetStaticErrBuf();
}
if (!errbuf) {
if (errbuf == NULL) {
/* Get the original memory functions for this allocation because the lifetime
* of the error buffer may span calls to SDL_SetMemoryFunctions() by the app
*/
@@ -273,7 +273,7 @@ SDL_GetErrBuf(void)
/* Mark that we're in the middle of allocating our buffer */
SDL_TLSSet(tls_errbuf, ALLOCATION_IN_PROGRESS, NULL);
errbuf = (SDL_error *)realloc_func(NULL, sizeof(*errbuf));
if (!errbuf) {
if (errbuf == NULL) {
SDL_TLSSet(tls_errbuf, NULL, NULL);
return SDL_GetStaticErrBuf();
}
@@ -474,7 +474,7 @@ SDL_WaitThread(SDL_Thread * thread, int *status)
void
SDL_DetachThread(SDL_Thread * thread)
{
if (!thread) {
if (thread == NULL) {
return;
}

View File

@@ -98,7 +98,7 @@ int
SDL_CondSignal_generic(SDL_cond * _cond)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -123,7 +123,7 @@ int
SDL_CondBroadcast_generic(SDL_cond * _cond)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -180,7 +180,7 @@ SDL_CondWaitTimeout_generic(SDL_cond * _cond, SDL_mutex * mutex, Uint32 ms)
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
int retval;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}

View File

@@ -87,7 +87,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *sem;
sem = (SDL_sem *) SDL_malloc(sizeof(*sem));
if (!sem) {
if (sem == NULL) {
SDL_OutOfMemory();
return NULL;
}
@@ -131,7 +131,7 @@ SDL_SemTryWait(SDL_sem * sem)
{
int retval;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -151,7 +151,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
{
int retval;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -199,7 +199,7 @@ SDL_SemValue(SDL_sem * sem)
int
SDL_SemPost(SDL_sem * sem)
{
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}

View File

@@ -47,13 +47,13 @@ SDL_SYS_SetupThread(const char *name)
SDL_threadID
SDL_ThreadID(void)
{
return (0);
return 0;
}
int
SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
return (0);
return 0;
}
void

View File

@@ -57,8 +57,8 @@ SDL_DestroyCond(SDL_cond *cond)
int
SDL_CondSignal(SDL_cond *cond)
{
if (!cond) {
return SDL_SetError("Passed a NULL condition variable");
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
CondVar_Signal(&cond->cond_variable);
@@ -69,8 +69,8 @@ SDL_CondSignal(SDL_cond *cond)
int
SDL_CondBroadcast(SDL_cond *cond)
{
if (!cond) {
return SDL_SetError("Passed a NULL condition variable");
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
CondVar_Broadcast(&cond->cond_variable);
@@ -103,11 +103,11 @@ SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
{
Result res;
if (!cond) {
return SDL_SetError("Passed a NULL condition variable");
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
if (!mutex) {
return SDL_SetError("Passed a NULL mutex");
if (mutex == NULL) {
return SDL_InvalidParamError("mutex");
}
res = 0;

View File

@@ -44,7 +44,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
}
sem = (SDL_sem *) SDL_malloc(sizeof(*sem));
if (!sem) {
if (sem == NULL) {
SDL_OutOfMemory();
return NULL;
}
@@ -68,8 +68,8 @@ SDL_DestroySemaphore(SDL_sem *sem)
int
SDL_SemTryWait(SDL_sem *sem)
{
if (!sem) {
return SDL_SetError("Passed a NULL semaphore");
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
return SDL_SemWaitTimeout(sem, 0);
@@ -80,8 +80,8 @@ SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
{
int retval;
if (!sem) {
return SDL_SetError("Passed a NULL semaphore");
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
if (timeout == SDL_MUTEX_MAXWAIT) {
@@ -113,8 +113,8 @@ SDL_SemWait(SDL_sem *sem)
Uint32
SDL_SemValue(SDL_sem *sem)
{
if (!sem) {
return SDL_SetError("Passed a NULL semaphore");
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
return sem->semaphore.current_count;
}
@@ -122,8 +122,8 @@ SDL_SemValue(SDL_sem *sem)
int
SDL_SemPost(SDL_sem *sem)
{
if (!sem) {
return SDL_SetError("Passed a NULL semaphore");
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
LightSemaphore_Release(&sem->semaphore, 1);
return 0;

View File

@@ -36,7 +36,7 @@ extern TInt CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny*,
static TInt NewMutex(const TDesC& aName, TAny* aPtr1, TAny*)
{
return ((RMutex*)aPtr1)->CreateGlobal(aName);
return ((RMutex *)aPtr1)->CreateGlobal(aName);
}
/* Create a mutex */
@@ -46,21 +46,19 @@ SDL_CreateMutex(void)
RMutex rmutex;
TInt status = CreateUnique(NewMutex, &rmutex, NULL);
if(status != KErrNone)
{
if (status != KErrNone) {
SDL_SetError("Couldn't create mutex.");
}
SDL_mutex* mutex = new /*(ELeave)*/ SDL_mutex;
mutex->handle = rmutex.Handle();
return(mutex);
return mutex;
}
/* Free the mutex */
void
SDL_DestroyMutex(SDL_mutex * mutex)
{
if (mutex)
{
if (mutex) {
RMutex rmutex;
rmutex.SetHandle(mutex->handle);
rmutex.Signal();
@@ -90,32 +88,30 @@ SDL_TryLockMutex(SDL_mutex * mutex)
int
SDL_LockMutex(SDL_mutex * mutex)
{
if (mutex == NULL)
{
return SDL_SetError("Passed a NULL mutex.");
if (mutex == NULL) {
return SDL_InvalidParamError("mutex");
}
RMutex rmutex;
rmutex.SetHandle(mutex->handle);
rmutex.Wait();
return(0);
return 0;
}
/* Unlock the mutex */
int
SDL_UnlockMutex(SDL_mutex * mutex)
{
if ( mutex == NULL )
{
return SDL_SetError("Passed a NULL mutex.");
if (mutex == NULL) {
return SDL_InvalidParamError("mutex");
}
RMutex rmutex;
rmutex.SetHandle(mutex->handle);
rmutex.Signal();
return(0);
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -60,18 +60,13 @@ static TBool RunThread(TAny* aInfo)
static TInt
NewThread(const TDesC& aName, TAny* aPtr1, TAny* aPtr2)
{
return ((RThread*)(aPtr1))->Create
(aName,
RunThread,
KDefaultStackSize,
NULL,
aPtr2);
return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2);
}
static TInt NewSema(const TDesC& aName, TAny* aPtr1, TAny* aPtr2)
{
TInt value = *((TInt*) aPtr2);
return ((RSemaphore*)aPtr1)->CreateGlobal(aName, value);
return ((RSemaphore *)aPtr1)->CreateGlobal(aName, value);
}
static void WaitAll(SDL_sem *sem)
@@ -79,8 +74,7 @@ static void WaitAll(SDL_sem *sem)
RSemaphore sema;
sema.SetHandle(sem->handle);
sema.Wait();
while(sem->count < 0)
{
while(sem->count < 0) {
sema.Wait();
}
}
@@ -90,21 +84,19 @@ SDL_CreateSemaphore(Uint32 initial_value)
{
RSemaphore s;
TInt status = CreateUnique(NewSema, &s, &initial_value);
if(status != KErrNone)
{
if (status != KErrNone) {
SDL_SetError("Couldn't create semaphore");
}
SDL_semaphore* sem = new /*(ELeave)*/ SDL_semaphore;
sem->handle = s.Handle();
sem->count = initial_value;
return(sem);
return sem;
}
void
SDL_DestroySemaphore(SDL_sem * sem)
{
if (sem)
{
if (sem) {
RSemaphore sema;
sema.SetHandle(sem->handle);
sema.Signal(sema.Count());
@@ -117,13 +109,11 @@ SDL_DestroySemaphore(SDL_sem * sem)
int
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
{
if (! sem)
{
return SDL_SetError("Passed a NULL sem");
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
if (timeout == SDL_MUTEX_MAXWAIT)
{
if (timeout == SDL_MUTEX_MAXWAIT) {
WaitAll(sem);
return SDL_MUTEX_MAXWAIT;
}
@@ -132,16 +122,14 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
TInfo* info = new (ELeave)TInfo(timeout, sem->handle);
TInt status = CreateUnique(NewThread, &thread, info);
if(status != KErrNone)
{
if (status != KErrNone) {
return status;
}
thread.Resume();
WaitAll(sem);
if(thread.ExitType() == EExitPending)
{
if (thread.ExitType() == EExitPending) {
thread.Kill(SDL_MUTEX_TIMEOUT);
}
@@ -152,8 +140,11 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
int
SDL_SemTryWait(SDL_sem *sem)
{
if(sem->count > 0)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
if (sem->count > 0) {
sem->count--;
}
return SDL_MUTEX_TIMEOUT;
@@ -168,9 +159,8 @@ SDL_SemWait(SDL_sem * sem)
Uint32
SDL_SemValue(SDL_sem * sem)
{
if (! sem)
{
SDL_SetError("Passed a NULL sem.");
if (sem == NULL) {
SDL_InvalidParamError("sem");
return 0;
}
return sem->count;
@@ -179,9 +169,8 @@ SDL_SemValue(SDL_sem * sem)
int
SDL_SemPost(SDL_sem * sem)
{
if (! sem)
{
return SDL_SetError("Passed a NULL sem.");
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
sem->count++;
RSemaphore sema;

View File

@@ -40,18 +40,13 @@ static int
RunThread(TAny* data)
{
SDL_RunThread((SDL_Thread*)data);
return(0);
return 0;
}
static TInt
NewThread(const TDesC& aName, TAny* aPtr1, TAny* aPtr2)
{
return ((RThread*)(aPtr1))->Create
(aName,
RunThread,
KDefaultStackSize,
NULL,
aPtr2);
return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2);
}
int
@@ -75,17 +70,16 @@ SDL_SYS_CreateThread(SDL_Thread *thread)
RThread rthread;
TInt status = CreateUnique(NewThread, &rthread, thread);
if (status != KErrNone)
{
if (status != KErrNone) {
delete(((RThread*)(thread->handle)));
thread->handle = NULL;
SDL_SetError("Not enough resources to create thread");
return(-1);
return -1;
}
rthread.Resume();
thread->handle = rthread.Handle();
return(0);
return 0;
}
void
@@ -105,7 +99,7 @@ SDL_ThreadID(void)
int
SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
return (0);
return 0;
}
void
@@ -113,8 +107,7 @@ SDL_SYS_WaitThread(SDL_Thread * thread)
{
RThread t;
t.Open(thread->threadid);
if(t.ExitReason() == EExitPending)
{
if (t.ExitReason() == EExitPending) {
TRequestStatus status;
t.Logon(status);
User::WaitForRequest(status);

View File

@@ -105,8 +105,9 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
ret = WaitSema(sem->semid);
StopTimerAlarm(&alarm);
if (ret < 0)
if (ret < 0) {
return SDL_MUTEX_TIMEDOUT;
}
return 0; //Wait condition satisfied.
}

View File

@@ -58,7 +58,7 @@ SDL_CreateCond(void)
} else {
SDL_OutOfMemory();
}
return (cond);
return cond;
}
/* Destroy a condition variable */
@@ -83,7 +83,7 @@ SDL_DestroyCond(SDL_cond * cond)
int
SDL_CondSignal(SDL_cond * cond)
{
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -107,7 +107,7 @@ SDL_CondSignal(SDL_cond * cond)
int
SDL_CondBroadcast(SDL_cond * cond)
{
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -163,7 +163,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
{
int retval;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}

View File

@@ -48,7 +48,7 @@ SDL_CreateCond(void)
cond = NULL;
}
}
return (cond);
return cond;
}
/* Destroy a condition variable */
@@ -67,7 +67,7 @@ SDL_CondSignal(SDL_cond * cond)
{
int retval;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -84,7 +84,7 @@ SDL_CondBroadcast(SDL_cond * cond)
{
int retval;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -104,7 +104,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
#endif
struct timespec abstime;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -147,7 +147,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
int
SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
{
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
} else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
return SDL_SetError("pthread_cond_wait() failed");

View File

@@ -64,7 +64,7 @@ SDL_CreateMutex(void)
} else {
SDL_OutOfMemory();
}
return (mutex);
return mutex;
}
void

View File

@@ -72,7 +72,7 @@ SDL_SemTryWait(SDL_sem * sem)
{
int retval;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
retval = SDL_MUTEX_TIMEDOUT;
@@ -87,7 +87,7 @@ SDL_SemWait(SDL_sem * sem)
{
int retval;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -114,7 +114,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
Uint32 end;
#endif
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -194,7 +194,7 @@ SDL_SemPost(SDL_sem * sem)
{
int retval;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}

View File

@@ -187,7 +187,7 @@ SDL_SYS_SetupThread(const char *name)
SDL_threadID
SDL_ThreadID(void)
{
return ((SDL_threadID) pthread_self());
return (SDL_threadID)pthread_self();
}
int

View File

@@ -69,7 +69,7 @@ extern "C"
int
SDL_CondSignal(SDL_cond * cond)
{
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -82,7 +82,7 @@ extern "C"
int
SDL_CondBroadcast(SDL_cond * cond)
{
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -132,7 +132,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
cpp_lock.release();
return 0;
} else {
auto wait_result = cond->cpp_cond.wait_for(
auto wait_result = cond->cpp_cond.wait_for (
cpp_lock,
std::chrono::duration<Uint32, std::milli>(ms)
);

View File

@@ -98,16 +98,13 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
if (priority == SDL_THREAD_PRIORITY_LOW) {
value = THREAD_PRIORITY_LOWEST;
}
else if (priority == SDL_THREAD_PRIORITY_HIGH) {
} else if (priority == SDL_THREAD_PRIORITY_HIGH) {
value = THREAD_PRIORITY_HIGHEST;
}
else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
} else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
// FIXME: WinRT does not support TIME_CRITICAL! -flibit
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "TIME_CRITICAL unsupported, falling back to HIGHEST");
value = THREAD_PRIORITY_HIGHEST;
}
else {
} else {
value = THREAD_PRIORITY_NORMAL;
}
if (!SetThreadPriority(GetCurrentThread(), value)) {

View File

@@ -58,7 +58,7 @@ SDL_CreateCond(void)
} else {
SDL_OutOfMemory();
}
return (cond);
return cond;
}
/* Destroy a condition variable */
@@ -83,7 +83,7 @@ SDL_DestroyCond(SDL_cond * cond)
int
SDL_CondSignal(SDL_cond * cond)
{
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -107,7 +107,7 @@ SDL_CondSignal(SDL_cond * cond)
int
SDL_CondBroadcast(SDL_cond * cond)
{
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -163,7 +163,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
{
int retval;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}

View File

@@ -88,7 +88,7 @@ SDL_CreateCond_cv(void)
/* Relies on CONDITION_VARIABLE_INIT == 0. */
cond = (SDL_cond_cv *) SDL_calloc(1, sizeof(*cond));
if (!cond) {
if (cond == NULL) {
SDL_OutOfMemory();
}
@@ -108,7 +108,7 @@ static int
SDL_CondSignal_cv(SDL_cond * _cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -121,7 +121,7 @@ static int
SDL_CondBroadcast_cv(SDL_cond * _cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
@@ -137,10 +137,10 @@ SDL_CondWaitTimeout_cv(SDL_cond * _cond, SDL_mutex * _mutex, Uint32 ms)
DWORD timeout;
int ret;
if (!cond) {
if (cond == NULL) {
return SDL_InvalidParamError("cond");
}
if (!_mutex) {
if (_mutex == NULL) {
return SDL_InvalidParamError("mutex");
}
@@ -234,7 +234,7 @@ SDL_CreateCond(void)
if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) {
/* The mutex implementation isn't decided yet, trigger it */
SDL_mutex *mutex = SDL_CreateMutex();
if (!mutex) {
if (mutex == NULL) {
return NULL;
}
SDL_DestroyMutex(mutex);

View File

@@ -65,7 +65,7 @@ SDL_CreateMutex_srw(void)
/* Relies on SRWLOCK_INIT == 0. */
mutex = (SDL_mutex_srw *) SDL_calloc(1, sizeof(*mutex));
if (!mutex) {
if (mutex == NULL) {
SDL_OutOfMemory();
}

View File

@@ -121,7 +121,7 @@ SDL_SemTryWait_atom(SDL_sem * _sem)
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
LONG count;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -143,7 +143,7 @@ SDL_SemWait_atom(SDL_sem * _sem)
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
LONG count;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -175,7 +175,7 @@ SDL_SemWaitTimeout_atom(SDL_sem * _sem, Uint32 timeout)
return SDL_SemWait_atom(_sem);
}
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -218,7 +218,7 @@ SDL_SemValue_atom(SDL_sem * _sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
if (!sem) {
if (sem == NULL) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -231,7 +231,7 @@ SDL_SemPost_atom(SDL_sem * _sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -312,7 +312,7 @@ SDL_SemWaitTimeout_kern(SDL_sem * _sem, Uint32 timeout)
int retval;
DWORD dwMilliseconds;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
@@ -353,7 +353,7 @@ static Uint32
SDL_SemValue_kern(SDL_sem * _sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (!sem) {
if (sem == NULL) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -364,7 +364,7 @@ static int
SDL_SemPost_kern(SDL_sem * _sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (!sem) {
if (sem == NULL) {
return SDL_InvalidParamError("sem");
}
/* Increase the counter in the first place, because
@@ -421,7 +421,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
pWaitOnAddress = (pfnWaitOnAddress) GetProcAddress(synch120, "WaitOnAddress");
pWakeByAddressSingle = (pfnWakeByAddressSingle) GetProcAddress(synch120, "WakeByAddressSingle");
if(pWaitOnAddress && pWakeByAddressSingle) {
if (pWaitOnAddress && pWakeByAddressSingle) {
impl = &SDL_sem_impl_atom;
}
}

View File

@@ -95,7 +95,7 @@ RunThreadViaCreateThread(LPVOID data)
static unsigned __stdcall
RunThreadViaBeginThreadEx(void *data)
{
return (unsigned) RunThread(data);
return (unsigned)RunThread(data);
}
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
@@ -206,7 +206,7 @@ SDL_SYS_SetupThread(const char *name)
SDL_threadID
SDL_ThreadID(void)
{
return ((SDL_threadID) GetCurrentThreadId());
return (SDL_threadID)GetCurrentThreadId();
}
int