summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/relay/api/relay-api-msg.c6
-rw-r--r--src/plugins/relay/api/remote/relay-remote-network.c27
-rw-r--r--src/plugins/relay/irc/relay-irc.c90
-rw-r--r--src/plugins/relay/relay-auth.c24
-rw-r--r--src/plugins/relay/relay-buffer.c6
-rw-r--r--src/plugins/relay/relay-client.c48
-rw-r--r--src/plugins/relay/relay-command.c3
-rw-r--r--src/plugins/relay/relay-config.c15
-rw-r--r--src/plugins/relay/relay-http.c78
-rw-r--r--src/plugins/relay/relay-network.c3
-rw-r--r--src/plugins/relay/relay-raw.c9
-rw-r--r--src/plugins/relay/relay-remote.c18
-rw-r--r--src/plugins/relay/relay-server.c12
-rw-r--r--src/plugins/relay/relay-websocket.c15
-rw-r--r--src/plugins/relay/weechat/relay-weechat-msg.c21
-rw-r--r--src/plugins/relay/weechat/relay-weechat-nicklist.c12
-rw-r--r--src/plugins/relay/weechat/relay-weechat-protocol.c21
17 files changed, 136 insertions, 272 deletions
diff --git a/src/plugins/relay/api/relay-api-msg.c b/src/plugins/relay/api/relay-api-msg.c
index 9f00746c3..2e32b612f 100644
--- a/src/plugins/relay/api/relay-api-msg.c
+++ b/src/plugins/relay/api/relay-api-msg.c
@@ -206,8 +206,7 @@ relay_api_msg_send_json_internal (struct t_relay_client *client,
string,
(string) ? strlen (string) : 0,
NULL); /* raw_message */
- if (string)
- free (string);
+ free (string);
cJSON_DetachItemFromObject (json, "body");
cJSON_Delete (json);
}
@@ -217,8 +216,7 @@ relay_api_msg_send_json_internal (struct t_relay_client *client,
string = (json_body) ? cJSON_PrintUnformatted (json_body) : NULL;
num_bytes = relay_http_send_json (client, return_code, message, headers,
string);
- if (string)
- free (string);
+ free (string);
}
return num_bytes;
diff --git a/src/plugins/relay/api/remote/relay-remote-network.c b/src/plugins/relay/api/remote/relay-remote-network.c
index b495846f7..eb6f4fb3c 100644
--- a/src/plugins/relay/api/remote/relay-remote-network.c
+++ b/src/plugins/relay/api/remote/relay-remote-network.c
@@ -312,8 +312,7 @@ relay_remote_network_send (struct t_relay_remote *remote,
num_sent = relay_remote_network_send_data (remote, ptr_data, data_size);
- if (websocket_frame)
- free (websocket_frame);
+ free (websocket_frame);
if (num_sent >= 0)
{
@@ -515,8 +514,7 @@ relay_remote_network_recv_buffer (struct t_relay_remote *remote,
&num_frames,
&remote->partial_ws_frame,
&remote->partial_ws_frame_size);
- if (buffer2)
- free (buffer2);
+ free (buffer2);
if (!rc)
{
/* fatal error when decoding frame: close connection */
@@ -524,8 +522,7 @@ relay_remote_network_recv_buffer (struct t_relay_remote *remote,
{
for (i = 0; i < num_frames; i++)
{
- if (frames[i].payload)
- free (frames[i].payload);
+ free (frames[i].payload);
}
free (frames);
}
@@ -540,8 +537,7 @@ relay_remote_network_recv_buffer (struct t_relay_remote *remote,
relay_remote_network_read_websocket_frames (remote, frames, num_frames);
for (i = 0; i < num_frames; i++)
{
- if (frames[i].payload)
- free (frames[i].payload);
+ free (frames[i].payload);
}
free (frames);
}
@@ -733,8 +729,7 @@ relay_remote_network_connect_ws_auth (struct t_relay_remote *remote)
/* generate random websocket key (16 bytes) */
gcry_create_nonce (ws_key, sizeof (ws_key));
weechat_string_base_encode ("64", ws_key, sizeof (ws_key), ws_key_base64);
- if (remote->websocket_key)
- free (remote->websocket_key);
+ free (remote->websocket_key);
remote->websocket_key = strdup (ws_key_base64);
weechat_string_base_encode ("64", str_auth, strlen (str_auth), str_auth_base64);
@@ -773,10 +768,8 @@ relay_remote_network_connect_ws_auth (struct t_relay_remote *remote)
str_http, strlen (str_http));
end:
- if (password)
- free (password);
- if (totp_secret)
- free (totp_secret);
+ free (password);
+ free (totp_secret);
}
/*
@@ -1450,10 +1443,8 @@ error:
weechat_printf (NULL,
_("remote[%s]: failed to connect, not enough memory"),
remote->name);
- if (url)
- free (url);
- if (body)
- free (body);
+ free (url);
+ free (body);
if (options)
weechat_hashtable_free (options);
return 0;
diff --git a/src/plugins/relay/irc/relay-irc.c b/src/plugins/relay/irc/relay-irc.c
index 8389ffa8f..d6f57c4d9 100644
--- a/src/plugins/relay/irc/relay-irc.c
+++ b/src/plugins/relay/irc/relay-irc.c
@@ -284,14 +284,12 @@ relay_irc_sendf (struct t_relay_client *client, const char *format, ...)
free (message);
}
}
- if (new_msg2)
- free (new_msg2);
+ free (new_msg2);
number++;
}
end:
- if (new_msg1)
- free (new_msg1);
+ free (new_msg1);
if (hashtable_in)
weechat_hashtable_free (hashtable_in);
if (hashtable_out)
@@ -387,8 +385,7 @@ relay_irc_signal_irc_in2_cb (const void *pointer, void *data,
&& irc_args && irc_args[0]
&& (weechat_strcasecmp (irc_nick, RELAY_IRC_DATA(client, nick)) == 0))
{
- if (RELAY_IRC_DATA(client, nick))
- free (RELAY_IRC_DATA(client, nick));
+ free (RELAY_IRC_DATA(client, nick));
RELAY_IRC_DATA(client, nick) = strdup ((irc_args[0] == ':') ?
irc_args + 1 : irc_args);
}
@@ -572,16 +569,13 @@ relay_irc_signal_irc_outtags_cb (const void *pointer, void *data,
weechat_infolist_free (infolist_nick);
}
}
- if (irc_channel)
- free (irc_channel);
+ free (irc_channel);
weechat_hashtable_free (hash_parsed);
}
end:
- if (message)
- free (message);
- if (tags)
- free (tags);
+ free (message);
+ free (tags);
return WEECHAT_RC_OK;
}
@@ -869,8 +863,7 @@ relay_irc_get_line_info (struct t_relay_client *client,
*tags = strdup (str_tag);
}
- if (message_no_color)
- free (message_no_color);
+ free (message_no_color);
}
/*
@@ -1059,10 +1052,8 @@ relay_irc_send_channel_backlog (struct t_relay_client *client,
/* make C compiler happy */
break;
}
- if (tags)
- free (tags);
- if (message)
- free (message);
+ free (tags);
+ free (message);
}
ptr_line = weechat_hdata_move (relay_hdata_line, ptr_line, 1);
}
@@ -1111,8 +1102,7 @@ relay_irc_send_join (struct t_relay_client *client,
RELAY_IRC_DATA(client, nick),
(host && host[0]) ? host : "weechat@proxy",
channel);
- if (host)
- free (host);
+ free (host);
snprintf (infolist_name, length, "%s,%s",
client->protocol_args,
channel);
@@ -1155,8 +1145,7 @@ relay_irc_send_join (struct t_relay_client *client,
nicks2 = realloc (nicks, length_nicks);
if (!nicks2)
{
- if (nicks)
- free (nicks);
+ free (nicks);
return;
}
nicks = nicks2;
@@ -1397,8 +1386,7 @@ relay_irc_cap_enabled (struct t_relay_client *client, const char *capability)
info = weechat_info_get ("irc_server_cap", str_info);
rc = (info && (strcmp (info, "1") == 0)) ? 1 : 0;
- if (info)
- free (info);
+ free (info);
return rc;
}
@@ -1706,8 +1694,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
{
if (num_params > 0)
{
- if (RELAY_IRC_DATA(client, nick))
- free (RELAY_IRC_DATA(client, nick));
+ free (RELAY_IRC_DATA(client, nick));
RELAY_IRC_DATA(client, nick) = strdup (params[0]);
}
}
@@ -1837,8 +1824,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
free (RELAY_IRC_DATA(client, nick));
RELAY_IRC_DATA(client, nick) = strdup (nick);
}
- if (nick)
- free (nick);
+ free (nick);
version = weechat_info_get ("version", NULL);
relay_irc_sendf (client,
@@ -1869,8 +1855,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
RELAY_IRC_DATA(client, nick),
RELAY_IRC_DATA(client, address),
version);
- if (version)
- free (version);
+ free (version);
nick_modes = NULL;
infolist_server = weechat_infolist_get ("irc_server", NULL,
client->protocol_args);
@@ -1926,8 +1911,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
RELAY_IRC_DATA(client, nick),
nick_modes);
}
- if (nick_modes)
- free (nick_modes);
+ free (nick_modes);
/* hook signals */
relay_irc_hook_signals (client);
@@ -1946,8 +1930,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
"priority_high",
"/join %s",
(str_args) ? str_args : "");
- if (str_args)
- free (str_args);
+ free (str_args);
}
else if (irc_command && weechat_strcasecmp (irc_command, "part") == 0)
{
@@ -1957,8 +1940,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
"priority_high",
"/part %s",
(str_args) ? str_args : "");
- if (str_args)
- free (str_args);
+ free (str_args);
}
else if (irc_command && weechat_strcasecmp (irc_command, "ping") == 0)
{
@@ -1969,8 +1951,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
RELAY_IRC_DATA(client, address),
RELAY_IRC_DATA(client, address),
(str_args) ? str_args : "");
- if (str_args)
- free (str_args);
+ free (str_args);
}
else if (irc_command && (weechat_strcasecmp (irc_command, "notice") == 0))
{
@@ -1983,8 +1964,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
"/notice %s %s",
params[0],
(str_args) ? str_args : "");
- if (str_args)
- free (str_args);
+ free (str_args);
}
}
else if (irc_command && (weechat_strcasecmp (irc_command, "privmsg") == 0))
@@ -2040,14 +2020,10 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
(str_args) ? str_args : "");
}
}
- if (str_args)
- free (str_args);
- if (irc_is_channel)
- free (irc_is_channel);
- if (ctcp_type)
- free (ctcp_type);
- if (ctcp_params)
- free (ctcp_params);
+ free (str_args);
+ free (irc_is_channel);
+ free (ctcp_type);
+ free (ctcp_params);
}
}
else if (!relay_irc_command_ignored (irc_command))
@@ -2119,8 +2095,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
"mode_user");
}
}
- if (info)
- free (info);
+ free (info);
}
}
else if (weechat_strcasecmp (irc_command, "ison") == 0)
@@ -2185,12 +2160,10 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
}
end:
- if (new_data)
- free (new_data);
+ free (new_data);
if (hash_parsed)
weechat_hashtable_free (hash_parsed);
- if (params)
- free (params);
+ free (params);
}
/*
@@ -2254,8 +2227,7 @@ relay_irc_alloc (struct t_relay_client *client)
RELAY_IRC_DATA(client, hook_hsignal_irc_redir) = NULL;
}
- if (password)
- free (password);
+ free (password);
}
/*
@@ -2321,10 +2293,8 @@ relay_irc_free (struct t_relay_client *client)
if (client->protocol_data)
{
- if (RELAY_IRC_DATA(client, address))
- free (RELAY_IRC_DATA(client, address));
- if (RELAY_IRC_DATA(client, nick))
- free (RELAY_IRC_DATA(client, nick));
+ 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))
diff --git a/src/plugins/relay/relay-auth.c b/src/plugins/relay/relay-auth.c
index eeccc894e..f1d4e0b59 100644
--- a/src/plugins/relay/relay-auth.c
+++ b/src/plugins/relay/relay-auth.c
@@ -518,12 +518,9 @@ relay_auth_password_hash (struct t_relay_client *client,
{
rc = -4;;
}
- if (salt_hexa)
- free (salt_hexa);
- if (salt)
- free (salt);
- if (hash_sha)
- free (hash_sha);
+ free (salt_hexa);
+ free (salt);
+ free (hash_sha);
break;
case RELAY_AUTH_PASSWORD_HASH_PBKDF2_SHA256:
case RELAY_AUTH_PASSWORD_HASH_PBKDF2_SHA512:
@@ -549,14 +546,10 @@ relay_auth_password_hash (struct t_relay_client *client,
{
rc = -4;
}
- if (hash_pbkdf2_algo)
- free (hash_pbkdf2_algo);
- if (salt_hexa)
- free (salt_hexa);
- if (salt)
- free (salt);
- if (hash_pbkdf2)
- free (hash_pbkdf2);
+ free (hash_pbkdf2_algo);
+ free (salt_hexa);
+ free (salt);
+ free (hash_pbkdf2);
break;
case RELAY_NUM_PASSWORD_HASH_ALGOS:
rc = -4;
@@ -564,8 +557,7 @@ relay_auth_password_hash (struct t_relay_client *client,
}
end:
- if (str_hash_algo)
- free (str_hash_algo);
+ free (str_hash_algo);
return rc;
}
diff --git a/src/plugins/relay/relay-buffer.c b/src/plugins/relay/relay-buffer.c
index 30ac45bbd..e2759dbf6 100644
--- a/src/plugins/relay/relay-buffer.c
+++ b/src/plugins/relay/relay-buffer.c
@@ -153,10 +153,8 @@ relay_buffer_refresh (const char *hotlist)
str_date_start,
str_date_end);
- if (str_recv)
- free (str_recv);
- if (str_sent)
- free (str_sent);
+ free (str_recv);
+ free (str_sent);
line++;
}
diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c
index 78966f039..cc22be83c 100644
--- a/src/plugins/relay/relay-client.c
+++ b/src/plugins/relay/relay-client.c
@@ -180,8 +180,7 @@ relay_client_set_desc (struct t_relay_client *client)
{
char desc[512];
- if (client->desc)
- free (client->desc);
+ free (client->desc);
snprintf (desc, sizeof (desc),
"%d/%s%s%s%s/%s%s%s%s",
@@ -658,8 +657,7 @@ relay_client_recv_buffer (struct t_relay_client *client,
&num_frames,
&client->partial_ws_frame,
&client->partial_ws_frame_size);
- if (buffer2)
- free (buffer2);
+ free (buffer2);
if (!rc)
{
/* fatal error when decoding frame: close connection */
@@ -667,8 +665,7 @@ relay_client_recv_buffer (struct t_relay_client *client,
{
for (i = 0; i < num_frames; i++)
{
- if (frames[i].payload)
- free (frames[i].payload);
+ free (frames[i].payload);
}
free (frames);
}
@@ -686,8 +683,7 @@ relay_client_recv_buffer (struct t_relay_client *client,
relay_client_read_websocket_frames (client, frames, num_frames);
for (i = 0; i < num_frames; i++)
{
- if (frames[i].payload)
- free (frames[i].payload);
+ free (frames[i].payload);
}
free (frames);
}
@@ -827,12 +823,9 @@ relay_client_outqueue_free (struct t_relay_client *client,
(outqueue->next_outqueue)->prev_outqueue = outqueue->prev_outqueue;
/* free data */
- if (outqueue->data)
- free (outqueue->data);
- if (outqueue->raw_message[0])
- free (outqueue->raw_message[0]);
- if (outqueue->raw_message[1])
- free (outqueue->raw_message[1]);
+ free (outqueue->data);
+ free (outqueue->raw_message[0]);
+ free (outqueue->raw_message[1]);
free (outqueue);
/* set new head */
@@ -1300,8 +1293,7 @@ relay_client_send (struct t_relay_client *client,
}
}
- if (websocket_frame)
- free (websocket_frame);
+ free (websocket_frame);
return num_sent;
}
@@ -1908,18 +1900,12 @@ relay_client_free (struct t_relay_client *client)
(client->next_client)->prev_client = client->prev_client;
/* free data */
- if (client->desc)
- free (client->desc);
- if (client->address)
- free (client->address);
- if (client->real_ip)
- free (client->real_ip);
- if (client->protocol_string)
- free (client->protocol_string);
- if (client->protocol_args)
- free (client->protocol_args);
- if (client->nonce)
- free (client->nonce);
+ free (client->desc);
+ free (client->address);
+ free (client->real_ip);
+ free (client->protocol_string);
+ free (client->protocol_args);
+ free (client->nonce);
if (client->hook_timer_handshake)
weechat_unhook (client->hook_timer_handshake);
relay_websocket_deflate_free (client->ws_deflate);
@@ -1928,10 +1914,8 @@ relay_client_free (struct t_relay_client *client)
weechat_unhook (client->hook_fd);
if (client->hook_timer_send)
weechat_unhook (client->hook_timer_send);
- if (client->partial_ws_frame)
- free (client->partial_ws_frame);
- if (client->partial_message)
- free (client->partial_message);
+ free (client->partial_ws_frame);
+ free (client->partial_message);
if (client->protocol_data)
{
switch (client->protocol)
diff --git a/src/plugins/relay/relay-command.c b/src/plugins/relay/relay-command.c
index 8ebdf7118..88233448c 100644
--- a/src/plugins/relay/relay-command.c
+++ b/src/plugins/relay/relay-command.c
@@ -728,8 +728,7 @@ relay_command_remote (const void *pointer, void *data,
_("%s: remote relay \"%s\" has been deleted"),
RELAY_PLUGIN_NAME,
(remote_name) ? remote_name : "???");
- if (remote_name)
- free (remote_name);
+ free (remote_name);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c
index fd4d12e16..d3c16f0a3 100644
--- a/src/plugins/relay/relay-config.c
+++ b/src/plugins/relay/relay-config.c
@@ -400,10 +400,8 @@ error:
weechat_prefix ("error"), RELAY_PLUGIN_NAME);
end:
- if (totp_secret)
- free (totp_secret);
- if (secret)
- free (secret);
+ free (totp_secret);
+ free (secret);
return rc;
}
@@ -954,10 +952,8 @@ relay_config_create_option_port_path (const void *pointer, void *data,
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
}
- if (protocol)
- free (protocol);
- if (protocol_args)
- free (protocol_args);
+ free (protocol);
+ free (protocol_args);
return rc;
}
@@ -1182,8 +1178,7 @@ relay_config_use_temp_remotes ()
{
next_temp_remote = relay_remotes_temp->next_remote;
- if (relay_remotes_temp->name)
- free (relay_remotes_temp->name);
+ free (relay_remotes_temp->name);
free (relay_remotes_temp);
relay_remotes_temp = next_temp_remote;
diff --git a/src/plugins/relay/relay-http.c b/src/plugins/relay/relay-http.c
index ee8888888..37af1846f 100644
--- a/src/plugins/relay/relay-http.c
+++ b/src/plugins/relay/relay-http.c
@@ -313,18 +313,14 @@ relay_http_parse_path (const char *path,
}
if (params)
weechat_hashtable_set (params, name, value);
- if (name)
- free (name);
- if (value)
- free (value);
+ free (name);
+ free (value);
}
}
}
- if (str_path)
- free (str_path);
- if (str_params)
- free (str_params);
+ free (str_path);
+ free (str_params);
if (items_path)
weechat_string_free_split (items_path);
}
@@ -358,18 +354,15 @@ relay_http_parse_method_path (struct t_relay_http_request *request,
if (!items || (num_items < 2))
goto error;
- if (request->method)
- free (request->method);
+ free (request->method);
request->method = strdup (items[0]);
- if (request->path)
- free (request->path);
+ free (request->path);
request->path = strdup (items[1]);
if (num_items > 2)
{
- if (request->http_version)
- free (request->http_version);
+ free (request->http_version);
request->http_version = strdup (items[2]);
}
@@ -685,8 +678,7 @@ relay_http_get_auth_status (struct t_relay_client *client)
info_totp = weechat_info_get ("totp_validate", info_totp_args);
totp_ok = (info_totp && (strcmp (info_totp, "1") == 0)) ?
1 : 0;
- if (info_totp)
- free (info_totp);
+ free (info_totp);
free (info_totp_args);
if (!totp_ok)
{
@@ -697,12 +689,9 @@ relay_http_get_auth_status (struct t_relay_client *client)
}
end:
- if (relay_password)
- free (relay_password);
- if (totp_secret)
- free (totp_secret);
- if (user_pass)
- free (user_pass);
+ free (relay_password);
+ free (totp_secret);
+ free (user_pass);
return rc;
}
@@ -852,8 +841,7 @@ relay_http_process_websocket (struct t_relay_client *client)
client->http_req->headers, "x-real-ip");
if (ptr_real_ip)
{
- if (client->real_ip)
- free (client->real_ip);
+ free (client->real_ip);
client->real_ip = strdup (ptr_real_ip);
relay_client_set_desc (client);
weechat_printf_date_tags (
@@ -1230,8 +1218,7 @@ relay_http_send (struct t_relay_client *client,
num_bytes = relay_client_send (client, RELAY_MSG_STANDARD,
http_message, length_msg,
raw_message);
- if (raw_message)
- free (raw_message);
+ free (raw_message);
free (http_message);
}
else
@@ -1240,8 +1227,7 @@ relay_http_send (struct t_relay_client *client,
}
}
- if (compressed_body)
- free (compressed_body);
+ free (compressed_body);
return num_bytes;
}
@@ -1286,8 +1272,7 @@ relay_http_send_json (struct t_relay_client *client,
json_string,
(json_string) ? strlen (json_string) : 0);
- if (headers2)
- free (headers2);
+ free (headers2);
return num_bytes;
}
@@ -1334,10 +1319,8 @@ relay_http_send_error_json (struct t_relay_client *client,
end:
free (vbuffer);
- if (error_msg)
- free (error_msg);
- if (json)
- free (json);
+ free (error_msg);
+ free (json);
return num_bytes;
}
@@ -1350,24 +1333,20 @@ relay_http_request_free (struct t_relay_http_request *request)
{
if (request->raw)
weechat_string_dyn_free (request->raw, 1);
- if (request->method)
- free (request->method);
- if (request->path)
- free (request->path);
+ free (request->method);
+ free (request->path);
if (request->path_items)
weechat_string_free_split (request->path_items);
if (request->params)
weechat_hashtable_free (request->params);
- if (request->http_version)
- free (request->http_version);
+ free (request->http_version);
if (request->headers)
weechat_hashtable_free (request->headers);
if (request->accept_encoding)
weechat_hashtable_free (request->accept_encoding);
if (request->ws_deflate)
relay_websocket_deflate_free (request->ws_deflate);
- if (request->body)
- free (request->body);
+ free (request->body);
free (request);
}
@@ -1430,8 +1409,7 @@ relay_http_parse_response_code (struct t_relay_http_response *response,
if (!pos)
goto error;
- if (response->http_version)
- free (response->http_version);
+ free (response->http_version);
response->http_version = weechat_strndup (response_code, pos - response_code);
while (pos[0] == ' ')
@@ -1460,8 +1438,7 @@ relay_http_parse_response_code (struct t_relay_http_response *response,
{
pos2++;
}
- if (response->message)
- free (response->message);
+ free (response->message);
response->message = strdup (pos2);
}
@@ -1609,14 +1586,11 @@ relay_http_parse_response (const char *data)
void
relay_http_response_free (struct t_relay_http_response *response)
{
- if (response->http_version)
- free (response->http_version);
- if (response->message)
- free (response->message);
+ free (response->http_version);
+ free (response->message);
if (response->headers)
weechat_hashtable_free (response->headers);
- if (response->body)
- free (response->body);
+ free (response->body);
free (response);
}
diff --git a/src/plugins/relay/relay-network.c b/src/plugins/relay/relay-network.c
index 497f7d4b3..b0dd1c6dd 100644
--- a/src/plugins/relay/relay-network.c
+++ b/src/plugins/relay/relay-network.c
@@ -131,8 +131,7 @@ relay_network_set_tls_cert_key (int verbose)
}
}
- if (certkey_path)
- free (certkey_path);
+ free (certkey_path);
}
/*
diff --git a/src/plugins/relay/relay-raw.c b/src/plugins/relay/relay-raw.c
index b18d7b796..6453d1344 100644
--- a/src/plugins/relay/relay-raw.c
+++ b/src/plugins/relay/relay-raw.c
@@ -154,10 +154,8 @@ relay_raw_message_free (struct t_relay_raw_message *raw_message)
(raw_message->next_message)->prev_message = raw_message->prev_message;
/* free data */
- if (raw_message->prefix)
- free (raw_message->prefix);
- if (raw_message->message)
- free (raw_message->message);
+ free (raw_message->prefix);
+ free (raw_message->message);
free (raw_message);
@@ -377,8 +375,7 @@ relay_raw_message_add (enum t_relay_msg_type msg_type,
relay_raw_message_free (new_raw_message);
}
- if (buf)
- free (buf);
+ free (buf);
free (raw_data);
}
diff --git a/src/plugins/relay/relay-remote.c b/src/plugins/relay/relay-remote.c
index 27b73ea10..6caf57e1a 100644
--- a/src/plugins/relay/relay-remote.c
+++ b/src/plugins/relay/relay-remote.c
@@ -413,8 +413,7 @@ relay_remote_add (struct t_relay_remote *remote,
void
relay_remote_set_url (struct t_relay_remote *remote, const char *url)
{
- if (remote->address)
- free (remote->address);
+ free (remote->address);
remote->address = relay_remote_get_address (url);
remote->port = relay_remote_get_port (url);
remote->tls = (weechat_strncmp (url, "https:", 6) == 0) ? 1 : 0;
@@ -712,8 +711,7 @@ relay_remote_rename (struct t_relay_remote *remote, const char *name)
}
}
- if (remote->name)
- free (remote->name);
+ free (remote->name);
remote->name = strdup (name);
free (option_name);
@@ -786,17 +784,14 @@ relay_remote_free (struct t_relay_remote *remote)
last_relay_remote = remote->prev_remote;
/* free data */
- if (remote->name)
- free (remote->name);
+ free (remote->name);
for (i = 0; i < RELAY_REMOTE_NUM_OPTIONS; i++)
{
if (remote->options[i])
weechat_config_option_free (remote->options[i]);
}
- if (remote->address)
- free (remote->address);
- if (remote->websocket_key)
- free (remote->websocket_key);
+ free (remote->address);
+ free (remote->websocket_key);
if (remote->hook_url_handshake)
weechat_unhook (remote->hook_url_handshake);
if (remote->hook_connect)
@@ -804,8 +799,7 @@ relay_remote_free (struct t_relay_remote *remote)
if (remote->hook_fd)
weechat_unhook (remote->hook_fd);
relay_websocket_deflate_free (remote->ws_deflate);
- if (remote->partial_ws_frame)
- free (remote->partial_ws_frame);
+ free (remote->partial_ws_frame);
free (remote);
diff --git a/src/plugins/relay/relay-server.c b/src/plugins/relay/relay-server.c
index fac396da3..0cfe1c394 100644
--- a/src/plugins/relay/relay-server.c
+++ b/src/plugins/relay/relay-server.c
@@ -478,10 +478,8 @@ error:
close (client_fd);
end:
- if (relay_password)
- free (relay_password);
- if (relay_totp_secret)
- free (relay_totp_secret);
+ free (relay_password);
+ free (relay_totp_secret);
return WEECHAT_RC_OK;
}
@@ -966,10 +964,8 @@ relay_server_free (struct t_relay_server *server)
/* free data */
relay_server_close_socket (server);
- if (server->protocol_string)
- free (server->protocol_string);
- if (server->protocol_args)
- free (server->protocol_args);
+ free (server->protocol_string);
+ free (server->protocol_args);
free (server->path);
free (server);
diff --git a/src/plugins/relay/relay-websocket.c b/src/plugins/relay/relay-websocket.c
index 7081adeec..bd9aceb1c 100644
--- a/src/plugins/relay/relay-websocket.c
+++ b/src/plugins/relay/relay-websocket.c
@@ -543,15 +543,12 @@ relay_websocket_inflate (const void *data, size_t size, z_stream *strm,
goto error;
dest = dest2;
dest[*size_decompressed] = '\0';
- if (data2)
- free (data2);
+ free (data2);
return (char *)dest;
error:
- if (data2)
- free (data2);
- if (dest)
- free (dest);
+ free (data2);
+ free (dest);
return NULL;
}
@@ -884,8 +881,7 @@ relay_websocket_encode_frame (struct t_relay_websocket_deflate *ws_deflate,
frame = malloc (data_size + 14);
if (!frame)
{
- if (payload_compressed)
- free (payload_compressed);
+ free (payload_compressed);
return NULL;
}
@@ -943,8 +939,7 @@ relay_websocket_encode_frame (struct t_relay_websocket_deflate *ws_deflate,
*length_frame = index + data_size;
- if (payload_compressed)
- free (payload_compressed);
+ free (payload_compressed);
return (char *)frame;
}
diff --git a/src/plugins/relay/weechat/relay-weechat-msg.c b/src/plugins/relay/weechat/relay-weechat-msg.c
index 2985eb6e1..7514e3f5a 100644
--- a/src/plugins/relay/weechat/relay-weechat-msg.c
+++ b/src/plugins/relay/weechat/relay-weechat-msg.c
@@ -770,14 +770,11 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
end:
if (list_keys)
weechat_string_free_split (list_keys);
- if (keys_types)
- free (keys_types);
+ free (keys_types);
if (list_path)
weechat_string_free_split (list_path);
- if (path_returned)
- free (path_returned);
- if (hdata_head)
- free (hdata_head);
+ free (path_returned);
+ free (hdata_head);
return rc;
}
@@ -1123,8 +1120,7 @@ relay_weechat_msg_compress_zlib (struct t_relay_client *client,
rc = 1;
error:
- if (dest)
- free (dest);
+ free (dest);
return rc;
}
@@ -1196,8 +1192,7 @@ relay_weechat_msg_compress_zstd (struct t_relay_client *client,
rc = 1;
error:
- if (dest)
- free (dest);
+ free (dest);
return rc;
#else
@@ -1264,10 +1259,8 @@ relay_weechat_msg_free (struct t_relay_weechat_msg *msg)
if (!msg)
return;
- if (msg->id)
- free (msg->id);
- if (msg->data)
- free (msg->data);
+ free (msg->id);
+ free (msg->data);
free (msg);
}
diff --git a/src/plugins/relay/weechat/relay-weechat-nicklist.c b/src/plugins/relay/weechat/relay-weechat-nicklist.c
index 5b28ec887..077f3198d 100644
--- a/src/plugins/relay/weechat/relay-weechat-nicklist.c
+++ b/src/plugins/relay/weechat/relay-weechat-nicklist.c
@@ -125,14 +125,10 @@ relay_weechat_nicklist_item_free (struct t_relay_weechat_nicklist_item *item)
if (!item)
return;
- if (item->name)
- free (item->name);
- if (item->color)
- free (item->color);
- if (item->prefix)
- free (item->prefix);
- if (item->prefix_color)
- free (item->prefix_color);
+ free (item->name);
+ free (item->color);
+ free (item->prefix);
+ free (item->prefix_color);
}
/*
diff --git a/src/plugins/relay/weechat/relay-weechat-protocol.c b/src/plugins/relay/weechat/relay-weechat-protocol.c
index 56aa69cfe..1d5d772e6 100644
--- a/src/plugins/relay/weechat/relay-weechat-protocol.c
+++ b/src/plugins/relay/weechat/relay-weechat-protocol.c
@@ -208,8 +208,7 @@ relay_weechat_protocol_handshake_reply (struct t_relay_client *client,
weechat_hashtable_free (hashtable);
}
- if (totp_secret)
- free (totp_secret);
+ free (totp_secret);
}
@@ -420,8 +419,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(init)
info_totp = weechat_info_get ("totp_validate", info_totp_args);
if (info_totp && (strcmp (info_totp, "1") == 0))
RELAY_WEECHAT_DATA(client, totp_ok) = 1;
- if (info_totp)
- free (info_totp);
+ free (info_totp);
free (info_totp_args);
}
}
@@ -451,10 +449,8 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(init)
relay_client_set_status (client, RELAY_STATUS_AUTH_FAILED);
}
- if (relay_password)
- free (relay_password);
- if (totp_secret)
- free (totp_secret);
+ free (relay_password);
+ free (totp_secret);
return WEECHAT_RC_OK;
}
@@ -515,8 +511,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(info)
relay_weechat_msg_add_string (msg, info);
relay_weechat_msg_send (client, msg);
relay_weechat_msg_free (msg);
- if (info)
- free (info);
+ free (info);
}
return WEECHAT_RC_OK;
@@ -1841,10 +1836,8 @@ relay_weechat_protocol_recv (struct t_relay_client *client, const char *data)
}
end:
- if (data_unescaped)
- free (data_unescaped);
- if (id)
- free (id);
+ free (data_unescaped);
+ free (id);
free (command);
if (argv)
weechat_string_free_split (argv);