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

@@ -174,7 +174,7 @@ SDL_TimerThread(void *_data)
current->scheduled = tick + interval;
SDL_AddTimerInternal(data, current);
} else {
if (!freelist_head) {
if (freelist_head == NULL) {
freelist_head = current;
}
if (freelist_tail) {
@@ -302,7 +302,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
SDL_RemoveTimer(timer->timerID);
} else {
timer = (SDL_Timer *)SDL_malloc(sizeof(*timer));
if (!timer) {
if (timer == NULL) {
SDL_OutOfMemory();
return 0;
}
@@ -315,7 +315,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
SDL_AtomicSet(&timer->canceled, 0);
entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry));
if (!entry) {
if (entry == NULL) {
SDL_free(timer);
SDL_OutOfMemory();
return 0;
@@ -432,7 +432,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
SDL_TimerMap *entry;
entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry));
if (!entry) {
if (entry == NULL) {
SDL_OutOfMemory();
return 0;
}

View File

@@ -38,8 +38,7 @@ extern "C" {
void
SDL_TicksInit(void)
{
if (ticks_started)
{
if (ticks_started) {
return;
}
ticks_started = SDL_TRUE;
@@ -62,8 +61,7 @@ SDL_TicksQuit(void)
Uint64
SDL_GetTicks64(void)
{
if (! ticks_started)
{
if (! ticks_started) {
SDL_TicksInit();
}

View File

@@ -79,8 +79,9 @@ SDL_GetPerformanceFrequency(void)
void SDL_Delay(Uint32 ms)
{
const Uint32 max_delay = 0xffffffffUL / 1000;
if(ms > max_delay)
if (ms > max_delay) {
ms = max_delay;
}
sceKernelDelayThreadCB(ms * 1000);
}

View File

@@ -117,7 +117,7 @@ SDL_GetTicks64(void)
return (Uint64)(((Sint64)(now.tv_sec - start_ts.tv_sec) * 1000) + ((now.tv_nsec - start_ts.tv_nsec) / 1000000));
#elif defined(__APPLE__)
const uint64_t now = mach_absolute_time();
return ((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
return (((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000;
#else
SDL_assert(SDL_FALSE);
return 0;
@@ -159,7 +159,7 @@ SDL_GetPerformanceCounter(void)
ticks *= 1000000;
ticks += now.tv_usec;
}
return (ticks);
return ticks;
}
Uint64

View File

@@ -79,8 +79,9 @@ SDL_GetPerformanceFrequency(void)
void SDL_Delay(Uint32 ms)
{
const Uint32 max_delay = 0xffffffffUL / 1000;
if(ms > max_delay)
if (ms > max_delay) {
ms = max_delay;
}
sceKernelDelayThreadCB(ms * 1000);
}