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

@ -188,11 +188,11 @@ SDL_EVDEV_Init(void)
while ((spec = SDL_strtokr(rest, ",", &rest))) {
char* endofcls = 0;
long cls = SDL_strtol(spec, &endofcls, 0);
if (endofcls)
if (endofcls) {
SDL_EVDEV_device_added(endofcls + 1, cls);
}
}
}
else {
} else {
/* TODO: Scan the devices manually, like a caveman */
}
}
@ -226,7 +226,7 @@ SDL_EVDEV_Quit(void)
SDL_EVDEV_kbd_quit(_this->kbd);
/* Remove existing devices */
while(_this->first != NULL) {
while (_this->first != NULL) {
SDL_EVDEV_device_removed(_this->first->path);
}
@ -249,11 +249,13 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
switch(udev_event) {
case SDL_UDEV_DEVICEADDED:
if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)))
if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD))) {
return;
}
if ((udev_class & SDL_UDEV_DEVICE_JOYSTICK))
if ((udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
return;
}
SDL_EVDEV_device_added(dev_path, udev_class);
break;
@ -338,13 +340,15 @@ SDL_EVDEV_Poll(void)
case EV_ABS:
switch(events[i].code) {
case ABS_MT_SLOT:
if (!item->is_touchscreen) /* FIXME: temp hack */
if (!item->is_touchscreen) { /* FIXME: temp hack */
break;
}
item->touchscreen_data->current_slot = events[i].value;
break;
case ABS_MT_TRACKING_ID:
if (!item->is_touchscreen) /* FIXME: temp hack */
if (!item->is_touchscreen) { /* FIXME: temp hack */
break;
}
if (events[i].value >= 0) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].tracking_id = events[i].value;
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_DOWN;
@ -353,24 +357,27 @@ SDL_EVDEV_Poll(void)
}
break;
case ABS_MT_POSITION_X:
if (!item->is_touchscreen) /* FIXME: temp hack */
if (!item->is_touchscreen) { /* FIXME: temp hack */
break;
}
item->touchscreen_data->slots[item->touchscreen_data->current_slot].x = events[i].value;
if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE;
}
break;
case ABS_MT_POSITION_Y:
if (!item->is_touchscreen) /* FIXME: temp hack */
if (!item->is_touchscreen) { /* FIXME: temp hack */
break;
}
item->touchscreen_data->slots[item->touchscreen_data->current_slot].y = events[i].value;
if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE;
}
break;
case ABS_MT_PRESSURE:
if (!item->is_touchscreen) /* FIXME: temp hack */
if (!item->is_touchscreen) { /* FIXME: temp hack */
break;
}
item->touchscreen_data->slots[item->touchscreen_data->current_slot].pressure = events[i].value;
if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) {
item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE;
@ -378,8 +385,9 @@ SDL_EVDEV_Poll(void)
break;
case ABS_X:
if (item->is_touchscreen) {
if (item->touchscreen_data->max_slots != 1)
if (item->touchscreen_data->max_slots != 1) {
break;
}
item->touchscreen_data->slots[0].x = events[i].value;
} else if (!item->relative_mouse) {
/* FIXME: Normalize to input device's reported input range (EVIOCGABS) */
@ -388,8 +396,9 @@ SDL_EVDEV_Poll(void)
break;
case ABS_Y:
if (item->is_touchscreen) {
if (item->touchscreen_data->max_slots != 1)
if (item->touchscreen_data->max_slots != 1) {
break;
}
item->touchscreen_data->slots[0].y = events[i].value;
} else if (!item->relative_mouse) {
/* FIXME: Normalize to input device's reported input range (EVIOCGABS) */
@ -403,24 +412,28 @@ SDL_EVDEV_Poll(void)
case EV_REL:
switch(events[i].code) {
case REL_X:
if (item->relative_mouse)
if (item->relative_mouse) {
item->mouse_x += events[i].value;
}
break;
case REL_Y:
if (item->relative_mouse)
if (item->relative_mouse) {
item->mouse_y += events[i].value;
}
break;
case REL_WHEEL:
if (!item->high_res_wheel)
if (!item->high_res_wheel) {
item->mouse_wheel += events[i].value;
}
break;
case REL_WHEEL_HI_RES:
SDL_assert(item->high_res_wheel);
item->mouse_wheel += events[i].value;
break;
case REL_HWHEEL:
if (!item->high_res_hwheel)
if (!item->high_res_hwheel) {
item->mouse_hwheel += events[i].value;
}
break;
case REL_HWHEEL_HI_RES:
SDL_assert(item->high_res_hwheel);
@ -446,10 +459,11 @@ SDL_EVDEV_Poll(void)
item->mouse_wheel = item->mouse_hwheel = 0;
}
if (!item->is_touchscreen) /* FIXME: temp hack */
if (!item->is_touchscreen) { /* FIXME: temp hack */
break;
}
for(j = 0; j < item->touchscreen_data->max_slots; j++) {
for (j = 0; j < item->touchscreen_data->max_slots; j++) {
norm_x = (float)(item->touchscreen_data->slots[j].x - item->touchscreen_data->min_x) /
(float)item->touchscreen_data->range_x;
norm_y = (float)(item->touchscreen_data->slots[j].y - item->touchscreen_data->min_y) /
@ -485,12 +499,14 @@ SDL_EVDEV_Poll(void)
}
}
if (item->out_of_sync)
if (item->out_of_sync) {
item->out_of_sync = SDL_FALSE;
}
break;
case SYN_DROPPED:
if (item->is_touchscreen)
if (item->is_touchscreen) {
item->out_of_sync = SDL_TRUE;
}
SDL_EVDEV_sync_device(item);
break;
default:
@ -533,12 +549,14 @@ SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class)
char name[64];
struct input_absinfo abs_info;
if (!item->is_touchscreen)
if (!item->is_touchscreen) {
return 0;
}
item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data));
if (item->touchscreen_data == NULL)
if (item->touchscreen_data == NULL) {
return SDL_OutOfMemory();
}
ret = ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
if (ret < 0) {
@ -608,7 +626,7 @@ SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class)
return SDL_OutOfMemory();
}
for(i = 0; i < item->touchscreen_data->max_slots; i++) {
for (i = 0; i < item->touchscreen_data->max_slots; i++) {
item->touchscreen_data->slots[i].tracking_id = -1;
}
@ -627,8 +645,9 @@ SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item, int udev_class)
static void
SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item* item) {
if (!item->is_touchscreen)
if (!item->is_touchscreen) {
return;
}
SDL_DelTouch(item->fd);
SDL_free(item->touchscreen_data->slots);
@ -655,8 +674,9 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
size_t mt_req_size;
/* TODO: sync devices other than touchscreen */
if (!item->is_touchscreen)
if (!item->is_touchscreen) {
return;
}
mt_req_size = sizeof(*mt_req_code) +
sizeof(*mt_req_values) * item->touchscreen_data->max_slots;
@ -674,7 +694,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
SDL_free(mt_req_code);
return;
}
for(i = 0; i < item->touchscreen_data->max_slots; i++) {
for (i = 0; i < item->touchscreen_data->max_slots; i++) {
/*
* This doesn't account for the very edge case of the user removing their
* finger and replacing it on the screen during the time we're out of sync,
@ -701,7 +721,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
SDL_free(mt_req_code);
return;
}
for(i = 0; i < item->touchscreen_data->max_slots; i++) {
for (i = 0; i < item->touchscreen_data->max_slots; i++) {
if (item->touchscreen_data->slots[i].tracking_id >= 0 &&
item->touchscreen_data->slots[i].x != mt_req_values[i]) {
item->touchscreen_data->slots[i].x = mt_req_values[i];
@ -719,7 +739,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
SDL_free(mt_req_code);
return;
}
for(i = 0; i < item->touchscreen_data->max_slots; i++) {
for (i = 0; i < item->touchscreen_data->max_slots; i++) {
if (item->touchscreen_data->slots[i].tracking_id >= 0 &&
item->touchscreen_data->slots[i].y != mt_req_values[i]) {
item->touchscreen_data->slots[i].y = mt_req_values[i];
@ -737,7 +757,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
SDL_free(mt_req_code);
return;
}
for(i = 0; i < item->touchscreen_data->max_slots; i++) {
for (i = 0; i < item->touchscreen_data->max_slots; i++) {
if (item->touchscreen_data->slots[i].tracking_id >= 0 &&
item->touchscreen_data->slots[i].pressure != mt_req_values[i]) {
item->touchscreen_data->slots[i].pressure = mt_req_values[i];