Pointer as bool (libsdl-org#7214)

This commit is contained in:
Sylvain
2023-11-09 22:29:15 +01:00
committed by Sam Lantinga
parent 23db971681
commit d8600f717e
371 changed files with 2448 additions and 2442 deletions

View File

@@ -84,7 +84,7 @@ static SDL_Condition *SDL_CreateCondition_cv(void)
/* Relies on CONDITION_VARIABLE_INIT == 0. */
cond = (SDL_cond_cv *)SDL_calloc(1, sizeof(*cond));
if (cond == NULL) {
if (!cond) {
SDL_OutOfMemory();
}
@@ -93,7 +93,7 @@ static SDL_Condition *SDL_CreateCondition_cv(void)
static void SDL_DestroyCondition_cv(SDL_Condition *cond)
{
if (cond != NULL) {
if (cond) {
/* There are no kernel allocated resources */
SDL_free(cond);
}
@@ -102,7 +102,7 @@ static void SDL_DestroyCondition_cv(SDL_Condition *cond)
static int SDL_SignalCondition_cv(SDL_Condition *_cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -114,7 +114,7 @@ static int SDL_SignalCondition_cv(SDL_Condition *_cond)
static int SDL_BroadcastCondition_cv(SDL_Condition *_cond)
{
SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
@@ -129,10 +129,10 @@ static int SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mutex
DWORD timeout;
int ret;
if (cond == NULL) {
if (!cond) {
return SDL_InvalidParamError("cond");
}
if (_mutex == NULL) {
if (!_mutex) {
return SDL_InvalidParamError("mutex");
}
@@ -208,13 +208,13 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = {
SDL_Condition *SDL_CreateCondition(void)
{
if (SDL_cond_impl_active.Create == NULL) {
if (!SDL_cond_impl_active.Create) {
const SDL_cond_impl_t *impl = NULL;
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

@@ -61,7 +61,7 @@ static SDL_Mutex *SDL_CreateMutex_srw(void)
SDL_mutex_srw *mutex;
mutex = (SDL_mutex_srw *)SDL_calloc(1, sizeof(*mutex));
if (mutex == NULL) {
if (!mutex) {
SDL_OutOfMemory();
}
@@ -145,7 +145,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_srw = {
static SDL_Mutex *SDL_CreateMutex_cs(void)
{
SDL_mutex_cs *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
#ifdef __WINRT__
@@ -199,7 +199,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;
@@ -239,7 +239,7 @@ void SDL_DestroyMutex(SDL_Mutex *mutex)
void SDL_LockMutex(SDL_Mutex *mutex)
{
if (mutex != NULL) {
if (mutex) {
SDL_mutex_impl_active.Lock(mutex);
}
}
@@ -251,7 +251,7 @@ int SDL_TryLockMutex(SDL_Mutex *mutex)
void SDL_UnlockMutex(SDL_Mutex *mutex)
{
if (mutex != NULL) {
if (mutex) {
SDL_mutex_impl_active.Unlock(mutex);
}
}

View File

@@ -88,7 +88,7 @@ typedef struct SDL_rwlock_srw
static SDL_RWLock *SDL_CreateRWLock_srw(void)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *)SDL_calloc(1, sizeof(*rwlock));
if (rwlock == NULL) {
if (!rwlock) {
SDL_OutOfMemory();
}
pInitializeSRWLock(&rwlock->srw);
@@ -125,7 +125,7 @@ static int SDL_TryLockRWLockForReading_srw(SDL_RWLock *_rwlock)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
int retval = 0;
if (rwlock != NULL) {
if (rwlock) {
retval = pTryAcquireSRWLockShared(&rwlock->srw) ? 0 : SDL_RWLOCK_TIMEDOUT;
}
return retval;
@@ -135,7 +135,7 @@ static int SDL_TryLockRWLockForWriting_srw(SDL_RWLock *_rwlock)
{
SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock;
int retval = 0;
if (rwlock != NULL) {
if (rwlock) {
retval = pTryAcquireSRWLockExclusive(&rwlock->srw) ? 0 : SDL_RWLOCK_TIMEDOUT;
}
return retval;
@@ -182,7 +182,7 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = {
SDL_RWLock *SDL_CreateRWLock(void)
{
if (SDL_rwlock_impl_active.Create == NULL) {
if (!SDL_rwlock_impl_active.Create) {
const SDL_rwlock_impl_t *impl;
#ifdef __WINRT__

View File

@@ -83,7 +83,7 @@ static SDL_Semaphore *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();
@@ -93,7 +93,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_atom(Uint32 initial_value)
static void SDL_DestroySemaphore_atom(SDL_Semaphore *sem)
{
if (sem != NULL) {
if (sem) {
SDL_free(sem);
}
}
@@ -106,7 +106,7 @@ static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_Semaphore *_sem, Sint64 timeoutNS
Uint64 deadline;
DWORD timeout_eff;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -176,7 +176,7 @@ static Uint32 SDL_GetSemaphoreValue_atom(SDL_Semaphore *_sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -188,7 +188,7 @@ static int SDL_PostSemaphore_atom(SDL_Semaphore *_sem)
{
SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -224,7 +224,7 @@ static SDL_Semaphore *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 */
#ifdef __WINRT__
sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS);
@@ -247,7 +247,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value)
static void SDL_DestroySemaphore_kern(SDL_Semaphore *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem != NULL) {
if (sem) {
if (sem->id) {
CloseHandle(sem->id);
sem->id = 0;
@@ -262,7 +262,7 @@ static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_Semaphore *_sem, Sint64 timeoutNS
int retval;
DWORD dwMilliseconds;
if (sem == NULL) {
if (!sem) {
return SDL_InvalidParamError("sem");
}
@@ -290,7 +290,7 @@ static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_Semaphore *_sem, Sint64 timeoutNS
static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem)
{
SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem == NULL) {
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
@@ -300,7 +300,7 @@ static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem)
static int SDL_PostSemaphore_kern(SDL_Semaphore *_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
@@ -330,7 +330,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = {
SDL_Semaphore *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

@@ -47,7 +47,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;
@@ -96,7 +96,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;
@@ -116,7 +116,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;
@@ -128,7 +128,7 @@ void SDL_SYS_SetupThread(const char *name)
}
}
if (pSetThreadDescription != NULL) {
if (pSetThreadDescription) {
WCHAR *strw = WIN_UTF8ToStringW(name);
if (strw) {
pSetThreadDescription(GetCurrentThread(), strw);