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
This commit is contained in:
Sylvain Becker 2022-11-27 17:38:43 +01:00 committed by GitHub
parent 4958dafdc3
commit 6a2200823c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
387 changed files with 6094 additions and 4633 deletions

View file

@ -269,13 +269,14 @@ static void kbd_unregister_emerg_cleanup()
old_action_p = &(old_sigaction[signum]);
/* Examine current signal action */
if (sigaction(signum, NULL, &cur_action))
if (sigaction(signum, NULL, &cur_action)) {
continue;
}
/* Check if action installed and not modifed */
if (!(cur_action.sa_flags & SA_SIGINFO)
|| cur_action.sa_sigaction != &kbd_cleanup_signal_action)
if (!(cur_action.sa_flags & SA_SIGINFO) || cur_action.sa_sigaction != &kbd_cleanup_signal_action) {
continue;
}
/* Restore original action */
sigaction(signum, old_action_p, NULL);
@ -319,16 +320,16 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd)
struct sigaction new_action;
signum = fatal_signals[tabidx];
old_action_p = &(old_sigaction[signum]);
if (sigaction(signum, NULL, old_action_p))
if (sigaction(signum, NULL, old_action_p)) {
continue;
}
/* Skip SIGHUP and SIGPIPE if handler is already installed
* - assume the handler will do the cleanup
*/
if ((signum == SIGHUP || signum == SIGPIPE)
&& (old_action_p->sa_handler != SIG_DFL
|| (void (*)(int))old_action_p->sa_sigaction != SIG_DFL))
if ((signum == SIGHUP || signum == SIGPIPE) && (old_action_p->sa_handler != SIG_DFL || (void(*)(int))old_action_p->sa_sigaction != SIG_DFL)) {
continue;
}
new_action = *old_action_p;
new_action.sa_flags |= SA_SIGINFO;
@ -346,7 +347,7 @@ SDL_EVDEV_kbd_init(void)
char shift_state[ sizeof (long) ] = {TIOCL_GETSHIFTSTATE, 0};
kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd));
if (!kbd) {
if (kbd == NULL) {
return NULL;
}
@ -412,7 +413,7 @@ SDL_EVDEV_kbd_init(void)
void
SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
{
if (!kbd) {
if (kbd == NULL) {
return;
}
@ -460,10 +461,12 @@ static void put_utf8(SDL_EVDEV_keyboard_state *kbd, uint c)
put_queue(kbd, 0xc0 | (c >> 6));
put_queue(kbd, 0x80 | (c & 0x3f));
} else if (c < 0x10000) {
if (c >= 0xD800 && c < 0xE000)
if (c >= 0xD800 && c < 0xE000) {
return;
if (c == 0xFFFF)
}
if (c == 0xFFFF) {
return;
}
/* 1110**** 10****** 10****** */
put_queue(kbd, 0xe0 | (c >> 12));
put_queue(kbd, 0x80 | ((c >> 6) & 0x3f));
@ -498,8 +501,9 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
}
}
if (ch == ' ' || ch == d)
if (ch == ' ' || ch == d) {
return d;
}
put_utf8(kbd, d);
@ -553,24 +557,27 @@ static void fn_enter(SDL_EVDEV_keyboard_state *kbd)
static void fn_caps_toggle(SDL_EVDEV_keyboard_state *kbd)
{
if (kbd->rep)
if (kbd->rep) {
return;
}
chg_vc_kbd_led(kbd, K_CAPSLOCK);
}
static void fn_caps_on(SDL_EVDEV_keyboard_state *kbd)
{
if (kbd->rep)
if (kbd->rep) {
return;
}
set_vc_kbd_led(kbd, K_CAPSLOCK);
}
static void fn_num(SDL_EVDEV_keyboard_state *kbd)
{
if (!kbd->rep)
if (!kbd->rep) {
chg_vc_kbd_led(kbd, K_NUMLOCK);
}
}
static void fn_compose(SDL_EVDEV_keyboard_state *kbd)
@ -588,12 +595,15 @@ static void k_ignore(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up
static void k_spec(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
{
if (up_flag)
if (up_flag) {
return;
if (value >= SDL_arraysize(fn_handler))
}
if (value >= SDL_arraysize(fn_handler)) {
return;
if (fn_handler[value])
}
if (fn_handler[value]) {
fn_handler[value](kbd);
}
}
static void k_lowercase(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
@ -602,11 +612,13 @@ static void k_lowercase(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char
static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
{
if (up_flag)
return; /* no action, if this is a key release */
if (up_flag) {
return; /* no action, if this is a key release */
}
if (kbd->diacr)
if (kbd->diacr) {
value = handle_diacr(kbd, value);
}
if (kbd->dead_key_next) {
kbd->dead_key_next = SDL_FALSE;
@ -675,8 +687,9 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
*/
if (value == KVAL(K_CAPSSHIFT)) {
value = KVAL(K_SHIFT);
if (!up_flag)
if (!up_flag) {
clr_vc_kbd_led(kbd, K_CAPSLOCK);
}
}
if (up_flag) {
@ -684,8 +697,9 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
* handle the case that two shift or control
* keys are depressed simultaneously
*/
if (kbd->shift_down[value])
if (kbd->shift_down[value]) {
kbd->shift_down[value]--;
}
} else
kbd->shift_down[value]++;
@ -761,7 +775,7 @@ SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int d
unsigned short *key_map;
unsigned short keysym;
if (!kbd) {
if (kbd == NULL) {
return;
}
@ -769,7 +783,7 @@ SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int d
shift_final = (kbd->shift_state | kbd->slockstate) ^ kbd->lockstate;
key_map = kbd->key_maps[shift_final];
if (!key_map) {
if (key_map == NULL) {
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
kbd->shift_state = 0;
kbd->slockstate = 0;