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
387 changed files with 6094 additions and 4633 deletions

View File

@@ -64,14 +64,30 @@ IBus_ModState(void)
SDL_Keymod sdl_mods = SDL_GetModState();
/* Not sure about MOD3, MOD4 and HYPER mappings */
if (sdl_mods & KMOD_LSHIFT) ibus_mods |= IBUS_SHIFT_MASK;
if (sdl_mods & KMOD_CAPS) ibus_mods |= IBUS_LOCK_MASK;
if (sdl_mods & KMOD_LCTRL) ibus_mods |= IBUS_CONTROL_MASK;
if (sdl_mods & KMOD_LALT) ibus_mods |= IBUS_MOD1_MASK;
if (sdl_mods & KMOD_NUM) ibus_mods |= IBUS_MOD2_MASK;
if (sdl_mods & KMOD_MODE) ibus_mods |= IBUS_MOD5_MASK;
if (sdl_mods & KMOD_LGUI) ibus_mods |= IBUS_SUPER_MASK;
if (sdl_mods & KMOD_RGUI) ibus_mods |= IBUS_META_MASK;
if (sdl_mods & KMOD_LSHIFT) {
ibus_mods |= IBUS_SHIFT_MASK;
}
if (sdl_mods & KMOD_CAPS) {
ibus_mods |= IBUS_LOCK_MASK;
}
if (sdl_mods & KMOD_LCTRL) {
ibus_mods |= IBUS_CONTROL_MASK;
}
if (sdl_mods & KMOD_LALT) {
ibus_mods |= IBUS_MOD1_MASK;
}
if (sdl_mods & KMOD_NUM) {
ibus_mods |= IBUS_MOD2_MASK;
}
if (sdl_mods & KMOD_MODE) {
ibus_mods |= IBUS_MOD5_MASK;
}
if (sdl_mods & KMOD_LGUI) {
ibus_mods |= IBUS_SUPER_MASK;
}
if (sdl_mods & KMOD_RGUI) {
ibus_mods |= IBUS_META_MASK;
}
return ibus_mods;
}
@@ -98,7 +114,7 @@ IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *
}
dbus->message_iter_get_basic(inside, &struct_id);
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
if (struct_id == NULL || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
return SDL_FALSE;
}
return SDL_TRUE;
@@ -248,13 +264,12 @@ IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data)
dbus->message_iter_init(msg, &iter);
has_dec_pos = IBus_GetDecorationPosition(conn, &iter, dbus, &start_pos, &end_pos);
if (!has_dec_pos)
{
if (!has_dec_pos) {
dbus->message_iter_init(msg, &iter);
has_pos = IBus_GetVariantCursorPos(conn, &iter, dbus, &pos);
}
if(has_dec_pos) {
if (has_dec_pos) {
SDL_SendEditingText(text, start_pos, end_pos - start_pos);
} else if (has_pos) {
SDL_SendEditingText(text, pos, -1);
@@ -298,15 +313,19 @@ IBus_ReadAddressFromFile(const char *file_path)
FILE *addr_file;
addr_file = fopen(file_path, "r");
if (!addr_file) {
if (addr_file == NULL) {
return NULL;
}
while (fgets(addr_buf, sizeof(addr_buf), addr_file)) {
if (SDL_strncmp(addr_buf, "IBUS_ADDRESS=", sizeof("IBUS_ADDRESS=")-1) == 0) {
size_t sz = SDL_strlen(addr_buf);
if (addr_buf[sz-1] == '\n') addr_buf[sz-1] = 0;
if (addr_buf[sz-2] == '\r') addr_buf[sz-2] = 0;
if (addr_buf[sz - 1] == '\n') {
addr_buf[sz - 1] = 0;
}
if (addr_buf[sz - 2] == '\r') {
addr_buf[sz - 2] = 0;
}
success = SDL_TRUE;
break;
}
@@ -340,7 +359,7 @@ IBus_GetDBusAddressFilename(void)
}
dbus = SDL_DBus_GetContext();
if (!dbus) {
if (dbus == NULL) {
return NULL;
}
@@ -354,7 +373,7 @@ IBus_GetDBusAddressFilename(void)
and look up the address from a filepath using all those bits, eek. */
disp_env = SDL_getenv("DISPLAY");
if (!disp_env || !*disp_env) {
if (disp_env == NULL || !*disp_env) {
display = SDL_strdup(":0.0");
} else {
display = SDL_strdup(disp_env);
@@ -364,7 +383,7 @@ IBus_GetDBusAddressFilename(void)
disp_num = SDL_strrchr(display, ':');
screen_num = SDL_strrchr(display, '.');
if (!disp_num) {
if (disp_num == NULL) {
SDL_free(display);
return NULL;
}
@@ -392,7 +411,7 @@ IBus_GetDBusAddressFilename(void)
SDL_strlcpy(config_dir, conf_env, sizeof(config_dir));
} else {
const char *home_env = SDL_getenv("HOME");
if (!home_env || !*home_env) {
if (home_env == NULL || !*home_env) {
SDL_free(display);
return NULL;
}
@@ -460,7 +479,7 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr)
ibus_input_interface = IBUS_INPUT_INTERFACE;
ibus_conn = dbus->connection_open_private(addr, NULL);
if (!ibus_conn) {
if (ibus_conn == NULL) {
return SDL_FALSE; /* oh well. */
}
@@ -498,7 +517,9 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr)
static SDL_bool
IBus_CheckConnection(SDL_DBusContext *dbus)
{
if (!dbus) return SDL_FALSE;
if (dbus == NULL) {
return SDL_FALSE;
}
if (ibus_conn && dbus->connection_get_is_connected(ibus_conn)) {
return SDL_TRUE;
@@ -516,7 +537,9 @@ IBus_CheckConnection(SDL_DBusContext *dbus)
struct inotify_event *event = (struct inotify_event*) p;
if (event->len > 0) {
char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/');
if (!addr_file_no_path) return SDL_FALSE;
if (addr_file_no_path == NULL) {
return SDL_FALSE;
}
if (SDL_strcmp(addr_file_no_path + 1, event->name) == 0) {
file_updated = SDL_TRUE;
@@ -552,7 +575,7 @@ SDL_IBus_Init(void)
char *addr;
char *addr_file_dir;
if (!addr_file) {
if (addr_file == NULL) {
return SDL_FALSE;
}
@@ -560,7 +583,7 @@ SDL_IBus_Init(void)
ibus_addr_file = SDL_strdup(addr_file);
addr = IBus_ReadAddressFromFile(addr_file);
if (!addr) {
if (addr == NULL) {
SDL_free(addr_file);
return SDL_FALSE;
}
@@ -699,7 +722,7 @@ SDL_IBus_UpdateTextRect(const SDL_Rect *rect)
}
focused_win = SDL_GetKeyboardFocus();
if (!focused_win) {
if (focused_win == NULL) {
return;
}