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

@@ -258,8 +258,9 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state
((match_state & (1<<SDL_CONTROLLER_BUTTON_DPAD_RIGHT)) ? XINPUT_GAMEPAD_DPAD_RIGHT : 0);
*/
if (state->xinput_buttons)
if (state->xinput_buttons) {
state->any_data = SDL_TRUE;
}
#endif
#ifdef SDL_JOYSTICK_RAWINPUT_WGI
@@ -296,8 +297,9 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state
((match_state & (1<<SDL_CONTROLLER_BUTTON_DPAD_LEFT)) ? GamepadButtons_DPadLeft : 0) |
((match_state & (1<<SDL_CONTROLLER_BUTTON_DPAD_RIGHT)) ? GamepadButtons_DPadRight : 0); */
if (state->wgi_buttons)
if (state->wgi_buttons) {
state->any_data = SDL_TRUE;
}
#endif
}
@@ -471,11 +473,13 @@ static void
RAWINPUT_UpdateWindowsGamingInput()
{
int ii;
if (!wgi_state.gamepad_statics)
if (!wgi_state.gamepad_statics) {
return;
}
if (!wgi_state.dirty)
if (!wgi_state.dirty) {
return;
}
wgi_state.dirty = SDL_FALSE;
@@ -519,7 +523,7 @@ RAWINPUT_UpdateWindowsGamingInput()
return;
}
gamepad_state = SDL_calloc(1, sizeof(*gamepad_state));
if (!gamepad_state) {
if (gamepad_state == NULL) {
SDL_OutOfMemory();
return;
}
@@ -702,8 +706,9 @@ RAWINPUT_DeviceFromHandle(HANDLE hDevice)
SDL_RAWINPUT_Device *curr;
for (curr = SDL_RAWINPUT_devices; curr; curr = curr->next) {
if (curr->hDevice == hDevice)
if (curr->hDevice == hDevice) {
return curr;
}
}
return NULL;
}
@@ -711,7 +716,7 @@ RAWINPUT_DeviceFromHandle(HANDLE hDevice)
static void
RAWINPUT_AddDevice(HANDLE hDevice)
{
#define CHECK(expression) { if(!(expression)) goto err; }
#define CHECK(expression) { if (!(expression)) goto err; }
SDL_RAWINPUT_Device *device = NULL;
SDL_RAWINPUT_Device *curr, *last;
RID_DEVICE_INFO rdi;
@@ -1076,7 +1081,7 @@ RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
ULONG i;
ctx = (RAWINPUT_DeviceContext *)SDL_calloc(1, sizeof(RAWINPUT_DeviceContext));
if (!ctx) {
if (ctx == NULL) {
return SDL_OutOfMemory();
}
joystick->hwdata = ctx;
@@ -1089,7 +1094,7 @@ RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
xinput_device_change = SDL_TRUE;
ctx->xinput_enabled = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, SDL_TRUE);
if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || !XINPUTGETSTATE)) {
if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || XINPUTGETSTATE == NULL)) {
ctx->xinput_enabled = SDL_FALSE;
}
ctx->xinput_slot = XUSER_INDEX_ANY;
@@ -1285,7 +1290,7 @@ RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uin
if (!rumbled && ctx->xinput_correlated) {
XINPUT_VIBRATION XVibration;
if (!XINPUTSETSTATE) {
if (XINPUTSETSTATE == NULL) {
return SDL_Unsupported();
}
@@ -1638,10 +1643,12 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
correlated = SDL_TRUE;
RAWINPUT_MarkWindowsGamingInputSlotUsed(ctx->wgi_slot, ctx);
/* If the generalized Guide button was using us, it doesn't need to anymore */
if (guide_button_candidate.joystick == joystick)
if (guide_button_candidate.joystick == joystick) {
guide_button_candidate.joystick = NULL;
if (guide_button_candidate.last_joystick == joystick)
}
if (guide_button_candidate.last_joystick == joystick) {
guide_button_candidate.last_joystick = NULL;
}
}
} else {
/* someone else also possibly correlated to this device, start over */
@@ -1732,10 +1739,12 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
correlated = SDL_TRUE;
RAWINPUT_MarkXInputSlotUsed(ctx->xinput_slot);
/* If the generalized Guide button was using us, it doesn't need to anymore */
if (guide_button_candidate.joystick == joystick)
if (guide_button_candidate.joystick == joystick) {
guide_button_candidate.joystick = NULL;
if (guide_button_candidate.last_joystick == joystick)
}
if (guide_button_candidate.last_joystick == joystick) {
guide_button_candidate.last_joystick = NULL;
}
}
} else {
/* someone else also possibly correlated to this device, start over */
@@ -1847,10 +1856,12 @@ RAWINPUT_JoystickClose(SDL_Joystick *joystick)
RAWINPUT_DeviceContext *ctx = joystick->hwdata;
#ifdef SDL_JOYSTICK_RAWINPUT_MATCHING
if (guide_button_candidate.joystick == joystick)
if (guide_button_candidate.joystick == joystick) {
guide_button_candidate.joystick = NULL;
if (guide_button_candidate.last_joystick == joystick)
}
if (guide_button_candidate.last_joystick == joystick) {
guide_button_candidate.last_joystick = NULL;
}
#endif
if (ctx) {