[SDL2] pointer boolean (#8523)

This commit is contained in:
Sylvain Becker
2023-11-10 15:30:56 +01:00
committed by GitHub
parent 4a3a9f3ad8
commit a14b948b6c
394 changed files with 2564 additions and 2559 deletions

View File

@@ -39,7 +39,7 @@ void *SDL_TLSGet(SDL_TLSID id)
SDL_TLSData *storage;
storage = SDL_SYS_GetTLSData();
if (storage == NULL || id == 0 || id > storage->limit) {
if (!storage || id == 0 || id > storage->limit) {
return NULL;
}
return storage->array[id - 1].data;
@@ -54,13 +54,13 @@ int SDL_TLSSet(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void *
}
storage = SDL_SYS_GetTLSData();
if (storage == NULL || (id > storage->limit)) {
if (!storage || (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 == NULL) {
if (!storage) {
return SDL_OutOfMemory();
}
storage->limit = newlimit;
@@ -120,14 +120,14 @@ SDL_TLSData *SDL_Generic_GetTLSData(void)
SDL_TLSData *storage = NULL;
#if !SDL_THREADS_DISABLED
if (SDL_generic_TLS_mutex == NULL) {
if (!SDL_generic_TLS_mutex) {
static SDL_SpinLock tls_lock;
SDL_AtomicLock(&tls_lock);
if (SDL_generic_TLS_mutex == NULL) {
if (!SDL_generic_TLS_mutex) {
SDL_mutex *mutex = SDL_CreateMutex();
SDL_MemoryBarrierRelease();
SDL_generic_TLS_mutex = mutex;
if (SDL_generic_TLS_mutex == NULL) {
if (!SDL_generic_TLS_mutex) {
SDL_AtomicUnlock(&tls_lock);
return NULL;
}
@@ -161,10 +161,10 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data)
prev = NULL;
for (entry = SDL_generic_TLS; entry; entry = entry->next) {
if (entry->thread == thread) {
if (data != NULL) {
if (data) {
entry->storage = data;
} else {
if (prev != NULL) {
if (prev) {
prev->next = entry->next;
} else {
SDL_generic_TLS = entry->next;
@@ -175,7 +175,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data)
}
prev = entry;
}
if (entry == NULL) {
if (!entry) {
entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry));
if (entry) {
entry->thread = thread;
@@ -186,7 +186,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data)
}
SDL_UnlockMutex(SDL_generic_TLS_mutex);
if (entry == NULL) {
if (!entry) {
return SDL_OutOfMemory();
}
return 0;
@@ -251,7 +251,7 @@ SDL_error *SDL_GetErrBuf(void)
if (errbuf == ALLOCATION_IN_PROGRESS) {
return SDL_GetStaticErrBuf();
}
if (errbuf == NULL) {
if (!errbuf) {
/* Get the original memory functions for this allocation because the lifetime
* of the error buffer may span calls to SDL_SetMemoryFunctions() by the app
*/
@@ -262,7 +262,7 @@ SDL_error *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 == NULL) {
if (!errbuf) {
SDL_TLSSet(tls_errbuf, NULL, NULL);
return SDL_GetStaticErrBuf();
}
@@ -330,7 +330,7 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
/* Allocate memory for the thread info structure */
thread = (SDL_Thread *)SDL_calloc(1, sizeof(*thread));
if (thread == NULL) {
if (!thread) {
SDL_OutOfMemory();
return NULL;
}
@@ -338,9 +338,9 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
SDL_AtomicSet(&thread->state, SDL_THREAD_STATE_ALIVE);
/* Set up the arguments for the thread */
if (name != NULL) {
if (name) {
thread->name = SDL_strdup(name);
if (thread->name == NULL) {
if (!thread->name) {
SDL_OutOfMemory();
SDL_free(thread);
return NULL;
@@ -383,7 +383,7 @@ DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int(SDLCALL *fn)(void *),
size_t stacksize = 0;
/* If the SDL_HINT_THREAD_STACK_SIZE exists, use it */
if (stackhint != NULL) {
if (stackhint) {
char *endp = NULL;
const Sint64 hintval = SDL_strtoll(stackhint, &endp, 10);
if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */
@@ -452,7 +452,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status)
void SDL_DetachThread(SDL_Thread *thread)
{
if (thread == NULL) {
if (!thread) {
return;
}

View File

@@ -95,7 +95,7 @@ void SDL_DestroyCond_generic(SDL_cond *_cond)
int SDL_CondSignal_generic(SDL_cond *_cond)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -119,7 +119,7 @@ int SDL_CondSignal_generic(SDL_cond *_cond)
int SDL_CondBroadcast_generic(SDL_cond *_cond)
{
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -175,7 +175,7 @@ int SDL_CondWaitTimeout_generic(SDL_cond *_cond, SDL_mutex *mutex, Uint32 ms)
SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
int retval;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}

View File

@@ -107,7 +107,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
int retval = 0;
SDL_threadID this_thread;
if (mutex == NULL) {
if (!mutex) {
return 0;
}

View File

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

View File

@@ -54,7 +54,7 @@ void SDL_DestroyCond(SDL_cond *cond)
/* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -65,7 +65,7 @@ int SDL_CondSignal(SDL_cond *cond)
/* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -98,10 +98,10 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
{
Result res;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
if (mutex == NULL) {
if (!mutex) {
return SDL_InvalidParamError("mutex");
}

View File

@@ -64,7 +64,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
/* try Lock the mutex */
int SDL_TryLockMutex(SDL_mutex *mutex)
{
if (mutex == NULL) {
if (!mutex) {
return 0;
}

View File

@@ -46,7 +46,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
}
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if (sem == NULL) {
if (!sem) {
SDL_OutOfMemory();
return NULL;
}
@@ -66,7 +66,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
int SDL_SemTryWait(SDL_sem *sem)
{
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -81,7 +81,7 @@ int SDL_SemTryWait(SDL_sem *sem)
int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
{
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -122,7 +122,7 @@ int SDL_SemWait(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
{
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -131,7 +131,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
int SDL_SemPost(SDL_sem *sem)
{
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
LightSemaphore_Release(&sem->semaphore, 1);

View File

@@ -66,7 +66,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
cpu,
false);
if (thread->handle == NULL) {
if (!thread->handle) {
return SDL_SetError("Couldn't create thread");
}

View File

@@ -92,7 +92,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
void SDL_DestroySemaphore(SDL_sem *sem)
{
if (sem != NULL) {
if (sem) {
RSemaphore sema;
sema.SetHandle(sem->handle);
sema.Signal(sema.Count());
@@ -104,7 +104,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
{
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -134,7 +134,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
int SDL_SemTryWait(SDL_sem *sem)
{
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -151,7 +151,7 @@ int SDL_SemWait(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
{
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -160,7 +160,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
int SDL_SemPost(SDL_sem *sem)
{
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
sem->count++;

View File

@@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
ULONG ulRC;
SDL_sem *pSDLSem = SDL_malloc(sizeof(SDL_sem));
if (pSDLSem == NULL) {
if (!pSDLSem) {
SDL_OutOfMemory();
return NULL;
}
@@ -85,7 +85,7 @@ int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
ULONG ulTimeout;
ULONG cPost;
if (sem == NULL)
if (!sem)
return SDL_InvalidParamError("sem");
if (timeout != SEM_INDEFINITE_WAIT)
@@ -140,7 +140,7 @@ Uint32 SDL_SemValue(SDL_sem * sem)
{
ULONG ulRC;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -159,7 +159,7 @@ int SDL_SemPost(SDL_sem * sem)
{
ULONG ulRC;
if (sem == NULL)
if (!sem)
return SDL_InvalidParamError("sem");
ulRC = DosRequestMutexSem(sem->hMtx, SEM_INDEFINITE_WAIT);

View File

@@ -45,7 +45,7 @@ static void RunThread(void *data)
SDL_Thread *thread = (SDL_Thread *) data;
pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread) thread->endfunc;
if (ppSDLTLSData != NULL)
if (ppSDLTLSData)
*ppSDLTLSData = NULL;
SDL_RunThread(thread);

View File

@@ -41,7 +41,7 @@ void SDL_OS2TLSAlloc(void)
{
ULONG ulRC;
if (cTLSAlloc == 0 || ppSDLTLSData == NULL) {
if (cTLSAlloc == 0 || !ppSDLTLSData) {
/* First call - allocate the thread local memory (1 DWORD) */
ulRC = DosAllocThreadLocalMemory(1, (PULONG *)&ppSDLTLSData);
if (ulRC != NO_ERROR) {
@@ -59,7 +59,7 @@ void SDL_OS2TLSFree(void)
if (cTLSAlloc != 0)
cTLSAlloc--;
if (cTLSAlloc == 0 && ppSDLTLSData != NULL) {
if (cTLSAlloc == 0 && ppSDLTLSData) {
/* Last call - free the thread local memory */
ulRC = DosFreeThreadLocalMemory((PULONG)ppSDLTLSData);
if (ulRC != NO_ERROR) {
@@ -72,7 +72,7 @@ void SDL_OS2TLSFree(void)
SDL_TLSData *SDL_SYS_GetTLSData(void)
{
return (ppSDLTLSData == NULL)? NULL : *ppSDLTLSData;
return (!ppSDLTLSData)? NULL : *ppSDLTLSData;
}
int SDL_SYS_SetTLSData(SDL_TLSData *data)

View File

@@ -50,7 +50,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
ee_sema_t sema;
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
if (sem) {
/* TODO: Figure out the limit on the maximum value. */
sema.init_count = initial_value;
sema.max_count = 255;
@@ -72,7 +72,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
/* Free the semaphore */
void SDL_DestroySemaphore(SDL_sem *sem)
{
if (sem != NULL) {
if (sem) {
if (sem->semid > 0) {
DeleteSema(sem->semid);
sem->semid = 0;
@@ -88,7 +88,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
struct timer_alarm_t alarm;
InitializeTimerAlarm(&alarm);
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -127,7 +127,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
{
ee_sema_t info;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -143,7 +143,7 @@ int SDL_SemPost(SDL_sem *sem)
{
int res;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}

View File

@@ -80,7 +80,7 @@ void SDL_DestroyCond(SDL_cond *cond)
/* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -103,7 +103,7 @@ int SDL_CondSignal(SDL_cond *cond)
/* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -158,7 +158,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
{
int retval;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}

View File

@@ -101,7 +101,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
#else
SceInt32 res = 0;
if (mutex == NULL) {
if (!mutex) {
return 0;
}

View File

@@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *sem;
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
if (sem) {
/* TODO: Figure out the limit on the maximum value. */
sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL);
if (sem->semid < 0) {
@@ -62,7 +62,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
/* Free the semaphore */
void SDL_DestroySemaphore(SDL_sem *sem)
{
if (sem != NULL) {
if (sem) {
if (sem->semid > 0) {
sceKernelDeleteSema(sem->semid);
sem->semid = 0;
@@ -81,7 +81,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
Uint32 *pTimeout;
int res;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -126,7 +126,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
{
SceKernelSemaInfo info;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -142,7 +142,7 @@ int SDL_SemPost(SDL_sem *sem)
{
int res;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}

View File

@@ -64,7 +64,7 @@ int SDL_CondSignal(SDL_cond *cond)
{
int retval;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -80,7 +80,7 @@ int SDL_CondBroadcast(SDL_cond *cond)
{
int retval;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -99,7 +99,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
#endif
struct timespec abstime;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -141,7 +141,7 @@ tryagain:
*/
int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
} else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
return SDL_SetError("pthread_cond_wait() failed");

View File

@@ -117,7 +117,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
pthread_t this_thread;
#endif
if (mutex == NULL) {
if (!mutex) {
return 0;
}

View File

@@ -45,7 +45,7 @@ struct SDL_semaphore
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem = (SDL_sem *)SDL_malloc(sizeof(SDL_sem));
if (sem != NULL) {
if (sem) {
if (sem_init(&sem->sem, 0, initial_value) < 0) {
SDL_SetError("sem_init() failed");
SDL_free(sem);
@@ -59,7 +59,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
void SDL_DestroySemaphore(SDL_sem *sem)
{
if (sem != NULL) {
if (sem) {
sem_destroy(&sem->sem);
SDL_free(sem);
}
@@ -69,7 +69,7 @@ int SDL_SemTryWait(SDL_sem *sem)
{
int retval;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
retval = SDL_MUTEX_TIMEDOUT;
@@ -83,7 +83,7 @@ int SDL_SemWait(SDL_sem *sem)
{
int retval;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -109,7 +109,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
Uint32 end;
#endif
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -175,7 +175,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
{
int ret = 0;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -191,7 +191,7 @@ int SDL_SemPost(SDL_sem *sem)
{
int retval;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}

View File

@@ -127,10 +127,10 @@ void SDL_SYS_SetupThread(const char *name)
sigset_t mask;
#endif /* !__NACL__ */
if (name != NULL) {
if (name) {
#if (defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN)
SDL_assert(checked_setname);
if (ppthread_setname_np != NULL) {
if (ppthread_setname_np) {
#if defined(__MACOSX__) || defined(__IPHONEOS__)
ppthread_setname_np(name);
#elif defined(__LINUX__)

View File

@@ -57,7 +57,7 @@ SDL_CreateCond(void)
extern "C" void
SDL_DestroyCond(SDL_cond *cond)
{
if (cond != NULL) {
if (cond) {
delete cond;
}
}
@@ -66,7 +66,7 @@ SDL_DestroyCond(SDL_cond *cond)
extern "C" int
SDL_CondSignal(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -78,7 +78,7 @@ SDL_CondSignal(SDL_cond *cond)
extern "C" int
SDL_CondBroadcast(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}

View File

@@ -51,7 +51,7 @@ SDL_CreateMutex(void)
extern "C" void
SDL_DestroyMutex(SDL_mutex *mutex)
{
if (mutex != NULL) {
if (mutex) {
delete mutex;
}
}
@@ -77,7 +77,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
{
int retval = 0;
if (mutex == NULL) {
if (!mutex) {
return 0;
}

View File

@@ -45,7 +45,7 @@ SDL_cond *SDL_CreateCond(void)
SDL_cond *cond;
cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond));
if (cond != NULL) {
if (cond) {
cond->lock = SDL_CreateMutex();
cond->wait_sem = SDL_CreateSemaphore(0);
cond->wait_done = SDL_CreateSemaphore(0);
@@ -63,7 +63,7 @@ SDL_cond *SDL_CreateCond(void)
/* Destroy a condition variable */
void SDL_DestroyCond(SDL_cond *cond)
{
if (cond != NULL) {
if (cond) {
if (cond->wait_sem) {
SDL_DestroySemaphore(cond->wait_sem);
}
@@ -80,7 +80,7 @@ void SDL_DestroyCond(SDL_cond *cond)
/* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -103,7 +103,7 @@ int SDL_CondSignal(SDL_cond *cond)
/* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond)
{
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -158,7 +158,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
{
int retval;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}

View File

@@ -41,7 +41,7 @@ SDL_mutex *SDL_CreateMutex(void)
/* Allocate mutex memory */
mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
if (mutex != NULL) {
if (mutex) {
res = sceKernelCreateLwMutex(
&mutex->lock,
@@ -62,7 +62,7 @@ SDL_mutex *SDL_CreateMutex(void)
/* Free the mutex */
void SDL_DestroyMutex(SDL_mutex *mutex)
{
if (mutex != NULL) {
if (mutex) {
sceKernelDeleteLwMutex(&mutex->lock);
SDL_free(mutex);
}
@@ -76,7 +76,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
#else
SceInt32 res = 0;
if (mutex == NULL) {
if (!mutex) {
return 0;
}
@@ -97,7 +97,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
#else
SceInt32 res = 0;
if (mutex == NULL) {
if (!mutex) {
return 0;
}

View File

@@ -45,7 +45,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
SDL_sem *sem;
sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
if (sem) {
/* TODO: Figure out the limit on the maximum value. */
sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL);
if (sem->semid < 0) {
@@ -63,7 +63,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
/* Free the semaphore */
void SDL_DestroySemaphore(SDL_sem *sem)
{
if (sem != NULL) {
if (sem) {
if (sem->semid > 0) {
sceKernelDeleteSema(sem->semid);
sem->semid = 0;
@@ -82,7 +82,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
Uint32 *pTimeout;
int res;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -128,7 +128,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
SceKernelSemaInfo info;
info.size = sizeof(info);
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -144,7 +144,7 @@ int SDL_SemPost(SDL_sem *sem)
{
int res;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}

View File

@@ -89,7 +89,7 @@ static SDL_cond *SDL_CreateCond_cv(void)
/* Relies on CONDITION_VARIABLE_INIT == 0. */
cond = (SDL_cond_cv *)SDL_calloc(1, sizeof(*cond));
if (cond == NULL) {
if (!cond) {
SDL_OutOfMemory();
}
@@ -98,7 +98,7 @@ static SDL_cond *SDL_CreateCond_cv(void)
static void SDL_DestroyCond_cv(SDL_cond *cond)
{
if (cond != NULL) {
if (cond) {
/* There are no kernel allocated resources */
SDL_free(cond);
}
@@ -107,7 +107,7 @@ static void SDL_DestroyCond_cv(SDL_cond *cond)
static int SDL_CondSignal_cv(SDL_cond *_cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -119,7 +119,7 @@ static int SDL_CondSignal_cv(SDL_cond *_cond)
static int SDL_CondBroadcast_cv(SDL_cond *_cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -134,10 +134,10 @@ static int SDL_CondWaitTimeout_cv(SDL_cond *_cond, SDL_mutex *_mutex, Uint32 ms)
DWORD timeout;
int ret;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
if (_mutex == NULL) {
if (!_mutex) {
return SDL_InvalidParamError("mutex");
}
@@ -220,14 +220,14 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = {
SDL_cond *SDL_CreateCond(void)
{
if (SDL_cond_impl_active.Create == NULL) {
if (!SDL_cond_impl_active.Create) {
/* Default to generic implementation, works with all mutex implementations */
const SDL_cond_impl_t *impl = &SDL_cond_impl_generic;
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 == NULL) {
if (!mutex) {
return NULL;
}
SDL_DestroyMutex(mutex);

View File

@@ -62,7 +62,7 @@ static SDL_mutex *SDL_CreateMutex_srw(void)
/* Relies on SRWLOCK_INIT == 0. */
mutex = (SDL_mutex_srw *)SDL_calloc(1, sizeof(*mutex));
if (mutex == NULL) {
if (!mutex) {
SDL_OutOfMemory();
}
@@ -153,7 +153,7 @@ static SDL_mutex *SDL_CreateMutex_cs(void)
/* Allocate mutex memory */
mutex = (SDL_mutex_cs *)SDL_malloc(sizeof(*mutex));
if (mutex != NULL) {
if (mutex) {
/* Initialize */
/* On SMP systems, a non-zero spin count generally helps performance */
#if __WINRT__
@@ -221,7 +221,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = {
SDL_mutex *SDL_CreateMutex(void)
{
if (SDL_mutex_impl_active.Create == NULL) {
if (!SDL_mutex_impl_active.Create) {
/* Default to fallback implementation */
const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs;
@@ -260,7 +260,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
int SDL_LockMutex(SDL_mutex *mutex)
{
if (mutex == NULL) {
if (!mutex) {
return 0;
}
@@ -269,7 +269,7 @@ int SDL_LockMutex(SDL_mutex *mutex)
int SDL_TryLockMutex(SDL_mutex *mutex)
{
if (mutex == NULL) {
if (!mutex) {
return 0;
}
@@ -278,7 +278,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
int SDL_UnlockMutex(SDL_mutex *mutex)
{
if (mutex == NULL) {
if (!mutex) {
return 0;
}

View File

@@ -97,7 +97,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value)
SDL_sem_atom *sem;
sem = (SDL_sem_atom *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
if (sem) {
sem->count = initial_value;
} else {
SDL_OutOfMemory();
@@ -107,7 +107,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value)
static void SDL_DestroySemaphore_atom(SDL_sem *sem)
{
if (sem != NULL) {
if (sem) {
SDL_free(sem);
}
}
@@ -117,7 +117,7 @@ static int SDL_SemTryWait_atom(SDL_sem *_sem)
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
LONG count;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -138,7 +138,7 @@ static int SDL_SemWait_atom(SDL_sem *_sem)
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
LONG count;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -169,7 +169,7 @@ static int SDL_SemWaitTimeout_atom(SDL_sem *_sem, Uint32 timeout)
return SDL_SemWait_atom(_sem);
}
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -211,7 +211,7 @@ static Uint32 SDL_SemValue_atom(SDL_sem *_sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -223,7 +223,7 @@ static int SDL_SemPost_atom(SDL_sem *_sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -261,7 +261,7 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value)
/* Allocate sem memory */
sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem));
if (sem != NULL) {
if (sem) {
/* Create the semaphore, with max value 32K */
#if __WINRT__
sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS);
@@ -284,7 +284,7 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value)
static void SDL_DestroySemaphore_kern(SDL_sem *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem != NULL) {
if (sem) {
if (sem->id) {
CloseHandle(sem->id);
sem->id = 0;
@@ -299,7 +299,7 @@ static int SDL_SemWaitTimeout_kern(SDL_sem *_sem, Uint32 timeout)
int retval;
DWORD dwMilliseconds;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -337,7 +337,7 @@ static int SDL_SemWait_kern(SDL_sem *sem)
static Uint32 SDL_SemValue_kern(SDL_sem *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -347,7 +347,7 @@ static Uint32 SDL_SemValue_kern(SDL_sem *_sem)
static int SDL_SemPost_kern(SDL_sem *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
/* Increase the counter in the first place, because
@@ -379,7 +379,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = {
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
if (SDL_sem_impl_active.Create == NULL) {
if (!SDL_sem_impl_active.Create) {
/* Default to fallback implementation */
const SDL_sem_impl_t *impl = &SDL_sem_impl_kern;

View File

@@ -49,7 +49,7 @@ static DWORD RunThread(void *data)
SDL_Thread *thread = (SDL_Thread *)data;
pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)thread->endfunc;
SDL_RunThread(thread);
if (pfnEndThread != NULL) {
if (pfnEndThread) {
pfnEndThread(0);
}
return 0;
@@ -98,7 +98,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
RunThreadViaCreateThread,
thread, flags, &threadid);
}
if (thread->handle == NULL) {
if (!thread->handle) {
return SDL_SetError("Not enough resources to create thread");
}
return 0;
@@ -118,7 +118,7 @@ typedef HRESULT(WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR);
void SDL_SYS_SetupThread(const char *name)
{
if (name != NULL) {
if (name) {
#ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */
static pfnSetThreadDescription pSetThreadDescription = NULL;
static HMODULE kernel32 = NULL;
@@ -130,7 +130,7 @@ void SDL_SYS_SetupThread(const char *name)
}
}
if (pSetThreadDescription != NULL) {
if (pSetThreadDescription) {
WCHAR *strw = WIN_UTF8ToStringW(name);
if (strw) {
pSetThreadDescription(GetCurrentThread(), strw);