diff options
Diffstat (limited to 'src/plugins/irc')
26 files changed, 374 insertions, 752 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index 4587c6153..92c4f3d3e 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -292,8 +292,7 @@ irc_bar_item_buffer_modes (const void *pointer, void *data, "%s%s", IRC_COLOR_ITEM_CHANNEL_MODES, (modes_without_args) ? modes_without_args : channel->modes); - if (modes_without_args) - free (modes_without_args); + free (modes_without_args); return strdup (modes); } diff --git a/src/plugins/irc/irc-batch.c b/src/plugins/irc/irc-batch.c index 8ad01b90d..d0ede5db1 100644 --- a/src/plugins/irc/irc-batch.c +++ b/src/plugins/irc/irc-batch.c @@ -181,14 +181,10 @@ irc_batch_add_message (struct t_irc_server *server, const char *reference, void irc_batch_free (struct t_irc_server *server, struct t_irc_batch *batch) { - if (batch->reference) - free (batch->reference); - if (batch->parent_ref) - free (batch->parent_ref); - if (batch->type) - free (batch->type); - if (batch->parameters) - free (batch->parameters); + free (batch->reference); + free (batch->parent_ref); + free (batch->type); + free (batch->parameters); if (batch->tags) weechat_hashtable_free (batch->tags); if (batch->messages) @@ -295,17 +291,14 @@ irc_batch_process_messages (struct t_irc_server *server, free (message); free (message2); - if (command) - free (command); - if (channel) - free (channel); + free (command); + free (channel); } weechat_string_free_split (list_messages); } } - if (new_messages) - free (new_messages); + free (new_messages); } /* @@ -455,16 +448,11 @@ irc_batch_process_multiline (struct t_irc_server *server, if (text) weechat_string_dyn_concat (result, text, -1); } - if (tags) - free (tags); - if (host) - free (host); - if (command) - free (command); - if (channel) - free (channel); - if (text) - free (text); + free (tags); + free (host); + free (command); + free (channel); + free (text); } end: diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 6382fad1c..c052de77c 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -404,8 +404,7 @@ irc_channel_create_buffer (struct t_irc_server *server, end: if (buffer_props) weechat_hashtable_free (buffer_props); - if (buffer_name) - free (buffer_name); + free (buffer_name); return ptr_buffer; } @@ -587,8 +586,7 @@ irc_channel_set_buffer_title (struct t_irc_channel *channel) channel->topic, (weechat_config_boolean (irc_config_look_topic_strip_colors)) ? 0 : 1); weechat_buffer_set (channel->buffer, "title", title_color); - if (title_color) - free (title_color); + free (title_color); } else { @@ -616,8 +614,7 @@ irc_channel_set_topic (struct t_irc_channel *channel, const char *topic) && topic && topic[0] && (strcmp (channel->topic, topic) != 0)); - if (channel->topic) - free (channel->topic); + free (channel->topic); channel->topic = (topic) ? strdup (topic) : NULL; irc_channel_set_buffer_title (channel); @@ -663,9 +660,7 @@ irc_channel_set_topic_private_buffers (struct t_irc_server *server, void irc_channel_set_modes (struct t_irc_channel *channel, const char *modes) { - if (channel->modes) - free (channel->modes); - + free (channel->modes); channel->modes = (modes) ? strdup (modes) : NULL; } @@ -749,8 +744,7 @@ irc_channel_remove_account (struct t_irc_server *server, for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - if (ptr_nick->account) - free (ptr_nick->account); + free (ptr_nick->account); ptr_nick->account = NULL; } } @@ -995,8 +989,7 @@ irc_channel_nick_speaking_time_free (struct t_irc_channel *channel, return; /* free data */ - if (nick_speaking->nick) - free (nick_speaking->nick); + free (nick_speaking->nick); /* remove nick from list */ if (nick_speaking->prev_nick) @@ -1361,8 +1354,7 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel, line = weechat_hdata_move (hdata_line, line, -1); } - if (nick_to_search) - free (nick_to_search); + free (nick_to_search); weechat_hashtable_remove (channel->join_smart_filtered, nick); } @@ -1545,20 +1537,14 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel) irc_modelist_free_all (channel); /* free channel data */ - if (channel->name) - free (channel->name); - if (channel->topic) - free (channel->topic); - if (channel->modes) - free (channel->modes); - if (channel->key) - free (channel->key); + free (channel->name); + free (channel->topic); + free (channel->modes); + free (channel->key); if (channel->join_msg_received) weechat_hashtable_free (channel->join_msg_received); - if (channel->away_message) - free (channel->away_message); - if (channel->pv_remote_nick_color) - free (channel->pv_remote_nick_color); + free (channel->away_message); + free (channel->pv_remote_nick_color); if (channel->hook_autorejoin) weechat_unhook (channel->hook_autorejoin); if (channel->nicks_speaking[0]) @@ -1568,8 +1554,7 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel) irc_channel_nick_speaking_time_free_all (channel); if (channel->join_smart_filtered) weechat_hashtable_free (channel->join_smart_filtered); - if (channel->buffer_as_string) - free (channel->buffer_as_string); + free (channel->buffer_as_string); free (channel); diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c index 6ba5561d8..8c92d77ac 100644 --- a/src/plugins/irc/irc-color.c +++ b/src/plugins/irc/irc-color.c @@ -103,8 +103,7 @@ irc_color_convert_rgb2term (long rgb) info_color = weechat_info_get ("color_rgb2term", str_color); if (!info_color || !info_color[0]) { - if (info_color) - free (info_color); + free (info_color); return -1; } @@ -144,8 +143,7 @@ irc_color_convert_rgb2irc (long rgb) info_color = weechat_info_get ("color_rgb2term", str_color); if (!info_color || !info_color[0]) { - if (info_color) - free (info_color); + free (info_color); return -1; } @@ -180,8 +178,7 @@ irc_color_convert_term2irc (int color) info_color = weechat_info_get ("color_term2rgb", str_color); if (!info_color || !info_color[0]) { - if (info_color) - free (info_color); + free (info_color); return -1; } @@ -924,8 +921,7 @@ irc_color_decode_ansi_cb (void *data, const char *text) end: if (items) weechat_string_free_split (items); - if (text2) - free (text2); + free (text2); return (output) ? output : strdup (""); } @@ -956,14 +952,12 @@ irc_color_decode_ansi (const char *string, int keep_colors) ansi_regex, REG_EXTENDED) != 0) { - if (ansi_regex) - free (ansi_regex); + free (ansi_regex); free (irc_color_regex_ansi); irc_color_regex_ansi = NULL; return NULL; } - if (ansi_regex) - free (ansi_regex); + free (ansi_regex); } ansi_state.keep_colors = keep_colors; diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 05f5a90fd..b8f2099cc 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -342,8 +342,7 @@ irc_command_mode_masks (struct t_irc_server *server, modes_added++; } - if (mask) - free (mask); + free (mask); } /* send a final MODE command if some masks are remaining */ @@ -604,10 +603,8 @@ irc_command_exec_buffers (struct t_weelist *list_buffers, weechat_command ( (ptr_channel) ? ptr_channel->buffer : ptr_server->buffer, (cmd_eval) ? cmd_eval : ((cmd_vars_replaced) ? cmd_vars_replaced : command)); - if (cmd_vars_replaced) - free (cmd_vars_replaced); - if (cmd_eval) - free (cmd_eval); + free (cmd_vars_replaced); + free (cmd_eval); } weechat_hashtable_free (pointers); @@ -1113,8 +1110,7 @@ IRC_COMMAND_CALLBACK(autojoin) { irc_command_join_server (ptr_server, autojoin, 0, 0); } - if (autojoin) - free (autojoin); + free (autojoin); } return WEECHAT_RC_OK; } @@ -1161,8 +1157,7 @@ IRC_COMMAND_CALLBACK(autojoin) { if (argc < 3) { - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); WEECHAT_COMMAND_MIN_ARGS(3, "addraw"); } irc_join_add_channels_to_autojoin (ptr_server, argv_eol[2]); @@ -1231,8 +1226,7 @@ end: ptr_autojoin); } } - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); return WEECHAT_RC_OK; } @@ -1285,8 +1279,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, if (arguments) { - if (server->away_message) - free (server->away_message); + free (server->away_message); server->away_message = strdup (arguments); /* if server is connected, send away command now */ @@ -1311,8 +1304,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, (string) ? string : arguments); irc_command_me_all_channels (server, buffer); } - if (string) - free (string); + free (string); } irc_server_set_away (server, server->nick, 1); @@ -1344,8 +1336,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, _("%s: future away: %s"), IRC_PLUGIN_NAME, (string) ? string : arguments); - if (string) - free (string); + free (string); } } else @@ -1517,8 +1508,7 @@ irc_command_send_ban (struct t_irc_server *server, mode, (mask) ? mask : nick); - if (mask) - free (mask); + free (mask); } /* @@ -1829,8 +1819,7 @@ IRC_COMMAND_CALLBACK(connect) /* add server with address */ name = irc_server_get_name_without_port (argv[i]); ptr_server = irc_server_alloc ((name) ? name : argv[i]); - if (name) - free (name); + free (name); if (ptr_server) { ptr_server->temp_server = 1; @@ -2110,8 +2099,7 @@ IRC_COMMAND_CALLBACK(cycle) "PART %s", channel_name); } - if (msg) - free (msg); + free (msg); return WEECHAT_RC_OK; } @@ -2392,8 +2380,7 @@ irc_command_quit_server (struct t_irc_server *server, const char *arguments) "QUIT"); } - if (msg) - free (msg); + free (msg); } /* @@ -2664,10 +2651,8 @@ IRC_COMMAND_CALLBACK(ignore) if (irc_ignore_search (ptr_regex, server, channel)) { - if (regex) - free (regex); - if (regex2) - free (regex2); + free (regex); + free (regex2); weechat_printf (NULL, _("%s%s: ignore already exists"), weechat_prefix ("error"), IRC_PLUGIN_NAME); @@ -2676,10 +2661,8 @@ IRC_COMMAND_CALLBACK(ignore) ptr_ignore = irc_ignore_new (ptr_regex, server, channel); - if (regex) - free (regex); - if (regex2) - free (regex2); + free (regex); + free (regex2); if (ptr_ignore) { @@ -2728,8 +2711,7 @@ IRC_COMMAND_CALLBACK(ignore) irc_ignore_free (ptr_ignore); weechat_printf (NULL, _("%s: ignore \"%s\" deleted"), IRC_PLUGIN_NAME, mask); - if (mask) - free (mask); + free (mask); } else { @@ -2983,8 +2965,7 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, ptr_channel = irc_channel_search (server, pos_channel); if (ptr_channel) { - if (ptr_channel->key) - free (ptr_channel->key); + free (ptr_channel->key); ptr_channel->key = strdup (keys[i]); } else if (channel_name_lower) @@ -3008,8 +2989,7 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, 1, 1); } } - if (channel_name_lower) - free (channel_name_lower); + free (channel_name_lower); } if (pos_space) strcat (new_args, pos_space); @@ -3146,8 +3126,7 @@ irc_command_kick_channel (struct t_irc_server *server, channel_name, nick_name); } - if (msg) - free (msg); + free (msg); } /* @@ -4376,8 +4355,7 @@ irc_command_part_channel (struct t_irc_server *server, const char *channel_name, "PART %s", channel_name); } - if (msg) - free (msg); + free (msg); } /* @@ -4964,8 +4942,7 @@ IRC_COMMAND_CALLBACK(remove) ptr_channel_name, argv[index_nick], (msg_vars_replaced) ? msg_vars_replaced : argv_eol[index_nick + 1]); - if (msg_vars_replaced) - free (msg_vars_replaced); + free (msg_vars_replaced); } else { @@ -5458,8 +5435,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND)); weechat_printf (NULL, " command. . . . . . . : ('%s')", (cmd_pwd_hidden) ? cmd_pwd_hidden : IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND)); - if (cmd_pwd_hidden) - free (cmd_pwd_hidden); + free (cmd_pwd_hidden); } else { @@ -5469,8 +5445,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail) weechat_printf (NULL, " command. . . . . . . : %s'%s'", IRC_COLOR_CHAT_VALUE, (cmd_pwd_hidden) ? cmd_pwd_hidden : weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND])); - if (cmd_pwd_hidden) - free (cmd_pwd_hidden); + free (cmd_pwd_hidden); } /* autojoin_delay */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOJOIN_DELAY])) @@ -5776,8 +5751,7 @@ IRC_COMMAND_CALLBACK(server) IRC_COLOR_RESET, description); - if (description) - free (description); + free (description); /* do not connect to server after adding it */ /* @@ -6019,8 +5993,7 @@ IRC_COMMAND_CALLBACK(server) IRC_COLOR_CHAT_SERVER, (server_name) ? server_name : "???", IRC_COLOR_RESET); - if (server_name) - free (server_name); + free (server_name); return WEECHAT_RC_OK; } @@ -6352,8 +6325,7 @@ IRC_COMMAND_CALLBACK(topic) "TOPIC %s :%s", channel_name, (new_topic_color) ? new_topic_color : new_topic); - if (new_topic_color) - free (new_topic_color); + free (new_topic_color); } } else diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index 8c899c26e..7d5b6542d 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -594,8 +594,7 @@ irc_completion_channel_topic_cb (const void *pointer, void *data, weechat_completion_list_add (completion, (topic) ? topic : ptr_channel->topic, 0, WEECHAT_LIST_POS_SORT); - if (topic) - free (topic); + free (topic); } return WEECHAT_RC_OK; diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 7a8db7b10..b96235348 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -245,8 +245,7 @@ irc_config_compute_nick_colors () if (irc_server_strcasecmp (ptr_server, ptr_nick->name, ptr_server->nick) != 0) { - if (ptr_nick->color) - free (ptr_nick->color); + free (ptr_nick->color); ptr_nick->color = irc_nick_find_color (ptr_nick->name); } } @@ -1219,8 +1218,7 @@ irc_config_check_autojoin (const char *autojoin) rc = 1; end: - if (string) - free (string); + free (string); if (items) weechat_string_free_split (items); if (channels) @@ -1567,8 +1565,7 @@ irc_config_msgbuffer_create_option_cb (const void *pointer, void *data, weechat_prefix ("error"), IRC_PLUGIN_NAME, option_name, option_name); } - if (name_lower) - free (name_lower); + free (name_lower); ptr_option = weechat_config_new_option ( config_file, section, @@ -1685,8 +1682,7 @@ irc_config_ctcp_create_option_cb (const void *pointer, void *data, weechat_prefix ("error"), IRC_PLUGIN_NAME, pos_name, option_name); } - if (name_lower) - free (name_lower); + free (name_lower); ptr_option = weechat_config_new_option ( config_file, section, @@ -2999,8 +2995,7 @@ irc_config_update_cb (const void *pointer, void *data, weechat_hashtable_set (data_read, "value", new_value); changes++; } - if (new_value) - free (new_value); + free (new_value); } } diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 405bed8b3..619a16f1e 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -94,8 +94,7 @@ irc_ctcp_convert_legacy_format (const char *format) "${%s}", ctcp_legacy_vars[i]); str2 = weechat_string_replace (str, old_format, new_format); - if (str) - free (str); + free (str); str = str2; } @@ -408,14 +407,11 @@ irc_ctcp_display_reply_to_nick (struct t_irc_protocol_ctxt *ctxt, irc_color_decode (ctcp_args, 1) : NULL; irc_ctcp_display_reply_to_nick_internal (ctxt, target, ctcp_type, ctcp_args_no_colors); - if (ctcp_args_no_colors) - free (ctcp_args_no_colors); + free (ctcp_args_no_colors); } - if (ctcp_type) - free (ctcp_type); - if (ctcp_args) - free (ctcp_args); + free (ctcp_type); + free (ctcp_args); } /* @@ -496,12 +492,9 @@ irc_ctcp_reply_to_nick (struct t_irc_protocol_ctxt *ctxt, } end: - if (dup_ctcp) - free (dup_ctcp); - if (dup_ctcp_upper) - free (dup_ctcp_upper); - if (dup_args) - free (dup_args); + free (dup_ctcp); + free (dup_ctcp_upper); + free (dup_args); if (list_messages) weechat_arraylist_free (list_messages); } @@ -720,8 +713,7 @@ irc_ctcp_eval_reply (struct t_irc_server *server, const char *format) buf_uname->machine); weechat_hashtable_set (extra_vars, "osinfo", buf); } - if (buf_uname) - free (buf_uname); + free (buf_uname); } /* @@ -787,10 +779,8 @@ irc_ctcp_eval_reply (struct t_irc_server *server, const char *format) value = weechat_string_eval_expression (format, NULL, extra_vars, NULL); - if (info_version) - free (info_version); - if (info_version_git) - free (info_version_git); + free (info_version); + free (info_version_git); weechat_hashtable_free (extra_vars); @@ -1005,9 +995,7 @@ irc_ctcp_recv_dcc (struct t_irc_protocol_ctxt *ctxt, const char *arguments) WEECHAT_HOOK_SIGNAL_STRING, (void *)ctxt->irc_message); - if (filename) - free (filename); - + free (filename); free (dcc_args); } else if (strncmp (arguments, "RESUME ", 7) == 0) @@ -1151,9 +1139,7 @@ irc_ctcp_recv_dcc (struct t_irc_protocol_ctxt *ctxt, const char *arguments) WEECHAT_HOOK_SIGNAL_STRING, (void *)ctxt->irc_message); - if (filename) - free (filename); - + free (filename); free (dcc_args); } else if (strncmp (arguments, "ACCEPT ", 7) == 0) @@ -1297,9 +1283,7 @@ irc_ctcp_recv_dcc (struct t_irc_protocol_ctxt *ctxt, const char *arguments) WEECHAT_HOOK_SIGNAL_STRING, (void *)ctxt->irc_message); - if (filename) - free (filename); - + free (filename); free (dcc_args); } else if (strncmp (arguments, "CHAT ", 5) == 0) @@ -1521,8 +1505,7 @@ irc_ctcp_recv (struct t_irc_protocol_ctxt *ctxt, (pos_args) ? " " : "", (pos_args) ? pos_args : ""); } - if (nick_color) - free (nick_color); + free (nick_color); } else { diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c index 57d408ee8..4fb9d5f89 100644 --- a/src/plugins/irc/irc-ignore.c +++ b/src/plugins/irc/irc-ignore.c @@ -309,17 +309,14 @@ irc_ignore_free (struct t_irc_ignore *ignore) } /* free data */ - if (ignore->mask) - free (ignore->mask); + free (ignore->mask); if (ignore->regex_mask) { regfree (ignore->regex_mask); free (ignore->regex_mask); } - if (ignore->server) - free (ignore->server); - if (ignore->channel) - free (ignore->channel); + free (ignore->server); + free (ignore->channel); /* remove ignore from list */ if (ignore->prev_ignore) diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index cada8c375..abdee08d1 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -300,12 +300,9 @@ irc_info_info_irc_buffer_cb (const void *pointer, void *data, if (server && ptr_server && channel) ptr_channel = irc_channel_search (ptr_server, channel); - if (server) - free (server); - if (channel) - free (channel); - if (host) - free (host); + free (server); + free (channel); + free (host); if (ptr_channel) { diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c index 789b88fb7..9db3ba30a 100644 --- a/src/plugins/irc/irc-input.c +++ b/src/plugins/irc/irc-input.c @@ -165,8 +165,7 @@ irc_input_user_message_display (struct t_irc_server *server, "%sself_msg,notify_none,no_highlight,prefix_nick_%s", (ctcp_type) ? "irc_ctcp," : "", (str_color) ? str_color : "default"); - if (str_color) - free (str_color); + free (str_color); } } @@ -275,10 +274,8 @@ irc_input_user_message_display (struct t_irc_server *server, (ptr_text) ? ptr_text : ""); } - if (text2) - free (text2); - if (text_decoded) - free (text_decoded); + free (text2); + free (text_decoded); } /* @@ -406,8 +403,7 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags, free (msg); } - if (data_with_colors) - free (data_with_colors); + free (data_with_colors); } else { @@ -580,8 +576,7 @@ irc_input_send_cb (const void *pointer, void *data, weechat_command ( ptr_buffer, (data_with_colors) ? data_with_colors : ptr_message); - if (data_with_colors) - free (data_with_colors); + free (data_with_colors); } /* reset tags to use by default */ @@ -589,14 +584,10 @@ irc_input_send_cb (const void *pointer, void *data, } } - if (server) - free (server); - if (channel) - free (channel); - if (options) - free (options); - if (tags) - free (tags); + free (server); + free (channel); + free (options); + free (tags); return WEECHAT_RC_OK; } diff --git a/src/plugins/irc/irc-join.c b/src/plugins/irc/irc-join.c index 6cde2d4e1..c9e028a62 100644 --- a/src/plugins/irc/irc-join.c +++ b/src/plugins/irc/irc-join.c @@ -194,10 +194,8 @@ irc_join_compare_sort_buffer_cb (void *data, struct t_arraylist *arraylist, void irc_join_free_join_channel (struct t_irc_join_channel *join_channel) { - if (join_channel->name) - free (join_channel->name); - if (join_channel->key) - free (join_channel->key); + free (join_channel->name); + free (join_channel->key); free (join_channel); } @@ -274,8 +272,7 @@ irc_join_arraylist_add (struct t_arraylist *arraylist, { free (ptr_join_chan_exact->name); ptr_join_chan_exact->name = strdup (join_channel->name); - if (ptr_join_chan_exact->key) - free (ptr_join_chan_exact->key); + free (ptr_join_chan_exact->key); ptr_join_chan_exact->key = (join_channel->key) ? strdup (join_channel->key) : NULL; return 0; @@ -655,8 +652,7 @@ irc_join_add_channel_to_autojoin (struct t_irc_server *server, free (new_autojoin); } - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); } /* @@ -680,8 +676,7 @@ irc_join_add_channels_to_autojoin (struct t_irc_server *server, free (new_autojoin); } - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); } /* @@ -755,8 +750,7 @@ irc_join_remove_channel_from_autojoin (struct t_irc_server *server, free (new_autojoin); } - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); } /* @@ -875,8 +869,7 @@ irc_join_rename_channel_in_autojoin (struct t_irc_server *server, free (new_autojoin); } - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); } /* @@ -966,8 +959,7 @@ irc_join_sort_autojoin (struct t_irc_server *server, enum t_irc_join_sort sort) if (!old_autojoin || !old_autojoin[0]) { - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); return; } @@ -978,6 +970,5 @@ irc_join_sort_autojoin (struct t_irc_server *server, enum t_irc_join_sort sort) free (new_autojoin); } - if (old_autojoin) - free (old_autojoin); + free (old_autojoin); } diff --git a/src/plugins/irc/irc-list.c b/src/plugins/irc/irc-list.c index a176fe7c4..9806bffb3 100644 --- a/src/plugins/irc/irc-list.c +++ b/src/plugins/irc/irc-list.c @@ -101,12 +101,9 @@ irc_list_free_cb (void *data, struct t_arraylist *arraylist, void *pointer) ptr_channel = (struct t_irc_list_channel *)pointer; if (ptr_channel) { - if (ptr_channel->name) - free (ptr_channel->name); - if (ptr_channel->name2) - free (ptr_channel->name2); - if (ptr_channel->topic) - free (ptr_channel->topic); + free (ptr_channel->name); + free (ptr_channel->name2); + free (ptr_channel->topic); free (ptr_channel); } } @@ -255,8 +252,7 @@ irc_list_channel_match_filter (struct t_irc_server *server, irc_list_filter_hashtable_extra_vars, irc_list_filter_hashtable_options); match = (result && (strcmp (result, "1") == 0)) ? 1 : 0; - if (result) - free (result); + free (result); return match; } @@ -451,8 +447,7 @@ irc_list_parse_messages (struct t_irc_server *server, const char *output) weechat_arraylist_add (server->list->channels, channel); } } - if (command) - free (command); + free (command); if (params) weechat_string_free_split (params); } diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c index 0b27d66e9..d908716be 100644 --- a/src/plugins/irc/irc-message.c +++ b/src/plugins/irc/irc-message.c @@ -511,24 +511,15 @@ irc_message_parse_to_hashtable (struct t_irc_server *server, snprintf (str_pos, sizeof (str_pos), "%d", pos_text); weechat_hashtable_set (hashtable, "pos_text", str_pos); - if (tags) - free (tags); - if (message_without_tags) - free (message_without_tags); - if (nick) - free (nick); - if (user) - free (user); - if (host) - free (host); - if (command) - free (command); - if (channel) - free (channel); - if (arguments) - free (arguments); - if (text) - free (text); + free (tags); + free (message_without_tags); + free (nick); + free (user); + free (host); + free (command); + free (channel); + free (arguments); + free (text); if (params) weechat_string_free_split (params); @@ -845,14 +836,10 @@ irc_message_ignored (struct t_irc_server *server, const char *message) nick, host_no_color); - if (nick) - free (nick); - if (host) - free (host); - if (host_no_color) - free (host_no_color); - if (channel) - free (channel); + free (nick); + free (host); + free (host_no_color); + free (channel); return ignored; } @@ -1840,8 +1827,7 @@ end: arguments); } - if (tags) - free (tags); + free (tags); if (argv) weechat_string_free_split (argv); if (argv_eol) diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c index cf9103dc2..09eb0fe71 100644 --- a/src/plugins/irc/irc-mode.c +++ b/src/plugins/irc/irc-mode.c @@ -300,26 +300,21 @@ irc_mode_channel_update (struct t_irc_server *server, if (str_temp) { snprintf (str_temp, length, "%s %s", new_modes, new_args); - if (channel->modes) - free (channel->modes); + free (channel->modes); channel->modes = str_temp; } } else { - if (channel->modes) - free (channel->modes); + free (channel->modes); channel->modes = strdup (new_modes); } } end: - if (new_modes) - free (new_modes); - if (new_args) - free (new_args); - if (str_modes) - free (str_modes); + free (new_modes); + free (new_args); + free (str_modes); if (argv) weechat_string_free_split (argv); if (channel->modes && (strcmp (channel->modes, "+") == 0)) @@ -484,8 +479,7 @@ irc_mode_channel_set (struct t_irc_server *server, && ptr_arg && (strcmp (ptr_arg, "*") != 0)) { /* replace key for +k, but ignore "*" as new key */ - if (channel->key) - free (channel->key); + free (channel->key); channel->key = strdup (ptr_arg); } } diff --git a/src/plugins/irc/irc-modelist.c b/src/plugins/irc/irc-modelist.c index 72fa0ade6..c84013518 100644 --- a/src/plugins/irc/irc-modelist.c +++ b/src/plugins/irc/irc-modelist.c @@ -323,10 +323,8 @@ irc_modelist_item_free (struct t_irc_modelist *modelist, (item->next_item)->prev_item = item->prev_item; /* free item data */ - if (item->mask) - free (item->mask); - if (item->setter) - free (item->setter); + free (item->mask); + free (item->setter); free (item); modelist->items = new_items; diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index f3ee654d9..255b20620 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -250,8 +250,7 @@ irc_nick_set_host (struct t_irc_nick *nick, const char *host) } /* update the host in nick */ - if (nick->host) - free (nick->host); + free (nick->host); nick->host = (host) ? strdup (host) : NULL; } @@ -422,8 +421,7 @@ irc_nick_nicklist_add (struct t_irc_server *server, nick->prefix, irc_nick_get_prefix_color_name (server, nick->prefix[0]), 1); - if (color) - free (color); + free (color); } /* @@ -513,8 +511,7 @@ irc_nick_nicklist_set_color_all () { color = irc_nick_get_color_for_nicklist (ptr_server, ptr_nick); irc_nick_nicklist_set (ptr_channel, ptr_nick, "color", color); - if (color) - free (color); + free (color); } } } @@ -554,18 +551,12 @@ irc_nick_new_in_channel (struct t_irc_server *server, new_nick->prefix = malloc (2); if (!new_nick->name || !new_nick->prefixes || !new_nick->prefix) { - if (new_nick->name) - free (new_nick->name); - if (new_nick->host) - free (new_nick->host); - if (new_nick->account) - free (new_nick->account); - if (new_nick->realname) - free (new_nick->realname); - if (new_nick->prefixes) - free (new_nick->prefixes); - if (new_nick->prefix) - free (new_nick->prefix); + free (new_nick->name); + free (new_nick->host); + free (new_nick->account); + free (new_nick->realname); + free (new_nick->prefixes); + free (new_nick->prefix); free (new_nick); return NULL; } @@ -662,11 +653,9 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel, irc_channel_nick_speaking_rename (channel, nick->name, new_nick); /* change nickname */ - if (nick->name) - free (nick->name); + free (nick->name); nick->name = strdup (new_nick); - if (nick->color) - free (nick->color); + free (nick->color); if (nick_is_me) nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF); else @@ -789,20 +778,13 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel, channel->nicks_count--; /* free data */ - if (nick->name) - free (nick->name); - if (nick->host) - free (nick->host); - if (nick->prefixes) - free (nick->prefixes); - if (nick->prefix) - free (nick->prefix); - if (nick->account) - free (nick->account); - if (nick->realname) - free (nick->realname); - if (nick->color) - free (nick->color); + free (nick->name); + free (nick->host); + free (nick->prefixes); + free (nick->prefix); + free (nick->account); + free (nick->realname); + free (nick->color); free (nick); @@ -937,8 +919,7 @@ irc_nick_set_away (struct t_irc_server *server, struct t_irc_channel *channel, nick->away = is_away; color = irc_nick_get_color_for_nicklist (server, nick); irc_nick_nicklist_set (channel, nick, "color", color); - if (color) - free (color); + free (color); } } @@ -1021,8 +1002,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick, color, (nick) ? nick->name : nickname); - if (color) - free (color); + free (color); return result; } @@ -1060,8 +1040,7 @@ irc_nick_color_for_msg (struct t_irc_server *server, int server_message, snprintf (color[index_color], sizeof (color[index_color]), "%s", color_found); - if (color_found) - free (color_found); + free (color_found); return color[index_color]; } diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c index a5cafafbe..d1178556f 100644 --- a/src/plugins/irc/irc-notify.c +++ b/src/plugins/irc/irc-notify.c @@ -149,8 +149,7 @@ irc_notify_set_server_option (struct t_irc_server *server) str2 = realloc (str, total_length); if (!str2) { - if (str) - free (str); + free (str); return; } str = str2; @@ -298,8 +297,7 @@ irc_notify_build_message_with_nicks (struct t_irc_server *server, message2 = realloc (message, total_length); if (!message2) { - if (message) - free (message); + free (message); message = NULL; break; } @@ -352,8 +350,7 @@ irc_notify_send_monitor (struct t_irc_server *server) weechat_hashtable_free (hashtable); } } - if (message) - free (message); + free (message); } /* @@ -464,8 +461,7 @@ irc_notify_free (struct t_irc_server *server, struct t_irc_notify *notify, } free (notify->nick); } - if (notify->away_message) - free (notify->away_message); + free (notify->away_message); /* remove notify from list */ if (notify->prev_notify) @@ -667,8 +663,7 @@ irc_notify_send_signal (struct t_irc_notify *notify, (void) weechat_hook_signal_send (signal, WEECHAT_HOOK_SIGNAL_STRING, data); - if (data) - free (data); + free (data); } /* @@ -797,8 +792,7 @@ irc_notify_set_away_message (struct t_irc_notify *notify, irc_notify_send_signal (notify, "still_away", away_message); } - if (notify->away_message) - free (notify->away_message); + free (notify->away_message); notify->away_message = (away_message) ? strdup (away_message) : NULL; } @@ -1037,10 +1031,8 @@ irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal, } } } - if (irc_cmd) - free (irc_cmd); - if (arguments) - free (arguments); + free (irc_cmd); + free (arguments); } } if (!away_message_updated && !no_such_nick) @@ -1106,8 +1098,7 @@ irc_notify_timer_ison_cb (const void *pointer, void *data, int remaining_calls) weechat_hashtable_free (hashtable); } } - if (message) - free (message); + free (message); } } diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index ac1fb725d..20b6e9c31 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -189,8 +189,7 @@ irc_protocol_tags_add_cb (void *data, /* key */ str_temp = weechat_string_replace (ptr_key, ",", ";"); weechat_string_dyn_concat (str_tags, str_temp, -1); - if (str_temp) - free (str_temp); + free (str_temp); /* separator between key and value */ if (ptr_value) @@ -199,8 +198,7 @@ irc_protocol_tags_add_cb (void *data, /* value */ str_temp = weechat_string_replace (ptr_value, ",", ";"); weechat_string_dyn_concat (str_tags, str_temp, -1); - if (str_temp) - free (str_temp); + free (str_temp); } /* @@ -434,8 +432,7 @@ irc_protocol_print_error_warning_msg (struct t_irc_protocol_ctxt *ctxt, IRC_COLOR_RESET, ctxt->params[ctxt->num_params - 1]); - if (str_context) - free (str_context); + free (str_context); } /* @@ -529,8 +526,7 @@ IRC_PROTOCOL_CALLBACK(account) IRC_COLOR_MESSAGE_ACCOUNT, (pos_account) ? str_account : NULL); } - if (ptr_nick->account) - free (ptr_nick->account); + free (ptr_nick->account); ptr_nick->account = (cap_account_notify && pos_account) ? strdup (pos_account) : NULL; } @@ -623,14 +619,10 @@ IRC_PROTOCOL_CALLBACK(authenticate) (sasl_error) ? sasl_error : _("internal error")); irc_server_sendf (ctxt->server, 0, NULL, "CAP END"); } - if (sasl_username) - free (sasl_username); - if (sasl_password) - free (sasl_password); - if (sasl_key) - free (sasl_key); - if (sasl_error) - free (sasl_error); + free (sasl_username); + free (sasl_password); + free (sasl_key); + free (sasl_error); return WEECHAT_RC_OK; } @@ -699,8 +691,7 @@ IRC_PROTOCOL_CALLBACK(batch) ctxt->params[1], /* type */ str_params, ctxt->tags); - if (str_params) - free (str_params); + free (str_params); } else if (ctxt->params[0][0] == '-') { @@ -843,8 +834,7 @@ irc_protocol_cap_sync_req (struct t_irc_server *server, irc_server_sendf (server, 0, NULL, "CAP REQ :%s", ptr_caps_req); } - if (new_caps_req) - free (new_caps_req); + free (new_caps_req); } /* @@ -946,10 +936,8 @@ irc_protocol_cap_sync (struct t_irc_server *server, int sasl) weechat_string_free_split (list_caps_to_enable); } - if (str_caps_server) - free (str_caps_server); - if (caps_to_enable) - free (caps_to_enable); + free (str_caps_server); + free (caps_to_enable); if (cap_req) weechat_string_dyn_free (cap_req, 1); } @@ -1284,8 +1272,7 @@ IRC_PROTOCOL_CALLBACK(cap) "irc_cap,log3", _("%s%s: client capability, refused: %s"), weechat_prefix ("error"), IRC_PLUGIN_NAME, str_params); - if (str_params) - free (str_params); + free (str_params); if (!ctxt->server->is_connected) irc_server_sendf (ctxt->server, 0, NULL, "CAP END"); } @@ -1303,8 +1290,7 @@ IRC_PROTOCOL_CALLBACK(cap) "irc_cap,log3", _("%s%s: client capability, now available: %s"), weechat_prefix ("network"), IRC_PLUGIN_NAME, str_params); - if (str_params) - free (str_params); + free (str_params); for (i = 2; i < ctxt->num_params; i++) { caps_added = weechat_string_split ( @@ -1358,8 +1344,7 @@ IRC_PROTOCOL_CALLBACK(cap) "irc_cap,log3", _("%s%s: client capability, removed: %s"), weechat_prefix ("network"), IRC_PLUGIN_NAME, str_params); - if (str_params) - free (str_params); + free (str_params); for (i = 2; i < ctxt->num_params; i++) { caps_removed = weechat_string_split ( @@ -1529,8 +1514,7 @@ IRC_PROTOCOL_CALLBACK(error) if (str_error && (strncmp (str_error, "Closing Link", 12) == 0)) irc_server_disconnect (ctxt->server, !ctxt->server->is_connected, 1); - if (str_error) - free (str_error); + free (str_error); return WEECHAT_RC_OK; } @@ -1629,8 +1613,7 @@ IRC_PROTOCOL_CALLBACK(generic_error) str_target, str_error); - if (str_error) - free (str_error); + free (str_error); return WEECHAT_RC_OK; } @@ -2160,8 +2143,7 @@ IRC_PROTOCOL_CALLBACK(knock_reply) IRC_COLOR_RESET, str_message); - if (str_message) - free (str_message); + free (str_message); return WEECHAT_RC_OK; } @@ -2222,8 +2204,7 @@ IRC_PROTOCOL_CALLBACK(mode) IRC_COLOR_RESET, irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick), ctxt->nick); - if (modes_args) - free (modes_args); + free (modes_args); } else { @@ -2244,8 +2225,7 @@ IRC_PROTOCOL_CALLBACK(mode) irc_mode_user_set (ctxt->server, ctxt->params[1], 0); } - if (msg_modes_args) - free (msg_modes_args); + free (msg_modes_args); return WEECHAT_RC_OK; } @@ -2366,10 +2346,8 @@ IRC_PROTOCOL_CALLBACK(nick) new_color, ctxt->params[0], IRC_COLOR_RESET); - if (old_color) - free (old_color); - if (new_color) - free (new_color); + free (old_color); + free (new_color); } } break; @@ -2452,8 +2430,7 @@ IRC_PROTOCOL_CALLBACK(nick) ctxt->params[0]); } - if (old_color) - free (old_color); + free (old_color); } break; } @@ -2790,8 +2767,7 @@ IRC_PROTOCOL_CALLBACK(notice) } } } - if (channel) - free (channel); + free (channel); } free (notice_args); @@ -2949,8 +2925,7 @@ IRC_PROTOCOL_CALLBACK(part) } } - if (str_comment) - free (str_comment); + free (str_comment); return WEECHAT_RC_OK; } @@ -2973,8 +2948,7 @@ IRC_PROTOCOL_CALLBACK(ping) irc_server_sendf (ctxt->server, IRC_SERVER_SEND_OUTQ_PRIO_IMMEDIATE, NULL, "PONG :%s", str_params); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -3025,8 +2999,7 @@ IRC_PROTOCOL_CALLBACK(pong) "PONG%s%s", (str_params) ? ": " : "", (str_params) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); } return WEECHAT_RC_OK; @@ -3069,10 +3042,8 @@ irc_protocol_privmsg_display_ctcp_send (struct t_irc_protocol_ctxt *ctxt, 0); /* decode_colors */ } - if (ctcp_type) - free (ctcp_type); - if (ctcp_args) - free (ctcp_args); + free (ctcp_type); + free (ctcp_args); } /* @@ -3205,14 +3176,12 @@ IRC_PROTOCOL_CALLBACK(privmsg) color = irc_nick_find_color_name ( (ptr_nick) ? ptr_nick->name : ctxt->nick); str_color = irc_color_for_tags (color); - if (color) - free (color); + free (color); snprintf (str_tags, sizeof (str_tags), "notify_message,prefix_nick_%s", (str_color) ? str_color : "default"); } - if (str_color) - free (str_color); + free (str_color); weechat_printf_datetime_tags ( ptr_channel->buffer, ctxt->date, @@ -3318,8 +3287,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) { color = irc_nick_find_color_name (ctxt->nick); str_color = irc_color_for_tags (color); - if (color) - free (color); + free (color); } else { @@ -3343,8 +3311,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) (pv_tags && pv_tags[0]) ? "," : "", (str_color) ? str_color : "default"); } - if (str_color) - free (str_color); + free (str_color); msg_args2 = (ctxt->nick_is_me) ? irc_message_hide_password (ctxt->server, remote_nick, msg_args) : NULL; if (ctxt->nick_is_me && !ptr_channel) @@ -3376,8 +3343,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) ctxt->nick)), (msg_args2) ? msg_args2 : msg_args); } - if (msg_args2) - free (msg_args2); + free (msg_args2); if (ptr_channel && ptr_channel->has_quit_server) ptr_channel->has_quit_server = 0; @@ -3388,8 +3354,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) } end: - if (msg_args) - free (msg_args); + free (msg_args); return WEECHAT_RC_OK; } @@ -3519,8 +3484,7 @@ IRC_PROTOCOL_CALLBACK(quit) } } - if (str_quit_msg) - free (str_quit_msg); + free (str_quit_msg); return WEECHAT_RC_OK; } @@ -3618,8 +3582,7 @@ IRC_PROTOCOL_CALLBACK(setname) } if (setname_enabled) { - if (ptr_nick->realname) - free (ptr_nick->realname); + free (ptr_nick->realname); ptr_nick->realname = strdup (str_realname); } } @@ -3644,8 +3607,7 @@ IRC_PROTOCOL_CALLBACK(setname) IRC_COLOR_RESET); } - if (realname_color) - free (realname_color); + free (realname_color); free (str_realname); @@ -3744,8 +3706,7 @@ IRC_PROTOCOL_CALLBACK(server_mode_reason) (str_params && str_params[0]) ? ": " : "", (str_params && str_params[0]) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -3854,8 +3815,7 @@ IRC_PROTOCOL_CALLBACK(topic) IRC_COLOR_TOPIC_NEW, (topic_color) ? topic_color : str_topic, IRC_COLOR_RESET); - if (old_topic_color) - free (old_topic_color); + free (old_topic_color); } else { @@ -3877,8 +3837,7 @@ IRC_PROTOCOL_CALLBACK(topic) (topic_color) ? topic_color : str_topic, IRC_COLOR_RESET); } - if (topic_color) - free (topic_color); + free (topic_color); } else { @@ -3906,8 +3865,7 @@ IRC_PROTOCOL_CALLBACK(topic) IRC_COLOR_TOPIC_OLD, (old_topic_color) ? old_topic_color : ptr_channel->topic, IRC_COLOR_RESET); - if (old_topic_color) - free (old_topic_color); + free (old_topic_color); } else { @@ -3934,8 +3892,7 @@ IRC_PROTOCOL_CALLBACK(topic) (str_topic && str_topic[0]) ? str_topic : NULL); } - if (str_topic) - free (str_topic); + free (str_topic); return WEECHAT_RC_OK; } @@ -3978,8 +3935,7 @@ IRC_PROTOCOL_CALLBACK(wallops) (nick_address[0]) ? nick_address : "?", str_message); - if (str_message) - free (str_message); + free (str_message); return WEECHAT_RC_OK; } @@ -4061,8 +4017,7 @@ IRC_PROTOCOL_CALLBACK(001) "MODE %s %s", ctxt->server->nick, usermode); } - if (usermode) - free (usermode); + free (usermode); /* execute command when connected */ if (IRC_SERVER_OPTION_INTEGER(ctxt->server, IRC_SERVER_OPTION_COMMAND_DELAY) > 0) @@ -4162,15 +4117,13 @@ IRC_PROTOCOL_CALLBACK(005) else if (strncmp (ctxt->params[i], "CHANTYPES=", 10) == 0) { /* save chantypes */ - if (ctxt->server->chantypes) - free (ctxt->server->chantypes); + free (ctxt->server->chantypes); ctxt->server->chantypes = strdup (ctxt->params[i] + 10); } else if (strncmp (ctxt->params[i], "CHANMODES=", 10) == 0) { /* save chanmodes */ - if (ctxt->server->chanmodes) - free (ctxt->server->chanmodes); + free (ctxt->server->chanmodes); ctxt->server->chanmodes = strdup (ctxt->params[i] + 10); } else if (strncmp (ctxt->params[i], "MONITOR=", 8) == 0) @@ -4213,8 +4166,7 @@ IRC_PROTOCOL_CALLBACK(005) ctxt->server->isupport = strdup (str_info); } } - if (str_info) - free (str_info); + free (str_info); return WEECHAT_RC_OK; } @@ -4246,8 +4198,7 @@ IRC_PROTOCOL_CALLBACK(008) IRC_COLOR_RESET, str_params); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -4285,8 +4236,7 @@ IRC_PROTOCOL_CALLBACK(221) if (irc_server_strcasecmp (ctxt->server, ctxt->params[0], ctxt->server->nick) == 0) irc_mode_user_set (ctxt->server, str_modes, 1); - if (str_modes) - free (str_modes); + free (str_modes); return WEECHAT_RC_OK; } @@ -4340,8 +4290,7 @@ IRC_PROTOCOL_CALLBACK(301) str_away_msg); if (ptr_channel) { - if (ptr_channel->away_message) - free (ptr_channel->away_message); + free (ptr_channel->away_message); ptr_channel->away_message = strdup (str_away_msg); } } @@ -4376,8 +4325,7 @@ IRC_PROTOCOL_CALLBACK(303) IRC_COLOR_CHAT_NICK, str_nicks); - if (str_nicks) - free (str_nicks); + free (str_nicks); return WEECHAT_RC_OK; } @@ -4407,8 +4355,7 @@ IRC_PROTOCOL_CALLBACK(305) "%s%s", weechat_prefix ("network"), str_away_msg); - if (str_away_msg) - free (str_away_msg); + free (str_away_msg); } ctxt->server->is_away = 0; @@ -4444,8 +4391,7 @@ IRC_PROTOCOL_CALLBACK(306) "%s%s", weechat_prefix ("network"), str_away_msg); - if (str_away_msg) - free (str_away_msg); + free (str_away_msg); } ctxt->server->is_away = 1; @@ -4489,8 +4435,7 @@ IRC_PROTOCOL_CALLBACK(whois_nick_msg) IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, str_params); - if (str_params) - free (str_params); + free (str_params); } else { @@ -4534,8 +4479,7 @@ IRC_PROTOCOL_CALLBACK(whowas_nick_msg) IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, str_params); - if (str_params) - free (str_params); + free (str_params); } else { @@ -4587,8 +4531,7 @@ IRC_PROTOCOL_CALLBACK(311) IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, str_realname); - if (str_realname) - free (str_realname); + free (str_realname); } return WEECHAT_RC_OK; @@ -4632,8 +4575,7 @@ IRC_PROTOCOL_CALLBACK(312) IRC_COLOR_RESET, str_server, IRC_COLOR_CHAT_DELIMITERS); - if (str_server) - free (str_server); + free (str_server); } return WEECHAT_RC_OK; @@ -4677,8 +4619,7 @@ IRC_PROTOCOL_CALLBACK(314) IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, str_realname); - if (str_realname) - free (str_realname); + free (str_realname); } return WEECHAT_RC_OK; @@ -4720,8 +4661,7 @@ IRC_PROTOCOL_CALLBACK(315) IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, str_text); - if (str_text) - free (str_text); + free (str_text); } return WEECHAT_RC_OK; @@ -4848,8 +4788,7 @@ IRC_PROTOCOL_CALLBACK(321) (str_params && str_params[0]) ? " " : "", (str_params && str_params[0]) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -4888,8 +4827,7 @@ IRC_PROTOCOL_CALLBACK(322) IRC_COLOR_RESET, (str_topic && str_topic[0]) ? ": " : "", (str_topic && str_topic[0]) ? str_topic : ""); - if (str_topic) - free (str_topic); + free (str_topic); } return WEECHAT_RC_OK; @@ -4919,8 +4857,7 @@ IRC_PROTOCOL_CALLBACK(323) weechat_prefix ("network"), str_params); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -4978,10 +4915,8 @@ IRC_PROTOCOL_CALLBACK(324) if (ptr_channel) weechat_hashtable_set (ptr_channel->join_msg_received, ctxt->command, "1"); - if (str_modes) - free (str_modes); - if (str_modes_args) - free (str_modes_args); + free (str_modes); + free (str_modes_args); return WEECHAT_RC_OK; } @@ -5051,8 +4986,7 @@ IRC_PROTOCOL_CALLBACK(327) ctxt->params[3]); } - if (str_realname) - free (str_realname); + free (str_realname); } return WEECHAT_RC_OK; @@ -5088,8 +5022,7 @@ IRC_PROTOCOL_CALLBACK(328) ctxt->params[1], IRC_COLOR_RESET, str_url); - if (str_url) - free (str_url); + free (str_url); } return WEECHAT_RC_OK; @@ -5189,8 +5122,7 @@ IRC_PROTOCOL_CALLBACK(330_343) str_text, irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[2]), ctxt->params[2]); - if (str_text) - free (str_text); + free (str_text); } else { @@ -5212,8 +5144,7 @@ IRC_PROTOCOL_CALLBACK(330_343) IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, str_text); - if (str_text) - free (str_text); + free (str_text); } return WEECHAT_RC_OK; @@ -5277,8 +5208,7 @@ IRC_PROTOCOL_CALLBACK(332) NULL : irc_color_decode (str_topic, 0); irc_channel_set_topic (ptr_channel, (topic_no_color) ? topic_no_color : str_topic); - if (topic_no_color) - free (topic_no_color); + free (topic_no_color); } ptr_buffer = ptr_channel->buffer; } @@ -5313,14 +5243,12 @@ IRC_PROTOCOL_CALLBACK(332) IRC_COLOR_RESET); } - if (topic_color) - free (topic_color); + free (topic_color); if (ptr_channel) weechat_hashtable_set (ptr_channel->join_msg_received, ctxt->command, "1"); - if (str_topic) - free (str_topic); + free (str_topic); return WEECHAT_RC_OK; } @@ -5488,8 +5416,7 @@ IRC_PROTOCOL_CALLBACK(338) str_text, IRC_COLOR_CHAT_HOST, ctxt->params[2]); - if (str_text) - free (str_text); + free (str_text); } return WEECHAT_RC_OK; @@ -5563,8 +5490,7 @@ IRC_PROTOCOL_CALLBACK(344) IRC_COLOR_RESET, IRC_COLOR_CHAT_HOST, str_host); - if (str_host) - free (str_host); + free (str_host); } else { @@ -5592,8 +5518,7 @@ IRC_PROTOCOL_CALLBACK(344) (ctxt->num_params >= 4) ? " (" : "", (ctxt->num_params >= 4) ? ctxt->params[2] : "", (ctxt->num_params >= 4) ? ")" : ""); - if (str_params) - free (str_params); + free (str_params); } else { @@ -5632,8 +5557,7 @@ IRC_PROTOCOL_CALLBACK(345) IRC_COLOR_RESET, str_params); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -5810,8 +5734,7 @@ IRC_PROTOCOL_CALLBACK(347) (str_params) ? " " : "", (str_params) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -5989,8 +5912,7 @@ IRC_PROTOCOL_CALLBACK(349) (str_params) ? " " : "", (str_params) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -6044,8 +5966,7 @@ IRC_PROTOCOL_CALLBACK(350) str_host, IRC_COLOR_RESET, str_params); - if (str_params) - free (str_params); + free (str_params); } else @@ -6087,8 +6008,7 @@ IRC_PROTOCOL_CALLBACK(351) ctxt->params[1], ctxt->params[2], str_params); - if (str_params) - free (str_params); + free (str_params); } else { @@ -6176,8 +6096,7 @@ IRC_PROTOCOL_CALLBACK(352) /* update realname in nick */ if (ptr_channel && ptr_nick && str_realname) { - if (ptr_nick->realname) - free (ptr_nick->realname); + free (ptr_nick->realname); ptr_nick->realname = strdup (str_realname); } @@ -6214,10 +6133,8 @@ IRC_PROTOCOL_CALLBACK(352) IRC_COLOR_CHAT_DELIMITERS); } - if (str_hopcount) - free (str_hopcount); - if (str_realname) - free (str_realname); + free (str_hopcount); + free (str_realname); return WEECHAT_RC_OK; } @@ -6339,8 +6256,7 @@ IRC_PROTOCOL_CALLBACK(353) { color = irc_nick_find_color (nickname); weechat_string_dyn_concat (str_nicks, color, -1); - if (color) - free (color); + free (color); } } else @@ -6351,8 +6267,7 @@ IRC_PROTOCOL_CALLBACK(353) } free (nickname); } - if (prefixes) - free (prefixes); + free (prefixes); } if (!ptr_channel && str_nicks) @@ -6374,8 +6289,7 @@ IRC_PROTOCOL_CALLBACK(353) IRC_COLOR_CHAT_DELIMITERS); } - if (str_params) - free (str_params); + free (str_params); if (str_nicks) weechat_string_dyn_free (str_nicks, 1); if (nicks) @@ -6427,8 +6341,7 @@ IRC_PROTOCOL_CALLBACK(354) IRC_COLOR_RESET, (str_params && str_params[0]) ? " " : "", (str_params && str_params[0]) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); } return WEECHAT_RC_OK; } @@ -6459,8 +6372,7 @@ IRC_PROTOCOL_CALLBACK(354) /* update account in nick */ if (ptr_nick) { - if (ptr_nick->account) - free (ptr_nick->account); + free (ptr_nick->account); if (ptr_channel && weechat_hashtable_has_key (ctxt->server->cap_list, "account-notify")) { @@ -6475,8 +6387,7 @@ IRC_PROTOCOL_CALLBACK(354) /* update realname in nick */ if (ptr_nick) { - if (ptr_nick->realname) - free (ptr_nick->realname); + free (ptr_nick->realname); ptr_nick->realname = (ptr_channel && (ctxt->num_params >= 10)) ? strdup (ctxt->params[9]) : NULL; } @@ -6630,8 +6541,7 @@ irc_protocol_get_string_channel_nicks (struct t_irc_server *server, { color = irc_nick_find_color (nickname); weechat_string_dyn_concat (str_nicks, color, -1); - if (color) - free (color); + free (color); } } else @@ -6857,8 +6767,7 @@ IRC_PROTOCOL_CALLBACK(366) ctxt->params[1], IRC_COLOR_RESET, str_params); - if (str_params) - free (str_params); + free (str_params); } if (ptr_channel) @@ -7049,8 +6958,7 @@ IRC_PROTOCOL_CALLBACK(368) (str_params) ? " " : "", (str_params) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -7264,8 +7172,7 @@ IRC_PROTOCOL_CALLBACK(438) str_params, ctxt->params[0], ctxt->params[1]); - if (str_params) - free (str_params); + free (str_params); } else { @@ -7323,8 +7230,7 @@ IRC_PROTOCOL_CALLBACK(470) buffer_name = irc_buffer_build_name (ctxt->server->name, ctxt->params[2]); weechat_buffer_set (ptr_buffer, "name", buffer_name); weechat_buffer_set (ptr_buffer, "localvar_set_channel", ctxt->params[2]); - if (buffer_name) - free (buffer_name); + free (buffer_name); /* * check if logger backlog should be displayed for the new channel @@ -7425,8 +7331,7 @@ IRC_PROTOCOL_CALLBACK(help) weechat_prefix ("network"), str_message); - if (str_message) - free (str_message); + free (str_message); return WEECHAT_RC_OK; } @@ -7477,8 +7382,7 @@ IRC_PROTOCOL_CALLBACK(710) (str_message && str_message[0]) ? str_message : _("has asked for an invite")); - if (str_message) - free (str_message); + free (str_message); return WEECHAT_RC_OK; } @@ -7660,8 +7564,7 @@ IRC_PROTOCOL_CALLBACK(729) (str_params) ? " " : "", (str_params) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -7718,8 +7621,7 @@ IRC_PROTOCOL_CALLBACK(730) weechat_string_free_split (nicks); } - if (str_nicks) - free (str_nicks); + free (str_nicks); return WEECHAT_RC_OK; } @@ -7776,8 +7678,7 @@ IRC_PROTOCOL_CALLBACK(731) weechat_string_free_split (nicks); } - if (str_nicks) - free (str_nicks); + free (str_nicks); return WEECHAT_RC_OK; } @@ -7808,8 +7709,7 @@ IRC_PROTOCOL_CALLBACK(732) weechat_prefix ("network"), (str_nicks) ? str_nicks : ""); - if (str_nicks) - free (str_nicks); + free (str_nicks); return WEECHAT_RC_OK; } @@ -7840,8 +7740,7 @@ IRC_PROTOCOL_CALLBACK(733) weechat_prefix ("network"), (str_params) ? str_params : ""); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -7873,8 +7772,7 @@ IRC_PROTOCOL_CALLBACK(734) (str_params) ? str_params : "", ctxt->params[1]); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -7927,8 +7825,7 @@ IRC_PROTOCOL_CALLBACK(900) irc_server_free_sasl_data (ctxt->server); - if (str_params) - free (str_params); + free (str_params); return WEECHAT_RC_OK; } @@ -8469,13 +8366,9 @@ irc_protocol_recv_command (struct t_irc_server *server, irc_message, NULL); end: - if (address) - free (address); - if (host) - free (host); - if (host_no_color) - free (host_no_color); - if (message_colors_decoded) - free (message_colors_decoded); + free (address); + free (host); + free (host_no_color); + free (message_colors_decoded); irc_protocol_ctxt_free_data (&ctxt); } diff --git a/src/plugins/irc/irc-raw.c b/src/plugins/irc/irc-raw.c index 8b87e2145..7aac2d54f 100644 --- a/src/plugins/irc/irc-raw.c +++ b/src/plugins/irc/irc-raw.c @@ -125,8 +125,7 @@ irc_raw_message_match_filter (struct t_irc_raw_message *raw_message, match = (result && (strcmp (result, "1") == 0)) ? 1 : 0; if (hashtable) weechat_hashtable_free (hashtable); - if (result) - free (result); + free (result); return match; } else if (strncmp (filter, "s:", 2) == 0) @@ -177,8 +176,7 @@ irc_raw_message_match_filter (struct t_irc_raw_message *raw_message, NULL); /* pos_text */ match = (command && (weechat_strcasecmp (command, filter + 2) == 0)) ? 1 : 0; - if (command) - free (command); + free (command); return match; } else @@ -309,10 +307,8 @@ irc_raw_message_print (struct t_irc_raw_message *raw_message) prefix, (buf2) ? buf2 : ((buf) ? buf : raw_message->message)); - if (buf) - free (buf); - if (buf2) - free (buf2); + free (buf); + free (buf2); } /* @@ -441,8 +437,7 @@ irc_raw_open (int switch_to_buffer) void irc_raw_set_filter (const char *filter) { - if (irc_raw_filter) - free (irc_raw_filter); + free (irc_raw_filter); irc_raw_filter = (filter && (strcmp (filter, "*") != 0)) ? strdup (filter) : NULL; irc_raw_set_localvar_filter (); @@ -487,8 +482,7 @@ irc_raw_message_free (struct t_irc_raw_message *raw_message) (raw_message->next_message)->prev_message = raw_message->prev_message; /* free data */ - if (raw_message->message) - free (raw_message->message); + free (raw_message->message); free (raw_message); diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c index ae417e089..69b04e2c3 100644 --- a/src/plugins/irc/irc-redirect.c +++ b/src/plugins/irc/irc-redirect.c @@ -362,14 +362,10 @@ irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern) (redirect_pattern->next_redirect)->prev_redirect = redirect_pattern->prev_redirect; /* free data */ - if (redirect_pattern->name) - free (redirect_pattern->name); - if (redirect_pattern->cmd_start) - free (redirect_pattern->cmd_start); - if (redirect_pattern->cmd_stop) - free (redirect_pattern->cmd_stop); - if (redirect_pattern->cmd_extra) - free (redirect_pattern->cmd_extra); + free (redirect_pattern->name); + free (redirect_pattern->cmd_start); + free (redirect_pattern->cmd_stop); + free (redirect_pattern->cmd_extra); free (redirect_pattern); @@ -977,14 +973,10 @@ irc_redirect_free (struct t_irc_redirect *redirect) } /* free data */ - if (redirect->pattern) - free (redirect->pattern); - if (redirect->signal) - free (redirect->signal); - if (redirect->string) - free (redirect->string); - if (redirect->command) - free (redirect->command); + free (redirect->pattern); + free (redirect->signal); + free (redirect->string); + free (redirect->command); if (redirect->cmd_start) weechat_hashtable_free (redirect->cmd_start); if (redirect->cmd_stop) @@ -993,8 +985,7 @@ irc_redirect_free (struct t_irc_redirect *redirect) weechat_hashtable_free (redirect->cmd_extra); if (redirect->cmd_filter) weechat_hashtable_free (redirect->cmd_filter); - if (redirect->output) - free (redirect->output); + free (redirect->output); free (redirect); diff --git a/src/plugins/irc/irc-sasl.c b/src/plugins/irc/irc-sasl.c index 9ae598c8a..6c5343fe2 100644 --- a/src/plugins/irc/irc-sasl.c +++ b/src/plugins/irc/irc-sasl.c @@ -165,8 +165,7 @@ irc_sasl_mechanism_scram (struct t_irc_server *server, { snprintf (string, length + 1, "n,,n=%s,r=%s", username2, nonce_client_base64); - if (server->sasl_scram_client_first) - free (server->sasl_scram_client_first); + free (server->sasl_scram_client_first); server->sasl_scram_client_first = strdup (string + 3); } } @@ -191,14 +190,12 @@ irc_sasl_mechanism_scram (struct t_irc_server *server, { if (strncmp (attrs[i], "r=", 2) == 0) { - if (nonce_server) - free (nonce_server); + free (nonce_server); nonce_server = strdup (attrs[i] + 2); } else if (strncmp (attrs[i], "s=", 2) == 0) { - if (salt_base64) - free (salt_base64); + free (salt_base64); salt_base64 = strdup (attrs[i] + 2); } else if (strncmp (attrs[i], "i=", 2) == 0) @@ -210,14 +207,12 @@ irc_sasl_mechanism_scram (struct t_irc_server *server, } else if (strncmp (attrs[i], "v=", 2) == 0) { - if (verifier_base64) - free (verifier_base64); + free (verifier_base64); verifier_base64 = strdup (attrs[i] + 2); } else if (strncmp (attrs[i], "e=", 2) == 0) { - if (attr_error) - free (attr_error); + free (attr_error); attr_error = strdup (attrs[i] + 2); } } @@ -304,8 +299,7 @@ irc_sasl_mechanism_scram (struct t_irc_server *server, salted_password, &salted_password_size)) goto crypto_error; - if (server->sasl_scram_salted_pwd) - free (server->sasl_scram_salted_pwd); + free (server->sasl_scram_salted_pwd); server->sasl_scram_salted_pwd = malloc (salted_password_size); if (!server->sasl_scram_salted_pwd) goto memory_error; @@ -350,8 +344,7 @@ irc_sasl_mechanism_scram (struct t_irc_server *server, auth_no_proof); if ((rc < 0) || (rc >= length)) goto memory_error; - if (server->sasl_scram_auth_message) - free (server->sasl_scram_auth_message); + free (server->sasl_scram_auth_message); server->sasl_scram_auth_message = strdup (auth_message); /* RFC: ClientSignature := HMAC(StoredKey, AuthMessage) */ if (!weechat_crypto_hmac (stored_key, @@ -434,32 +427,20 @@ end: } } - if (string) - free (string); - if (username) - free (username); - if (username2) - free (username2); - if (data) - free (data); + free (string); + free (username); + free (username2); + free (data); if (attrs) weechat_string_free_split (attrs); - if (nonce_server) - free (nonce_server); - if (salt_base64) - free (salt_base64); - if (salt) - free (salt); - if (verifier_base64) - free (verifier_base64); - if (verifier) - free (verifier); - if (attr_error) - free (attr_error); - if (auth_no_proof) - free (auth_no_proof); - if (auth_message) - free (auth_message); + free (nonce_server); + free (salt_base64); + free (salt); + free (verifier_base64); + free (verifier); + free (attr_error); + free (auth_no_proof); + free (auth_message); return answer_base64; } @@ -506,8 +487,7 @@ irc_sasl_get_key_content (const char *sasl_key, char **sasl_error) *sasl_error = strdup (str_error); } - if (key_path) - free (key_path); + free (key_path); return content; } @@ -699,8 +679,7 @@ irc_sasl_mechanism_ecdsa_nist256p_challenge (struct t_irc_server *server, } } - if (string) - free (string); + free (string); return answer_base64; diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index d403b714d..c127f1013 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -445,8 +445,7 @@ irc_server_eval_fingerprint (struct t_irc_server *server) weechat_prefix ("error"), IRC_PLUGIN_NAME, server->name); - if (fingerprint_eval) - free (fingerprint_eval); + free (fingerprint_eval); return NULL; } @@ -494,8 +493,7 @@ irc_server_eval_fingerprint (struct t_irc_server *server) IRC_PLUGIN_NAME, server->name, (str_sizes) ? str_sizes : "?"); - if (str_sizes) - free (str_sizes); + free (str_sizes); free (fingerprint_eval); return NULL; case -2: /* invalid content */ @@ -571,12 +569,9 @@ irc_server_sasl_enabled (struct t_irc_server *server) || (sasl_username && sasl_username[0] && sasl_password && sasl_password[0])) ? 1 : 0; - if (sasl_username) - free (sasl_username); - if (sasl_password) - free (sasl_password); - if (sasl_key) - free (sasl_key); + free (sasl_username); + free (sasl_password); + free (sasl_key); return rc; } @@ -858,8 +853,7 @@ irc_server_set_nicks (struct t_irc_server *server, const char *nicks) 0, &server->nicks_count); - if (nicks2) - free (nicks2); + free (nicks2); } /* @@ -879,8 +873,7 @@ irc_server_set_nick (struct t_irc_server *server, const char *nick) } /* update the nick in server */ - if (server->nick) - free (server->nick); + free (server->nick); server->nick = (nick) ? strdup (nick) : NULL; /* set local variable "nick" for server and all channels/pv */ @@ -913,8 +906,7 @@ irc_server_set_host (struct t_irc_server *server, const char *host) } /* update the nick host in server */ - if (server->host) - free (server->host); + free (server->host); server->host = (host) ? strdup (host) : NULL; /* set local variable "host" for server and all channels/pv */ @@ -1569,8 +1561,7 @@ irc_server_get_default_msg (const char *default_msg, version = weechat_info_get ("version", ""); res = weechat_string_replace (default_msg, "%v", (version) ? version : ""); - if (version) - free (version); + free (version); return res; } @@ -2205,14 +2196,10 @@ irc_server_outqueue_free (struct t_irc_server *server, (outqueue->next_outqueue)->prev_outqueue = outqueue->prev_outqueue; /* free data */ - if (outqueue->command) - free (outqueue->command); - if (outqueue->message_before_mod) - free (outqueue->message_before_mod); - if (outqueue->message_after_mod) - free (outqueue->message_after_mod); - if (outqueue->tags) - free (outqueue->tags); + free (outqueue->command); + free (outqueue->message_before_mod); + free (outqueue->message_after_mod); + free (outqueue->tags); free (outqueue); /* set new head */ @@ -2303,20 +2290,14 @@ irc_server_free_data (struct t_irc_server *server) if (server->options[i]) weechat_config_option_free (server->options[i]); } - if (server->name) - free (server->name); - if (server->addresses_eval) - free (server->addresses_eval); + free (server->name); + free (server->addresses_eval); if (server->addresses_array) weechat_string_free_split (server->addresses_array); - if (server->ports_array) - free (server->ports_array); - if (server->retry_array) - free (server->retry_array); - if (server->current_address) - free (server->current_address); - if (server->current_ip) - free (server->current_ip); + free (server->ports_array); + free (server->retry_array); + free (server->current_address); + free (server->current_ip); if (server->hook_connect) weechat_unhook (server->hook_connect); if (server->hook_fd) @@ -2328,36 +2309,25 @@ irc_server_free_data (struct t_irc_server *server) if (server->hook_timer_anti_flood) weechat_unhook (server->hook_timer_anti_flood); irc_server_free_sasl_data (server); - if (server->unterminated_message) - free (server->unterminated_message); + free (server->unterminated_message); if (server->nicks_array) weechat_string_free_split (server->nicks_array); - if (server->nick) - free (server->nick); - if (server->nick_modes) - free (server->nick_modes); - if (server->host) - free (server->host); + free (server->nick); + free (server->nick_modes); + free (server->host); if (server->cap_ls) weechat_hashtable_free (server->cap_ls); if (server->cap_list) weechat_hashtable_free (server->cap_list); - if (server->isupport) - free (server->isupport); - if (server->prefix_modes) - free (server->prefix_modes); - if (server->prefix_chars) - free (server->prefix_chars); - if (server->chantypes) - free (server->chantypes); - if (server->chanmodes) - free (server->chanmodes); - if (server->clienttagdeny) - free (server->clienttagdeny); + free (server->isupport); + free (server->prefix_modes); + free (server->prefix_chars); + free (server->chantypes); + free (server->chanmodes); + free (server->clienttagdeny); if (server->clienttagdeny_array) weechat_string_free_split (server->clienttagdeny_array); - if (server->away_message) - free (server->away_message); + free (server->away_message); if (server->cmd_list_regexp) { regfree (server->cmd_list_regexp); @@ -2365,8 +2335,7 @@ irc_server_free_data (struct t_irc_server *server) } if (server->list) irc_list_free (server); - if (server->buffer_as_string) - free (server->buffer_as_string); + free (server->buffer_as_string); } /* @@ -2548,8 +2517,7 @@ irc_server_rename (struct t_irc_server *server, const char *new_name) } /* rename server */ - if (server->name) - free (server->name); + free (server->name); server->name = strdup (new_name); /* change name and local variables on buffers */ @@ -2563,8 +2531,7 @@ irc_server_rename (struct t_irc_server *server, const char *new_name) weechat_buffer_set (ptr_channel->buffer, "name", buffer_name); weechat_buffer_set (ptr_channel->buffer, "localvar_set_server", server->name); - if (buffer_name) - free (buffer_name); + free (buffer_name); } } if (server->buffer) @@ -2580,8 +2547,7 @@ irc_server_rename (struct t_irc_server *server, const char *new_name) "irc.%s", server->name); weechat_buffer_set (server->buffer, "localvar_set_charset_modifier", charset_modifier); - if (buffer_name) - free (buffer_name); + free (buffer_name); } return 1; @@ -2927,8 +2893,7 @@ irc_server_outqueue_send_one_msg (struct t_irc_server *server, message->command, message->message_after_mod, (tags_to_send) ? tags_to_send : ""); - if (tags_to_send) - free (tags_to_send); + free (tags_to_send); if (pos) pos[0] = '\r'; @@ -3141,8 +3106,7 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags, if (ptr_redirect) ptr_redirect->assigned_to_command = 1; - if (tags_to_send) - free (tags_to_send); + free (tags_to_send); if (pos) { @@ -3154,8 +3118,7 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags, first_message = 0; } - if (msg_encoded) - free (msg_encoded); + free (msg_encoded); } else { @@ -3163,8 +3126,7 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags, _("(message dropped)")); } - if (new_msg) - free (new_msg); + free (new_msg); } /* @@ -3329,14 +3291,10 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags, } } - if (nick) - free (nick); - if (command) - free (command); - if (channel) - free (channel); - if (new_msg) - free (new_msg); + free (nick); + free (command); + free (channel); + free (new_msg); free (vbuffer); /* send all messages with "immediate" priority */ @@ -3550,8 +3508,7 @@ irc_server_msgq_flush () str_modifier, irc_recv_msgq->server->name, ptr_data); - if (command) - free (command); + free (command); /* no changes in new message */ if (new_msg && (strcmp (ptr_data, new_msg) == 0)) @@ -3714,22 +3671,14 @@ irc_server_msgq_flush () } } - if (new_msg2) - free (new_msg2); - if (nick) - free (nick); - if (host) - free (host); - if (command) - free (command); - if (channel) - free (channel); - if (arguments) - free (arguments); - if (msg_decoded) - free (msg_decoded); - if (msg_decoded_without_color) - free (msg_decoded_without_color); + free (new_msg2); + free (nick); + free (host); + free (command); + free (channel); + free (arguments); + free (msg_decoded); + free (msg_decoded_without_color); if (pos) { @@ -3746,8 +3695,7 @@ irc_server_msgq_flush () IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED, _("(message dropped)")); } - if (new_msg) - free (new_msg); + free (new_msg); } } free (irc_recv_msgq->data); @@ -4446,8 +4394,7 @@ irc_server_login (struct t_irc_server *server) "USER %s 0 * :%s", (username2) ? username2 : "weechat", (realname && realname[0]) ? realname : ((username2) ? username2 : "weechat")); - if (username2) - free (username2); + free (username2); if (server->hook_timer_connection) weechat_unhook (server->hook_timer_connection); @@ -4457,12 +4404,9 @@ irc_server_login (struct t_irc_server *server) &irc_server_timer_connection_cb, server, NULL); - if (password) - free (password); - if (username) - free (username); - if (realname) - free (realname); + free (password); + free (username); + free (realname); } /* @@ -4527,8 +4471,7 @@ irc_server_connect_cb (const void *pointer, void *data, { case WEECHAT_HOOK_CONNECT_OK: /* set IP */ - if (server->current_ip) - free (server->current_ip); + free (server->current_ip); server->current_ip = (ip_address) ? strdup (ip_address) : NULL; weechat_printf ( server->buffer, @@ -5024,8 +4967,7 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server, for (i = 0; i < IRC_FINGERPRINT_NUM_ALGOS; i++) { - if (fingerprint_server[i]) - free (fingerprint_server[i]); + free (fingerprint_server[i]); } return rc; @@ -5417,8 +5359,7 @@ irc_server_gnutls_callback (const void *pointer, void *data, free (cert_str); } - if (tls_password) - free (tls_password); + free (tls_password); } else { @@ -5442,8 +5383,7 @@ end: if (cert_temp_init) gnutls_x509_crt_deinit (cert_temp); - if (fingerprint_eval) - free (fingerprint_eval); + free (fingerprint_eval); return rc; } @@ -6014,8 +5954,7 @@ irc_server_autojoin_create_buffers (struct t_irc_server *server) } } - if (autojoin) - free (autojoin); + free (autojoin); } /* @@ -6146,8 +6085,7 @@ irc_server_autojoin_channels (struct t_irc_server *server) irc_command_join_server (server, autojoin, 0, 0); server->autojoin_done = 1; } - if (autojoin) - free (autojoin); + free (autojoin); } else if (irc_server_has_channels (server)) { diff --git a/src/plugins/irc/irc-tag.c b/src/plugins/irc/irc-tag.c index 5d3d06c82..4ec61dea0 100644 --- a/src/plugins/irc/irc-tag.c +++ b/src/plugins/irc/irc-tag.c @@ -261,8 +261,7 @@ irc_tag_parse (const char *tags, key); unescaped = irc_tag_unescape_value (pos + 1); weechat_hashtable_set (hashtable, str_key, unescaped); - if (unescaped) - free (unescaped); + free (unescaped); free (key); num_tags++; } @@ -314,8 +313,7 @@ irc_tag_add_to_string_cb (void *data, weechat_string_dyn_concat (string, (escaped) ? escaped : (const char *)value, -1); - if (escaped) - free (escaped); + free (escaped); } } @@ -430,12 +428,10 @@ irc_tag_add_tags_to_message (const char *message, struct t_hashtable *tags) weechat_string_dyn_concat (result, ptr_message, -1); end: - if (msg_str_tags) - free (msg_str_tags); + free (msg_str_tags); if (msg_hash_tags) weechat_hashtable_free (msg_hash_tags); - if (new_tags) - free (new_tags); + free (new_tags); return (result) ? weechat_string_dyn_free (result, 0) : NULL; } diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index 4a82af10f..1ada7fa6d 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -500,16 +500,14 @@ irc_upgrade_read_cb (const void *pointer, void *data, str = weechat_infolist_string (infolist, "prefix_modes"); if (str) { - if (irc_upgrade_current_server->prefix_modes) - free (irc_upgrade_current_server->prefix_modes); + free (irc_upgrade_current_server->prefix_modes); irc_upgrade_current_server->prefix_modes = strdup (str); } /* "prefix_chars" is new in WeeChat 0.3.4 */ str = weechat_infolist_string (infolist, "prefix_chars"); if (str) { - if (irc_upgrade_current_server->prefix_chars) - free (irc_upgrade_current_server->prefix_chars); + free (irc_upgrade_current_server->prefix_chars); irc_upgrade_current_server->prefix_chars = strdup (str); } /* "msg_max_length" is new in WeeChat 4.0.0 */ diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index 19b24f90c..89827b700 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -263,8 +263,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) info_auto_connect = weechat_info_get ("auto_connect", NULL); auto_connect = (info_auto_connect && (strcmp (info_auto_connect, "1") == 0)) ? 1 : 0; - if (info_auto_connect) - free (info_auto_connect); + free (info_auto_connect); /* look at arguments */ for (i = 0; i < argc; i++) |