From f2b796940ea6ee0e90e78b9e77ebd26da1eef9a8 Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 18 Jul 2018 15:56:21 +0000 Subject: [PATCH] Add missing braces to if/for/while blocks. Astyle doesn't quite catch all of them. --- src/chat.c | 15 +++++++++------ src/prompt.c | 10 ++++++---- src/toxic.c | 4 ++-- src/toxic_strings.c | 6 ++++-- src/windows.c | 13 ++++++++----- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/chat.c b/src/chat.c index 422ad8b..5a08e4f 100644 --- a/src/chat.c +++ b/src/chat.c @@ -180,12 +180,13 @@ static void recv_message_helper(ToxWindow *self, Tox *m, uint32_t num, const cha line_info_add(self, timefrmt, nick, NULL, IN_MSG, 0, 0, "%s", msg); write_to_log(msg, nick, ctx->log, false); - if (self->active_box != -1) + if (self->active_box != -1) { box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, self->active_box, "%s", msg); - else + } else { box_notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, &self->active_box, nick, "%s", msg); + } } static void recv_action_helper(ToxWindow *self, Tox *m, uint32_t num, const char *action, size_t len, @@ -196,12 +197,13 @@ static void recv_action_helper(ToxWindow *self, Tox *m, uint32_t num, const char line_info_add(self, timefrmt, nick, NULL, IN_ACTION, 0, 0, "%s", action); write_to_log(action, nick, ctx->log, true); - if (self->active_box != -1) + if (self->active_box != -1) { box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, self->active_box, "* %s %s", nick, action); - else + } else { box_notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS | user_settings->bell_on_message, &self->active_box, self->name, "* %s %s", nick, action); + } } static void chat_onMessage(ToxWindow *self, Tox *m, uint32_t num, TOX_MESSAGE_TYPE type, const char *msg, size_t len) @@ -648,12 +650,13 @@ static void chat_onFileRecv(ToxWindow *self, Tox *m, uint32_t friendnum, uint32_ snprintf(ft->file_name, sizeof(ft->file_name), "%s", filename); tox_file_get_file_id(m, friendnum, filenum, ft->file_id, NULL); - if (self->active_box != -1) + if (self->active_box != -1) { box_notify2(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS | user_settings->bell_on_filetrans, self->active_box, "Incoming file: %s", filename); - else + } else { box_notify(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS | user_settings->bell_on_filetrans, &self->active_box, self->name, "Incoming file: %s", filename); + } } static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, uint8_t type, const char *group_pub_key, diff --git a/src/prompt.c b/src/prompt.c index a9bde45..4f55beb 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -450,23 +450,25 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnu line_info_add(self, timefrmt, nick, NULL, CONNECTION, 0, GREEN, msg); write_to_log(msg, nick, ctx->log, true); - if (self->active_box != -1) + if (self->active_box != -1) { box_notify2(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, "%s has come online", nick); - else + } else { box_notify(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box, "Toxic", "%s has come online", nick); + } } else if (connection_status == TOX_CONNECTION_NONE) { msg = "has gone offline"; line_info_add(self, timefrmt, nick, NULL, DISCONNECTION, 0, RED, msg); write_to_log(msg, nick, ctx->log, true); - if (self->active_box != -1) + if (self->active_box != -1) { box_notify2(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, "%s has gone offline", nick); - else + } else { box_notify(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box, "Toxic", "%s has gone offline", nick); + } } } diff --git a/src/toxic.c b/src/toxic.c index 452bad3..7e04d44 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -382,8 +382,8 @@ static int password_prompt(char *buf, int size) if (buf[--len] != '\n') { int ch; - while ((ch = getchar()) != '\n' && ch > 0) - ; + while ((ch = getchar()) != '\n' && ch > 0) { + } return 0; } diff --git a/src/toxic_strings.c b/src/toxic_strings.c index 1ad8d47..45f607e 100644 --- a/src/toxic_strings.c +++ b/src/toxic_strings.c @@ -261,18 +261,20 @@ void strsubst(char *str, char old, char new) { int i; - for (i = 0; str[i] != '\0'; ++i) + for (i = 0; str[i] != '\0'; ++i) { if (str[i] == old) { str[i] = new; } + } } void wstrsubst(wchar_t *str, wchar_t old, wchar_t new) { int i; - for (i = 0; str[i] != L'\0'; ++i) + for (i = 0; str[i] != L'\0'; ++i) { if (str[i] == old) { str[i] = new; } + } } diff --git a/src/windows.c b/src/windows.c index 36c61ef..923e234 100644 --- a/src/windows.c +++ b/src/windows.c @@ -304,9 +304,10 @@ void on_file_recv(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint32_t k size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { - if (windows[i].onFileRecv != NULL) + if (windows[i].onFileRecv != NULL) { windows[i].onFileRecv(&windows[i], m, friendnumber, filenumber, file_size, (char *) filename, filename_length); + } } } @@ -534,25 +535,27 @@ static void draw_bar(void) continue; } - if (windows + i == active_window) + if (windows + i == active_window) { #ifdef URXVT_FIX attron(A_BOLD | COLOR_PAIR(GREEN)); - else + } else { #endif attron(A_BOLD); + } draw_window_tab(&windows[i]); - if (windows + i == active_window) + if (windows + i == active_window) { #ifdef URXVT_FIX attroff(A_BOLD | COLOR_PAIR(GREEN)); - else + } else { #endif attroff(A_BOLD); + } } // restore cursor position after drawing