From 8dfa41ea8e05262225c83e38ccba1ea83f10e4b8 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 9 Oct 2015 10:34:58 +0200 Subject: [PATCH 1/6] Remove double declaration and reduce scope of pcontact In command/commands.c you declare pcontact at the top of the function. Later in one case you declare it again and use it in a small scope. And in the same function you use it again this time from the first declaration. I think you intended only declaring it one time. At first I thought about top of the function because its easier to find. Then I saw that you declare "Jid jid" not at the top too, and I think for the sake of reducing scope it is better. So I went for this approach. --- src/command/commands.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/command/commands.c b/src/command/commands.c index eb4aa03f..4fe77f90 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2012,7 +2012,6 @@ cmd_info(ProfWin *window, const char * const command, gchar **args) char *usr = args[0]; jabber_conn_status_t conn_status = jabber_get_connection_status(); - PContact pcontact = NULL; if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); @@ -2075,7 +2074,7 @@ cmd_info(ProfWin *window, const char * const command, gchar **args) if (usr_jid == NULL) { usr_jid = usr; } - pcontact = roster_get_contact(usr_jid); + PContact pcontact = roster_get_contact(usr_jid); if (pcontact) { cons_show_info(pcontact); } else { @@ -2096,7 +2095,6 @@ gboolean cmd_caps(ProfWin *window, const char * const command, gchar **args) { jabber_conn_status_t conn_status = jabber_get_connection_status(); - PContact pcontact = NULL; Occupant *occupant = NULL; if (conn_status != JABBER_CONNECTED) { @@ -2130,7 +2128,7 @@ cmd_caps(ProfWin *window, const char * const command, gchar **args) if (jid->fulljid == NULL) { cons_show("You must provide a full jid to the /caps command."); } else { - pcontact = roster_get_contact(jid->barejid); + PContact pcontact = roster_get_contact(jid->barejid); if (pcontact == NULL) { cons_show("Contact not found in roster: %s", jid->barejid); } else { @@ -2173,7 +2171,6 @@ gboolean cmd_software(ProfWin *window, const char * const command, gchar **args) { jabber_conn_status_t conn_status = jabber_get_connection_status(); - Occupant *occupant = NULL; if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); @@ -2186,7 +2183,7 @@ cmd_software(ProfWin *window, const char * const command, gchar **args) if (args[0]) { ProfMucWin *mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - occupant = muc_roster_item(mucwin->roomjid, args[0]); + Occupant *occupant = muc_roster_item(mucwin->roomjid, args[0]); if (occupant) { Jid *jid = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]); iq_send_software_version(jid->fulljid); From dd2ce7a5bfe6b854f8a54137c6bbcf536de1ddd7 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 9 Oct 2015 11:20:49 +0200 Subject: [PATCH 2/6] Reduce scope of variables in ui/core Not as important as the other one (where there was a double declaration). But for the sake of consistency. --- src/ui/core.c | 14 +++++--------- src/ui/window.c | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ui/core.c b/src/ui/core.c index ff6d90ce..13ae6cab 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2582,12 +2582,9 @@ ui_handle_room_configuration_form_error(const char * const roomjid, const char * void ui_handle_room_config_submit_result(const char * const roomjid) { - ProfWin *muc_window = NULL; - ProfWin *form_window = NULL; - int num; - if (roomjid) { - muc_window = (ProfWin*)wins_get_muc(roomjid); + ProfWin *form_window = NULL; + ProfWin *muc_window = (ProfWin*)wins_get_muc(roomjid); GString *form_recipient = g_string_new(roomjid); g_string_append(form_recipient, " config"); @@ -2595,7 +2592,7 @@ ui_handle_room_config_submit_result(const char * const roomjid) g_string_free(form_recipient, TRUE); if (form_window) { - num = wins_get_num(form_window); + int num = wins_get_num(form_window); wins_close_by_num(num); } @@ -2616,10 +2613,9 @@ void ui_handle_room_config_submit_result_error(const char * const roomjid, const char * const message) { ProfWin *console = wins_get_console(); - ProfWin *muc_window = NULL; - ProfWin *form_window = NULL; - if (roomjid) { + ProfWin *muc_window = NULL; + ProfWin *form_window = NULL; muc_window = (ProfWin*)wins_get_muc(roomjid); GString *form_recipient = g_string_new(roomjid); diff --git a/src/ui/window.c b/src/ui/window.c index 8579b02f..261b9380 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -471,12 +471,12 @@ win_clear(ProfWin *window) void win_resize(ProfWin *window) { - int subwin_cols = 0; int cols = getmaxx(stdscr); if (window->layout->type == LAYOUT_SPLIT) { ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { + int subwin_cols = 0; if (window->type == WIN_CONSOLE) { subwin_cols = win_roster_cols(); } else if (window->type == WIN_MUC) { @@ -506,11 +506,11 @@ win_update_virtual(ProfWin *window) { int rows, cols; getmaxyx(stdscr, rows, cols); - int subwin_cols = 0; if (window->layout->type == LAYOUT_SPLIT) { ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { + int subwin_cols = 0; if (window->type == WIN_MUC) { subwin_cols = win_occpuants_cols(); } else { From 4730dca546a6242b71cb9fcef1dc7d5adb1fe0a5 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 9 Oct 2015 11:24:54 +0200 Subject: [PATCH 3/6] Undefine argument list Call va_end() to correclty stop using the argument list. --- src/ui/window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ui/window.c b/src/ui/window.c index 261b9380..82073b40 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -905,6 +905,7 @@ win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim g_string_vprintf(fmt_msg, message, arg); win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str); g_string_free(fmt_msg, TRUE); + va_end(arg); } void From e434b1bbf8bd84b8478f4264bf1ced66b64f4df9 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 9 Oct 2015 11:50:21 +0200 Subject: [PATCH 4/6] Create is_notify_enabled function The same code was used on two different occasions. I put it into a function. --- src/common.c | 18 ++++++++++++++++++ src/common.h | 1 + src/main.c | 14 ++------------ src/ui/console.c | 13 +------------ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/common.c b/src/common.c index 0a314c91..c77c45c8 100644 --- a/src/common.c +++ b/src/common.c @@ -644,3 +644,21 @@ strip_arg_quotes(const char * const input) return unquoted; } + +gboolean +is_notify_enabled(void) +{ + gboolean notify_enabled = FALSE; + +#ifdef HAVE_OSXNOTIFY + notify_enabled = TRUE; +#endif +#ifdef HAVE_LIBNOTIFY + notify_enabled = TRUE; +#endif +#ifdef PLATFORM_CYGWIN + notify_enabled = TRUE; +#endif + + return notify_enabled; +} diff --git a/src/common.h b/src/common.h index a1e0226e..71977aaf 100644 --- a/src/common.h +++ b/src/common.h @@ -128,5 +128,6 @@ int get_next_available_win_num(GList *used); char* get_file_or_linked(char *loc, char *basedir); char * strip_arg_quotes(const char * const input); +gboolean is_notify_enabled(void); #endif diff --git a/src/main.c b/src/main.c index 49e1defc..32d6dd2c 100644 --- a/src/main.c +++ b/src/main.c @@ -40,6 +40,7 @@ #endif #include "profanity.h" +#include "common.h" #include "command/command.h" static gboolean disable_tls = FALSE; @@ -105,18 +106,7 @@ main(int argc, char **argv) g_print("XMPP library: libstrophe\n"); #endif - gboolean notify_enabled = FALSE; - -#ifdef HAVE_OSXNOTIFY - notify_enabled = TRUE; -#endif -#ifdef HAVE_LIBNOTIFY - notify_enabled = TRUE; -#endif -#ifdef PLATFORM_CYGWIN - notify_enabled = TRUE; -#endif - if (notify_enabled) { + if (is_notify_enabled()) { g_print("Desktop notification support: Enabled\n"); } else { g_print("Desktop notification support: Disabled\n"); diff --git a/src/ui/console.c b/src/ui/console.c index 5445a503..64b8e5a1 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1151,18 +1151,7 @@ cons_show_ui_prefs(void) void cons_notify_setting(void) { - gboolean notify_enabled = FALSE; -#ifdef HAVE_OSXNOTIFY - notify_enabled = TRUE; -#endif -#ifdef HAVE_LIBNOTIFY - notify_enabled = TRUE; -#endif -#ifdef PLATFORM_CYGWIN - notify_enabled = TRUE; -#endif - - if (notify_enabled) { + if (is_notify_enabled()) { if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) cons_show("Messages (/notify message) : ON"); else From 3b0f7e109c5c41d29635e518fc4a241cfade84a1 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 9 Oct 2015 11:58:25 +0200 Subject: [PATCH 5/6] Use consistent style for pointers --- src/chat_session.h | 16 ++++---- src/chat_state.h | 6 +-- src/common.h | 26 ++++++------- src/contact.h | 22 +++++------ src/jid.h | 10 ++--- src/log.h | 34 ++++++++-------- src/muc.h | 96 +++++++++++++++++++++++----------------------- src/resource.h | 4 +- src/roster_list.h | 44 ++++++++++----------- src/window_list.h | 38 +++++++++--------- 10 files changed, 148 insertions(+), 148 deletions(-) diff --git a/src/chat_session.h b/src/chat_session.h index f51a8341..e3372687 100644 --- a/src/chat_session.h +++ b/src/chat_session.h @@ -48,16 +48,16 @@ typedef struct chat_session_t { void chat_sessions_init(void); void chat_sessions_clear(void); -void chat_session_resource_override(const char * const barejid, const char * const resource); -ChatSession* chat_session_get(const char * const barejid); +void chat_session_resource_override(const char *const barejid, const char *const resource); +ChatSession* chat_session_get(const char *const barejid); -void chat_session_recipient_active(const char * const barejid, const char * const resource, +void chat_session_recipient_active(const char *const barejid, const char *const resource, gboolean send_states); -void chat_session_recipient_typing(const char * const barejid, const char * const resource); -void chat_session_recipient_paused(const char * const barejid, const char * const resource); -void chat_session_recipient_gone(const char * const barejid, const char * const resource); -void chat_session_recipient_inactive(const char * const barejid, const char * const resource); +void chat_session_recipient_typing(const char *const barejid, const char *const resource); +void chat_session_recipient_paused(const char *const barejid, const char *const resource); +void chat_session_recipient_gone(const char *const barejid, const char *const resource); +void chat_session_recipient_inactive(const char *const barejid, const char *const resource); -void chat_session_remove(const char * const barejid); +void chat_session_remove(const char *const barejid); #endif diff --git a/src/chat_state.h b/src/chat_state.h index 7f0d8832..00e175b3 100644 --- a/src/chat_state.h +++ b/src/chat_state.h @@ -53,9 +53,9 @@ typedef struct prof_chat_state_t { ChatState* chat_state_new(void); void chat_state_free(ChatState *state); -void chat_state_handle_idle(const char * const barejid, ChatState *state); -void chat_state_handle_typing(const char * const barejid, ChatState *state); +void chat_state_handle_idle(const char *const barejid, ChatState *state); +void chat_state_handle_typing(const char *const barejid, ChatState *state); void chat_state_active(ChatState *state); -void chat_state_gone(const char * const barejid, ChatState *state); +void chat_state_gone(const char *const barejid, ChatState *state); #endif diff --git a/src/common.h b/src/common.h index 71977aaf..3b05df29 100644 --- a/src/common.h +++ b/src/common.h @@ -98,36 +98,36 @@ gchar* p_utf8_substring(const gchar *str, glong start_pos, glong end_pos); void p_slist_free_full(GSList *items, GDestroyNotify free_func); void p_list_free_full(GList *items, GDestroyNotify free_func); gboolean p_hash_table_add(GHashTable *hash_table, gpointer key); -gboolean p_hash_table_contains(GHashTable *hash_table, gconstpointer key); +gboolean p_hash_table_contains(GHashTable *hash_table, gconstpointer key); gboolean create_dir(char *name); gboolean mkdir_recursive(const char *dir); -char * str_replace(const char *string, const char *substr, +char* str_replace(const char *string, const char *substr, const char *replacement); -gboolean str_contains_str(const char * const searchstr, const char * const substr); +gboolean str_contains_str(const char *const searchstr, const char *const substr); int str_contains(const char str[], int size, char ch); gboolean strtoi_range(char *str, int *saveptr, int min, int max, char **err_msg); -int utf8_display_len(const char * const str); -char * prof_getline(FILE *stream); +int utf8_display_len(const char *const str); +char* prof_getline(FILE *stream); char* release_get_latest(void); gboolean release_is_new(char *found_version); -gchar * xdg_get_config_home(void); -gchar * xdg_get_data_home(void); +gchar* xdg_get_config_home(void); +gchar* xdg_get_data_home(void); -gboolean valid_resource_presence_string(const char * const str); -const char * string_from_resource_presence(resource_presence_t presence); -resource_presence_t resource_presence_from_string(const char * const str); +gboolean valid_resource_presence_string(const char *const str); +const char* string_from_resource_presence(resource_presence_t presence); +resource_presence_t resource_presence_from_string(const char *const str); contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence); -char * p_sha1_hash(char *str); -char * create_unique_id(char *prefix); +char* p_sha1_hash(char *str); +char* create_unique_id(char *prefix); void reset_unique_id(void); int cmp_win_num(gconstpointer a, gconstpointer b); int get_next_available_win_num(GList *used); char* get_file_or_linked(char *loc, char *basedir); -char * strip_arg_quotes(const char * const input); +char* strip_arg_quotes(const char *const input); gboolean is_notify_enabled(void); #endif diff --git a/src/contact.h b/src/contact.h index 343b230f..a65c25df 100644 --- a/src/contact.h +++ b/src/contact.h @@ -40,11 +40,11 @@ typedef struct p_contact_t *PContact; -PContact p_contact_new(const char * const barejid, const char * const name, - GSList *groups, const char * const subscription, - const char * const offline_message, gboolean pending_out); +PContact p_contact_new(const char *const barejid, const char *const name, + GSList *groups, const char *const subscription, + const char *const offline_message, gboolean pending_out); void p_contact_add_resource(PContact contact, Resource *resource); -gboolean p_contact_remove_resource(PContact contact, const char * const resource); +gboolean p_contact_remove_resource(PContact contact, const char *const resource); void p_contact_free(PContact contact); const char* p_contact_barejid(PContact contact); const char* p_contact_barejid_collate_key(PContact contact); @@ -54,23 +54,23 @@ const char* p_contact_name_or_jid(const PContact contact); const char* p_contact_presence(PContact contact); const char* p_contact_status(PContact contact); const char* p_contact_subscription(const PContact contact); -GList * p_contact_get_available_resources(const PContact contact); +GList* p_contact_get_available_resources(const PContact contact); GDateTime* p_contact_last_activity(const PContact contact); gboolean p_contact_pending_out(const PContact contact); void p_contact_set_presence(const PContact contact, Resource *resource); -void p_contact_set_status(const PContact contact, const char * const status); -void p_contact_set_name(const PContact contact, const char * const name); -void p_contact_set_subscription(const PContact contact, const char * const subscription); +void p_contact_set_status(const PContact contact, const char *const status); +void p_contact_set_name(const PContact contact, const char *const name); +void p_contact_set_subscription(const PContact contact, const char *const subscription); void p_contact_set_pending_out(const PContact contact, gboolean pending_out); void p_contact_set_last_activity(const PContact contact, GDateTime *last_activity); gboolean p_contact_is_available(const PContact contact); gboolean p_contact_has_available_resource(const PContact contact); -Resource * p_contact_get_resource(const PContact contact, const char * const resource); +Resource* p_contact_get_resource(const PContact contact, const char *const resource); void p_contact_set_groups(const PContact contact, GSList *groups); GSList * p_contact_groups(const PContact contact); -gboolean p_contact_in_group(const PContact contact, const char * const group); +gboolean p_contact_in_group(const PContact contact, const char *const group); gboolean p_contact_subscribed(const PContact contact); -char * p_contact_create_display_string(const PContact contact, const char * const resource); +char* p_contact_create_display_string(const PContact contact, const char *const resource); Autocomplete p_contact_resource_ac(const PContact contact); void p_contact_resource_ac_reset(const PContact contact); diff --git a/src/jid.h b/src/jid.h index 6d530c5a..23095df2 100644 --- a/src/jid.h +++ b/src/jid.h @@ -48,14 +48,14 @@ struct jid_t { typedef struct jid_t Jid; -Jid * jid_create(const gchar * const str); -Jid * jid_create_from_bare_and_resource(const char * const room, const char * const nick); +Jid* jid_create(const gchar *const str); +Jid* jid_create_from_bare_and_resource(const char *const room, const char *const nick); void jid_destroy(Jid *jid); gboolean jid_is_valid_room_form(Jid *jid); -char * create_fulljid(const char * const barejid, const char * const resource); -char * get_nick_from_full_jid(const char * const full_room_jid); +char* create_fulljid(const char *const barejid, const char *const resource); +char* get_nick_from_full_jid(const char *const full_room_jid); -char * jid_fulljid_or_barejid(Jid *jid); +char* jid_fulljid_or_barejid(Jid *jid); #endif diff --git a/src/log.h b/src/log.h index 87c96df9..22bf6f30 100644 --- a/src/log.h +++ b/src/log.h @@ -54,13 +54,13 @@ void log_init(log_level_t filter); log_level_t log_get_filter(void); void log_close(void); void log_reinit(void); -char * get_log_file_location(void); -void log_debug(const char * const msg, ...); -void log_info(const char * const msg, ...); -void log_warning(const char * const msg, ...); -void log_error(const char * const msg, ...); -void log_msg(log_level_t level, const char * const area, - const char * const msg); +char* get_log_file_location(void); +void log_debug(const char *const msg, ...); +void log_info(const char *const msg, ...); +void log_warning(const char *const msg, ...); +void log_error(const char *const msg, ...); +void log_msg(log_level_t level, const char *const area, + const char *const msg); log_level_t log_level_from_string(char *log_level); void log_stderr_init(log_level_t level); @@ -69,19 +69,19 @@ void log_stderr_handler(void); void chat_log_init(void); -void chat_log_msg_out(const char * const barejid, const char * const msg); -void chat_log_otr_msg_out(const char * const barejid, const char * const msg); -void chat_log_pgp_msg_out(const char * const barejid, const char * const msg); +void chat_log_msg_out(const char *const barejid, const char *const msg); +void chat_log_otr_msg_out(const char *const barejid, const char *const msg); +void chat_log_pgp_msg_out(const char *const barejid, const char *const msg); -void chat_log_msg_in(const char * const barejid, const char * const msg, GDateTime *timestamp); -void chat_log_otr_msg_in(const char * const barejid, const char * const msg, gboolean was_decrypted, GDateTime *timestamp); -void chat_log_pgp_msg_in(const char * const barejid, const char * const msg, GDateTime *timestamp); +void chat_log_msg_in(const char *const barejid, const char *const msg, GDateTime *timestamp); +void chat_log_otr_msg_in(const char *const barejid, const char *const msg, gboolean was_decrypted, GDateTime *timestamp); +void chat_log_pgp_msg_in(const char *const barejid, const char *const msg, GDateTime *timestamp); void chat_log_close(void); -GSList * chat_log_get_previous(const gchar * const login, - const gchar * const recipient); +GSList* chat_log_get_previous(const gchar *const login, + const gchar *const recipient); void groupchat_log_init(void); -void groupchat_log_chat(const gchar * const login, const gchar * const room, - const gchar * const nick, const gchar * const msg); +void groupchat_log_chat(const gchar *const login, const gchar *const room, + const gchar *const nick, const gchar *const msg); #endif diff --git a/src/muc.h b/src/muc.h index eb636aff..73077b75 100644 --- a/src/muc.h +++ b/src/muc.h @@ -76,75 +76,75 @@ typedef struct _muc_occupant_t { void muc_init(void); void muc_close(void); -void muc_join(const char * const room, const char * const nick, const char * const password, gboolean autojoin); -void muc_leave(const char * const room); +void muc_join(const char *const room, const char *const nick, const char *const password, gboolean autojoin); +void muc_leave(const char *const room); -gboolean muc_active(const char * const room); -gboolean muc_autojoin(const char * const room); +gboolean muc_active(const char *const room); +gboolean muc_autojoin(const char *const room); GList* muc_rooms(void); -void muc_set_features(const char * const room, GSList *features); +void muc_set_features(const char *const room, GSList *features); -char* muc_nick(const char * const room); -char* muc_password(const char * const room); +char* muc_nick(const char *const room); +char* muc_password(const char *const room); -void muc_nick_change_start(const char * const room, const char * const new_nick); -void muc_nick_change_complete(const char * const room, const char * const nick); -gboolean muc_nick_change_pending(const char * const room); -char* muc_old_nick(const char * const room, const char * const new_nick); +void muc_nick_change_start(const char *const room, const char *const new_nick); +void muc_nick_change_complete(const char *const room, const char *const nick); +gboolean muc_nick_change_pending(const char *const room); +char* muc_old_nick(const char *const room, const char *const new_nick); -gboolean muc_roster_contains_nick(const char * const room, const char * const nick); -gboolean muc_roster_complete(const char * const room); -gboolean muc_roster_add(const char * const room, const char * const nick, const char * const jid, - const char * const role, const char * const affiliation, const char * const show, - const char * const status); -void muc_roster_remove(const char * const room, const char * const nick); -void muc_roster_set_complete(const char * const room); -GList * muc_roster(const char * const room); -Autocomplete muc_roster_ac(const char * const room); -Autocomplete muc_roster_jid_ac(const char * const room); -void muc_jid_autocomplete_reset(const char * const room); -void muc_jid_autocomplete_add_all(const char * const room, GSList *jids); +gboolean muc_roster_contains_nick(const char *const room, const char *const nick); +gboolean muc_roster_complete(const char *const room); +gboolean muc_roster_add(const char *const room, const char *const nick, const char *const jid, + const char *const role, const char *const affiliation, const char *const show, + const char *const status); +void muc_roster_remove(const char *const room, const char *const nick); +void muc_roster_set_complete(const char *const room); +GList* muc_roster(const char *const room); +Autocomplete muc_roster_ac(const char *const room); +Autocomplete muc_roster_jid_ac(const char *const room); +void muc_jid_autocomplete_reset(const char *const room); +void muc_jid_autocomplete_add_all(const char *const room, GSList *jids); -Occupant* muc_roster_item(const char * const room, const char * const nick); +Occupant * muc_roster_item(const char *const room, const char *const nick); gboolean muc_occupant_available(Occupant *occupant); -const char * muc_occupant_affiliation_str(Occupant *occupant); -const char * muc_occupant_role_str(Occupant *occupant); -GSList * muc_occupants_by_role(const char * const room, muc_role_t role); -GSList * muc_occupants_by_affiliation(const char * const room, muc_affiliation_t affiliation); +const char* muc_occupant_affiliation_str(Occupant *occupant); +const char* muc_occupant_role_str(Occupant *occupant); +GSList* muc_occupants_by_role(const char *const room, muc_role_t role); +GSList* muc_occupants_by_affiliation(const char *const room, muc_affiliation_t affiliation); -void muc_occupant_nick_change_start(const char * const room, const char * const new_nick, const char * const old_nick); -char* muc_roster_nick_change_complete(const char * const room, const char * const nick); +void muc_occupant_nick_change_start(const char *const room, const char *const new_nick, const char *const old_nick); +char* muc_roster_nick_change_complete(const char *const room, const char *const nick); -void muc_invites_add(const char * const room, const char * const password); -void muc_invites_remove(const char * const room); +void muc_invites_add(const char *const room, const char *const password); +void muc_invites_remove(const char *const room); gint muc_invites_count(void); GSList* muc_invites(void); -gboolean muc_invites_contain(const char * const room); +gboolean muc_invites_contain(const char *const room); void muc_invites_reset_ac(void); -char* muc_invites_find(const char * const search_str); +char* muc_invites_find(const char *const search_str); void muc_invites_clear(void); -char* muc_invite_password(const char * const room); +char* muc_invite_password(const char *const room); -void muc_set_subject(const char * const room, const char * const subject); -char* muc_subject(const char * const room); +void muc_set_subject(const char *const room, const char *const subject); +char* muc_subject(const char *const room); -void muc_pending_broadcasts_add(const char * const room, const char * const message); -GList * muc_pending_broadcasts(const char * const room); +void muc_pending_broadcasts_add(const char *const room, const char *const message); +GList* muc_pending_broadcasts(const char *const room); -char* muc_autocomplete(ProfWin *window, const char * const input); -void muc_autocomplete_reset(const char * const room); +char* muc_autocomplete(ProfWin *window, const char *const input); +void muc_autocomplete_reset(const char *const room); -gboolean muc_requires_config(const char * const room); -void muc_set_requires_config(const char * const room, gboolean val); +gboolean muc_requires_config(const char *const room); +void muc_set_requires_config(const char *const room, gboolean val); -void muc_set_role(const char * const room, const char * const role); -void muc_set_affiliation(const char * const room, const char * const affiliation); -char *muc_role_str(const char * const room); -char *muc_affiliation_str(const char * const room); +void muc_set_role(const char *const room, const char *const role); +void muc_set_affiliation(const char *const room, const char *const affiliation); +char* muc_role_str(const char *const room); +char* muc_affiliation_str(const char *const room); -muc_member_type_t muc_member_type(const char * const room); +muc_member_type_t muc_member_type(const char *const room); #endif diff --git a/src/resource.h b/src/resource.h index 43bb6d18..f45920fa 100644 --- a/src/resource.h +++ b/src/resource.h @@ -44,8 +44,8 @@ typedef struct resource_t { int priority; } Resource; -Resource * resource_new(const char * const name, resource_presence_t presence, - const char * const status, const int priority); +Resource* resource_new(const char *const name, resource_presence_t presence, + const char *const status, const int priority); void resource_destroy(Resource *resource); int resource_compare_availability(Resource *first, Resource *second); diff --git a/src/roster_list.h b/src/roster_list.h index 4417c763..2b01ea64 100644 --- a/src/roster_list.h +++ b/src/roster_list.h @@ -41,32 +41,32 @@ #include "contact.h" void roster_clear(void); -gboolean roster_update_presence(const char * const barejid, Resource *resource, +gboolean roster_update_presence(const char *const barejid, Resource *resource, GDateTime *last_activity); -PContact roster_get_contact(const char * const barejid); -gboolean roster_contact_offline(const char * const barejid, - const char * const resource, const char * const status); +PContact roster_get_contact(const char *const barejid); +gboolean roster_contact_offline(const char *const barejid, + const char *const resource, const char *const status); void roster_reset_search_attempts(void); void roster_init(void); void roster_free(void); -void roster_change_name(PContact contact, const char * const new_name); -void roster_remove(const char * const name, const char * const barejid); -void roster_update(const char * const barejid, const char * const name, - GSList *groups, const char * const subscription, gboolean pending_out); -gboolean roster_add(const char * const barejid, const char * const name, GSList *groups, - const char * const subscription, gboolean pending_out); -char * roster_barejid_from_name(const char * const name); -GSList * roster_get_contacts(void); -GSList * roster_get_contacts_online(void); +void roster_change_name(PContact contact, const char *const new_name); +void roster_remove(const char *const name, const char *const barejid); +void roster_update(const char *const barejid, const char *const name, + GSList *groups, const char *const subscription, gboolean pending_out); +gboolean roster_add(const char *const barejid, const char *const name, GSList *groups, + const char *const subscription, gboolean pending_out); +char* roster_barejid_from_name(const char *const name); +GSList* roster_get_contacts(void); +GSList* roster_get_contacts_online(void); gboolean roster_has_pending_subscriptions(void); -char * roster_contact_autocomplete(const char * const search_str); -char * roster_fulljid_autocomplete(const char * const search_str); -GSList * roster_get_group(const char * const group); -GSList * roster_get_groups(void); -char * roster_group_autocomplete(const char * const search_str); -char * roster_barejid_autocomplete(const char * const search_str); -GSList * roster_get_contacts_by_presence(const char * const presence); -GSList * roster_get_nogroup(void); -char * roster_get_msg_display_name(const char * const barejid, const char * const resource); +char* roster_contact_autocomplete(const char *const search_str); +char* roster_fulljid_autocomplete(const char *const search_str); +GSList* roster_get_group(const char *const group); +GSList* roster_get_groups(void); +char* roster_group_autocomplete(const char *const search_str); +char* roster_barejid_autocomplete(const char *const search_str); +GSList* roster_get_contacts_by_presence(const char *const presence); +GSList* roster_get_nogroup(void); +char* roster_get_msg_display_name(const char *const barejid, const char *const resource); #endif diff --git a/src/window_list.h b/src/window_list.h index 74073bd6..e3e446f4 100644 --- a/src/window_list.h +++ b/src/window_list.h @@ -39,27 +39,27 @@ void wins_init(void); -ProfWin * wins_new_xmlconsole(void); -ProfWin * wins_new_chat(const char * const barejid); -ProfWin * wins_new_muc(const char * const roomjid); -ProfWin * wins_new_muc_config(const char * const roomjid, DataForm *form); -ProfWin * wins_new_private(const char * const fulljid); +ProfWin* wins_new_xmlconsole(void); +ProfWin* wins_new_chat(const char *const barejid); +ProfWin* wins_new_muc(const char *const roomjid); +ProfWin* wins_new_muc_config(const char *const roomjid, DataForm *form); +ProfWin* wins_new_private(const char *const fulljid); -ProfWin * wins_get_console(void); -ProfChatWin *wins_get_chat(const char * const barejid); -ProfMucWin * wins_get_muc(const char * const roomjid); -ProfMucConfWin * wins_get_muc_conf(const char * const roomjid); -ProfPrivateWin *wins_get_private(const char * const fulljid); -ProfXMLWin * wins_get_xmlconsole(void); +ProfWin* wins_get_console(void); +ProfChatWin* wins_get_chat(const char *const barejid); +ProfMucWin* wins_get_muc(const char *const roomjid); +ProfMucConfWin* wins_get_muc_conf(const char *const roomjid); +ProfPrivateWin* wins_get_private(const char *const fulljid); +ProfXMLWin* wins_get_xmlconsole(void); -ProfWin * wins_get_current(void); +ProfWin* wins_get_current(void); void wins_set_current_by_num(int i); -ProfWin * wins_get_by_num(int i); +ProfWin* wins_get_by_num(int i); -ProfWin * wins_get_next(void); -ProfWin * wins_get_previous(void); +ProfWin* wins_get_next(void); +ProfWin* wins_get_previous(void); int wins_get_num(ProfWin *window); int wins_get_current_num(void); void wins_close_current(void); @@ -67,13 +67,13 @@ void wins_close_by_num(int i); gboolean wins_is_current(ProfWin *window); int wins_get_total_unread(void); void wins_resize_all(void); -GSList * wins_get_chat_recipients(void); -GSList * wins_get_prune_wins(void); +GSList* wins_get_chat_recipients(void); +GSList* wins_get_prune_wins(void); void wins_lost_connection(void); gboolean wins_tidy(void); -GSList * wins_create_summary(void); +GSList* wins_create_summary(void); void wins_destroy(void); -GList * wins_get_nums(void); +GList* wins_get_nums(void); gboolean wins_swap(int source_win, int target_win); void wins_hide_subwin(ProfWin *window); void wins_show_subwin(ProfWin *window); From 7a0e8f87b512678b725a25ba563d0db110162fa2 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 9 Oct 2015 12:49:17 +0200 Subject: [PATCH 6/6] Remove trailing whitespaces --- tests/unittests/test_common.c | 2 +- tests/unittests/ui/stub_ui.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unittests/test_common.c b/tests/unittests/test_common.c index 8df3790a..0e26b704 100644 --- a/tests/unittests/test_common.c +++ b/tests/unittests/test_common.c @@ -605,7 +605,7 @@ void strip_quotes_strips_first(void **state) char *result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); - + free(result); } diff --git a/tests/unittests/ui/stub_ui.h b/tests/unittests/ui/stub_ui.h index 81357a86..d4488c4b 100644 --- a/tests/unittests/ui/stub_ui.h +++ b/tests/unittests/ui/stub_ui.h @@ -3,4 +3,4 @@ void expect_any_cons_show(void); void expect_cons_show_error(char *expected); void expect_any_cons_show_error(void); void expect_ui_current_print_line(char *message); -void expect_ui_current_print_formatted_line(char show_char, int attrs, char *message); \ No newline at end of file +void expect_ui_current_print_formatted_line(char show_char, int attrs, char *message);