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

@@ -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