aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-25 00:21:54 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-26 08:41:44 +0200
commit529a22e342e9195bd0173877e707d74397f55d96 (patch)
tree56c6fb9d00bf630b8f78f978ab36af1240da3853 /src
parenttests: split hook tests into multiple files (issue #865) (diff)
downloadweechat-529a22e342e9195bd0173877e707d74397f55d96.tar.xz
weechat-529a22e342e9195bd0173877e707d74397f55d96.zip
plugins: remove check of NULL pointers before calling weechat_unhook() (issue #865)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/alias/alias.c3
-rw-r--r--src/plugins/exec/exec.c3
-rw-r--r--src/plugins/irc/irc-channel.c3
-rw-r--r--src/plugins/irc/irc-notify.c8
-rw-r--r--src/plugins/irc/irc-protocol.c3
-rw-r--r--src/plugins/irc/irc-server.c18
-rw-r--r--src/plugins/logger/logger-config.c4
-rw-r--r--src/plugins/relay/api/relay-api.c9
-rw-r--r--src/plugins/relay/irc/relay-irc.c12
-rw-r--r--src/plugins/relay/relay-client.c9
-rw-r--r--src/plugins/relay/relay-remote.c9
-rw-r--r--src/plugins/relay/weechat/relay-weechat.c12
-rw-r--r--src/plugins/trigger/trigger.c3
-rw-r--r--src/plugins/xfer/xfer.c9
14 files changed, 34 insertions, 71 deletions
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index 462b2f55a..73f8d8a8d 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -605,8 +605,7 @@ alias_free (struct t_alias *alias)
alias_remove_from_list (alias);
/* free data */
- if (alias->hook)
- weechat_unhook (alias->hook);
+ weechat_unhook (alias->hook);
free (alias->name);
free (alias->command);
free (alias->completion);
diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c
index e0d91804b..8d7d4a1f5 100644
--- a/src/plugins/exec/exec.c
+++ b/src/plugins/exec/exec.c
@@ -635,8 +635,7 @@ exec_free (struct t_exec_cmd *exec_cmd)
last_exec_cmd = exec_cmd->prev_cmd;
/* free data */
- if (exec_cmd->hook)
- weechat_unhook (exec_cmd->hook);
+ weechat_unhook (exec_cmd->hook);
free (exec_cmd->name);
free (exec_cmd->command);
free (exec_cmd->buffer_full_name);
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index c052de77c..683325fe9 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -1545,8 +1545,7 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
weechat_hashtable_free (channel->join_msg_received);
free (channel->away_message);
free (channel->pv_remote_nick_color);
- if (channel->hook_autorejoin)
- weechat_unhook (channel->hook_autorejoin);
+ weechat_unhook (channel->hook_autorejoin);
if (channel->nicks_speaking[0])
weechat_list_free (channel->nicks_speaking[0]);
if (channel->nicks_speaking[1])
diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c
index d1178556f..8c1c57ac5 100644
--- a/src/plugins/irc/irc-notify.c
+++ b/src/plugins/irc/irc-notify.c
@@ -1252,9 +1252,7 @@ irc_notify_print_log (struct t_irc_server *server)
void
irc_notify_hook_timer_ison ()
{
- if (irc_notify_timer_ison)
- weechat_unhook (irc_notify_timer_ison);
-
+ weechat_unhook (irc_notify_timer_ison);
irc_notify_timer_ison = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_ison),
0, 0, &irc_notify_timer_ison_cb, NULL, NULL);
@@ -1267,9 +1265,7 @@ irc_notify_hook_timer_ison ()
void
irc_notify_hook_timer_whois ()
{
- if (irc_notify_timer_whois)
- weechat_unhook (irc_notify_timer_whois);
-
+ weechat_unhook (irc_notify_timer_whois);
irc_notify_timer_whois = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_whois),
0, 0, &irc_notify_timer_whois_cb, NULL, NULL);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 20b6e9c31..57dcc9e03 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1246,8 +1246,7 @@ IRC_PROTOCOL_CALLBACK(cap)
irc_server_sendf (ctxt->server, 0, NULL, str_msg_auth_upper);
free (str_msg_auth_upper);
}
- if (ctxt->server->hook_timer_sasl)
- weechat_unhook (ctxt->server->hook_timer_sasl);
+ weechat_unhook (ctxt->server->hook_timer_sasl);
timeout = IRC_SERVER_OPTION_INTEGER(
ctxt->server, IRC_SERVER_OPTION_SASL_TIMEOUT);
ctxt->server->hook_timer_sasl = weechat_hook_timer (
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index c127f1013..d6051b2c7 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -2298,16 +2298,11 @@ irc_server_free_data (struct t_irc_server *server)
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)
- weechat_unhook (server->hook_fd);
- if (server->hook_timer_connection)
- weechat_unhook (server->hook_timer_connection);
- if (server->hook_timer_sasl)
- weechat_unhook (server->hook_timer_sasl);
- if (server->hook_timer_anti_flood)
- weechat_unhook (server->hook_timer_anti_flood);
+ weechat_unhook (server->hook_connect);
+ weechat_unhook (server->hook_fd);
+ weechat_unhook (server->hook_timer_connection);
+ weechat_unhook (server->hook_timer_sasl);
+ weechat_unhook (server->hook_timer_anti_flood);
irc_server_free_sasl_data (server);
free (server->unterminated_message);
if (server->nicks_array)
@@ -4396,8 +4391,7 @@ irc_server_login (struct t_irc_server *server)
(realname && realname[0]) ? realname : ((username2) ? username2 : "weechat"));
free (username2);
- if (server->hook_timer_connection)
- weechat_unhook (server->hook_timer_connection);
+ weechat_unhook (server->hook_timer_connection);
server->hook_timer_connection = weechat_hook_timer (
IRC_SERVER_OPTION_INTEGER (server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT) * 1000,
0, 1,
diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c
index a2059f6bf..6df3f39d4 100644
--- a/src/plugins/logger/logger-config.c
+++ b/src/plugins/logger/logger-config.c
@@ -135,9 +135,7 @@ logger_config_color_lines_change (const void *pointer, void *data,
if (logger_config_loading)
return;
- if (logger_hook_print)
- weechat_unhook (logger_hook_print);
-
+ weechat_unhook (logger_hook_print);
logger_hook_print = weechat_hook_print (
NULL, NULL, NULL,
(weechat_config_boolean (logger_config_file_color_lines)) ? 0 : 1,
diff --git a/src/plugins/relay/api/relay-api.c b/src/plugins/relay/api/relay-api.c
index e20e147f7..633662f73 100644
--- a/src/plugins/relay/api/relay-api.c
+++ b/src/plugins/relay/api/relay-api.c
@@ -241,12 +241,9 @@ relay_api_free (struct t_relay_client *client)
if (client->protocol_data)
{
- if (RELAY_API_DATA(client, hook_signal_buffer))
- weechat_unhook (RELAY_API_DATA(client, hook_signal_buffer));
- if (RELAY_API_DATA(client, hook_hsignal_nicklist))
- weechat_unhook (RELAY_API_DATA(client, hook_hsignal_nicklist));
- if (RELAY_API_DATA(client, hook_signal_upgrade))
- weechat_unhook (RELAY_API_DATA(client, hook_signal_upgrade));
+ weechat_unhook (RELAY_API_DATA(client, hook_signal_buffer));
+ weechat_unhook (RELAY_API_DATA(client, hook_hsignal_nicklist));
+ weechat_unhook (RELAY_API_DATA(client, hook_signal_upgrade));
free (client->protocol_data);
diff --git a/src/plugins/relay/irc/relay-irc.c b/src/plugins/relay/irc/relay-irc.c
index d6f57c4d9..c9fd0234f 100644
--- a/src/plugins/relay/irc/relay-irc.c
+++ b/src/plugins/relay/irc/relay-irc.c
@@ -2295,14 +2295,10 @@ relay_irc_free (struct t_relay_client *client)
{
free (RELAY_IRC_DATA(client, address));
free (RELAY_IRC_DATA(client, nick));
- if (RELAY_IRC_DATA(client, hook_signal_irc_in2))
- weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_in2));
- if (RELAY_IRC_DATA(client, hook_signal_irc_outtags))
- weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_outtags));
- if (RELAY_IRC_DATA(client, hook_signal_irc_disc))
- weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_disc));
- if (RELAY_IRC_DATA(client, hook_hsignal_irc_redir))
- weechat_unhook (RELAY_IRC_DATA(client, hook_hsignal_irc_redir));
+ weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_in2));
+ weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_outtags));
+ weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_disc));
+ weechat_unhook (RELAY_IRC_DATA(client, hook_hsignal_irc_redir));
free (client->protocol_data);
diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c
index cc22be83c..f073f180c 100644
--- a/src/plugins/relay/relay-client.c
+++ b/src/plugins/relay/relay-client.c
@@ -1906,14 +1906,11 @@ relay_client_free (struct t_relay_client *client)
free (client->protocol_string);
free (client->protocol_args);
free (client->nonce);
- if (client->hook_timer_handshake)
- weechat_unhook (client->hook_timer_handshake);
+ weechat_unhook (client->hook_timer_handshake);
relay_websocket_deflate_free (client->ws_deflate);
relay_http_request_free (client->http_req);
- if (client->hook_fd)
- weechat_unhook (client->hook_fd);
- if (client->hook_timer_send)
- weechat_unhook (client->hook_timer_send);
+ weechat_unhook (client->hook_fd);
+ weechat_unhook (client->hook_timer_send);
free (client->partial_ws_frame);
free (client->partial_message);
if (client->protocol_data)
diff --git a/src/plugins/relay/relay-remote.c b/src/plugins/relay/relay-remote.c
index 6caf57e1a..9d1ba211a 100644
--- a/src/plugins/relay/relay-remote.c
+++ b/src/plugins/relay/relay-remote.c
@@ -792,12 +792,9 @@ relay_remote_free (struct t_relay_remote *remote)
}
free (remote->address);
free (remote->websocket_key);
- if (remote->hook_url_handshake)
- weechat_unhook (remote->hook_url_handshake);
- if (remote->hook_connect)
- weechat_unhook (remote->hook_connect);
- if (remote->hook_fd)
- weechat_unhook (remote->hook_fd);
+ weechat_unhook (remote->hook_url_handshake);
+ weechat_unhook (remote->hook_connect);
+ weechat_unhook (remote->hook_fd);
relay_websocket_deflate_free (remote->ws_deflate);
free (remote->partial_ws_frame);
diff --git a/src/plugins/relay/weechat/relay-weechat.c b/src/plugins/relay/weechat/relay-weechat.c
index 12fa78b1a..4a2b022a6 100644
--- a/src/plugins/relay/weechat/relay-weechat.c
+++ b/src/plugins/relay/weechat/relay-weechat.c
@@ -319,16 +319,12 @@ relay_weechat_free (struct t_relay_client *client)
{
if (RELAY_WEECHAT_DATA(client, buffers_sync))
weechat_hashtable_free (RELAY_WEECHAT_DATA(client, buffers_sync));
- if (RELAY_WEECHAT_DATA(client, hook_signal_buffer))
- weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_buffer));
- if (RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist))
- weechat_unhook (RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist));
- if (RELAY_WEECHAT_DATA(client, hook_signal_upgrade))
- weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_upgrade));
+ weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_buffer));
+ weechat_unhook (RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist));
+ weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_upgrade));
if (RELAY_WEECHAT_DATA(client, buffers_nicklist))
weechat_hashtable_free (RELAY_WEECHAT_DATA(client, buffers_nicklist));
- if (RELAY_WEECHAT_DATA(client, hook_timer_nicklist))
- weechat_unhook (RELAY_WEECHAT_DATA(client, hook_timer_nicklist));
+ weechat_unhook (RELAY_WEECHAT_DATA(client, hook_timer_nicklist));
free (client->protocol_data);
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index afdb292d8..196f7a221 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -279,8 +279,7 @@ trigger_unhook (struct t_trigger *trigger)
{
for (i = 0; i < trigger->hooks_count; i++)
{
- if (trigger->hooks[i])
- weechat_unhook (trigger->hooks[i]);
+ weechat_unhook (trigger->hooks[i]);
}
free (trigger->hooks);
trigger->hooks = NULL;
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index 7f64a4e43..b0c437239 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -939,12 +939,9 @@ xfer_free (struct t_xfer *xfer)
free (xfer->remote_address);
free (xfer->remote_address_str);
free (xfer->remote_nick_color);
- if (xfer->hook_fd)
- weechat_unhook (xfer->hook_fd);
- if (xfer->hook_timer)
- weechat_unhook (xfer->hook_timer);
- if (xfer->hook_connect)
- weechat_unhook (xfer->hook_connect);
+ weechat_unhook (xfer->hook_fd);
+ weechat_unhook (xfer->hook_timer);
+ weechat_unhook (xfer->hook_connect);
free (xfer->unterminated_message);
free (xfer->local_filename);
free (xfer->temp_local_filename);