1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core, plugins: add missing parentheses when dereferencing a pointer with an array index

This commit is contained in:
Sébastien Helleu
2024-09-05 20:53:54 +02:00
parent 230c436dd4
commit 143f694fe2
25 changed files with 61 additions and 61 deletions
+2 -2
View File
@@ -5059,7 +5059,7 @@ command_plugin_list_input (struct t_gui_buffer *buffer,
for (ptr_item = list->items; ptr_item;
ptr_item = ptr_item->next_item)
{
if (*buf[0])
if ((*buf)[0])
{
string_dyn_concat (buf, ", ", -1);
}
@@ -5074,7 +5074,7 @@ command_plugin_list_input (struct t_gui_buffer *buffer,
string_dyn_concat (buf, ptr_item->data, -1);
}
if (!*buf[0])
if (!(*buf)[0])
{
string_dyn_concat (
buf,
+1 -1
View File
@@ -410,7 +410,7 @@ infolist_fields (struct t_infolist *infolist)
for (ptr_var = infolist->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var)
{
if (*fields[0])
if ((*fields)[0])
string_dyn_concat (fields, ",", -1);
string_dyn_concat (fields, infolist_type_char_string[ptr_var->type], -1);
string_dyn_concat (fields, ":", -1);
+3 -3
View File
@@ -369,10 +369,10 @@ gui_color_get_pairs_arrays (short **foregrounds, short **backgrounds)
*foregrounds = NULL;
*backgrounds = NULL;
*foregrounds = malloc (sizeof (*foregrounds[0]) * (gui_color_num_pairs + 1));
*foregrounds = malloc (sizeof ((*foregrounds)[0]) * (gui_color_num_pairs + 1));
if (!*foregrounds)
goto error;
*backgrounds = malloc (sizeof (*backgrounds[0]) * (gui_color_num_pairs + 1));
*backgrounds = malloc (sizeof ((*backgrounds)[0]) * (gui_color_num_pairs + 1));
if (!*backgrounds)
goto error;
@@ -609,7 +609,7 @@ gui_color_build (int number, int foreground, int background)
/* allocate color */
if (!gui_color[number])
{
gui_color[number] = malloc (sizeof (*gui_color[number]));
gui_color[number] = malloc (sizeof ((*gui_color)[number]));
if (!gui_color[number])
return;
}
+1 -1
View File
@@ -1874,7 +1874,7 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
&& buffer->nicklist_display_groups
&& ptr_group->visible))
{
if (*nicklist[0])
if ((*nicklist)[0])
string_dyn_concat (nicklist, "\n", -1);
if (ptr_nick)
+1 -1
View File
@@ -976,7 +976,7 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
break;
}
if (!*content[0])
if (!(*content)[0])
{
string_dyn_free (content, 1);
return NULL;
+1 -1
View File
@@ -1940,7 +1940,7 @@ gui_buffer_set_highlight_words_list (struct t_gui_buffer *buffer,
ptr_string = weelist_string (ptr_list_item);
if (ptr_string)
{
if (*words[0])
if ((*words)[0])
string_dyn_concat (words, ",", -1);
string_dyn_concat (words, ptr_string, -1);
}
+1 -1
View File
@@ -814,7 +814,7 @@ gui_chat_add_line_waiting_buffer (const char *message)
return;
}
if (*gui_chat_lines_waiting_buffer[0])
if ((*gui_chat_lines_waiting_buffer)[0])
string_dyn_concat (gui_chat_lines_waiting_buffer, "\n", -1);
string_dyn_concat (gui_chat_lines_waiting_buffer, message, -1);
+2 -2
View File
@@ -436,10 +436,10 @@ gui_key_expand (const char *key, char **key_name, char **key_name_alias)
meta2 = 0;
shift = 0;
if (*str_dyn_key[0])
if ((*str_dyn_key)[0])
string_dyn_concat (str_dyn_key, ",", -1);
if (*str_dyn_key_alias[0])
if ((*str_dyn_key_alias)[0])
string_dyn_concat (str_dyn_key_alias, ",", -1);
str_raw[0] = '\0';
+2 -2
View File
@@ -568,7 +568,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
str_hotlist_count);
if (count > 0)
{
if (*hotlist[0])
if ((*hotlist)[0])
{
weechat_string_dyn_concat (
hotlist,
@@ -644,7 +644,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
/* add newline between each buffer (if needed) */
if (weechat_config_boolean (buflist_config_look_add_newline)
&& *buflist[0])
&& (*buflist)[0])
{
if (!weechat_string_dyn_concat (buflist, "\n", -1))
goto error;
+1 -1
View File
@@ -122,7 +122,7 @@ weechat_guile_output_flush ()
char *temp_buffer, *command;
int length;
if (!*guile_buffer_output[0])
if (!(*guile_buffer_output)[0])
return;
/* if there's no buffer, we catch the output, so there's no flush */
+1 -1
View File
@@ -418,7 +418,7 @@ irc_batch_process_multiline (struct t_irc_server *server,
if (tags && tags[0])
irc_tag_parse (tags, hash_tags, NULL);
}
if (*result[0])
if ((*result)[0])
{
if (!hash_tags
|| !weechat_hashtable_has_key (hash_tags,
+5 -5
View File
@@ -265,7 +265,7 @@ irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
{
for (j = number1; j <= number2; j++)
{
if (*str_masks[0])
if ((*str_masks)[0])
weechat_string_dyn_concat (str_masks, " ", -1);
snprintf (str_number, sizeof (str_number),
"%ld", j);
@@ -278,7 +278,7 @@ irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
if (!added)
{
if (*str_masks[0])
if ((*str_masks)[0])
weechat_string_dyn_concat (str_masks, " ", -1);
weechat_string_dyn_concat (str_masks, argv[i], -1);
}
@@ -392,7 +392,7 @@ irc_command_mode_masks (struct t_irc_server *server,
* if we reached the max number of modes allowed, send the MODE
* command now and flush the modes/masks strings
*/
if (*modes[0] && (modes_added == max_modes))
if ((*modes)[0] && (modes_added == max_modes))
{
irc_server_sendf (server, msg_priority, NULL,
"MODE %s %s%s %s",
@@ -408,7 +408,7 @@ irc_command_mode_masks (struct t_irc_server *server,
/* add one mode letter (after +/-) and add the mask in masks */
weechat_string_dyn_concat (modes, mode, -1);
if (*masks[0])
if ((*masks)[0])
weechat_string_dyn_concat (masks, " ", -1);
weechat_string_dyn_concat (masks, (mask) ? mask : argv[pos_masks], -1);
modes_added++;
@@ -417,7 +417,7 @@ irc_command_mode_masks (struct t_irc_server *server,
}
/* send a final MODE command if some masks are remaining */
if (*modes[0] && *masks[0])
if ((*modes)[0] && (*masks)[0])
{
irc_server_sendf (server, msg_priority, NULL,
"MODE %s %s%s %s",
+1 -1
View File
@@ -602,7 +602,7 @@ irc_ctcp_get_supported_ctcp (struct t_irc_server *server)
(const char *)weechat_arraylist_get (list_ctcp, i));
if (ctcp_upper)
{
if (*result[0])
if ((*result)[0])
weechat_string_dyn_concat (result, " ", -1);
weechat_string_dyn_concat (result, ctcp_upper, -1);
free (ctcp_upper);
+3 -3
View File
@@ -413,18 +413,18 @@ irc_join_build_string (struct t_arraylist *arraylist)
{
ptr_join_chan = (struct t_irc_join_channel *)weechat_arraylist_get (
arraylist, i);
if (*channels[0])
if ((*channels)[0])
weechat_string_dyn_concat (channels, ",", -1);
weechat_string_dyn_concat (channels, ptr_join_chan->name, -1);
if (ptr_join_chan->key)
{
if (*keys[0])
if ((*keys)[0])
weechat_string_dyn_concat (keys, ",", -1);
weechat_string_dyn_concat (keys, ptr_join_chan->key, -1);
}
}
if (*keys[0])
if ((*keys)[0])
{
weechat_string_dyn_concat (channels, " ", -1);
weechat_string_dyn_concat (channels, *keys, -1);
+1 -1
View File
@@ -82,7 +82,7 @@ irc_message_parse_params (const char *parameters,
*params = malloc ((alloc_params + 1) * sizeof ((*params)[0]));
if (!*params)
return;
*params[0] = NULL;
(*params)[0] = NULL;
}
ptr_params = parameters;
+17 -17
View File
@@ -181,7 +181,7 @@ irc_protocol_tags_add_cb (void *data,
str_tags = (char **)data;
if (*str_tags[0])
if ((*str_tags)[0])
weechat_string_dyn_concat (str_tags, ",", -1);
weechat_string_dyn_concat (str_tags, "irc_tag_", -1);
@@ -274,7 +274,7 @@ irc_protocol_tags (struct t_irc_protocol_ctxt *ctxt, const char *extra_tags)
ptr_batch = irc_batch_search (ctxt->server, ptr_tag_batch);
if (ptr_batch)
{
if (*str_irc_tags[0])
if ((*str_irc_tags)[0])
weechat_string_dyn_concat (str_irc_tags, ",", -1);
weechat_string_dyn_concat (str_irc_tags,
"irc_batch_type_", -1);
@@ -301,8 +301,8 @@ irc_protocol_tags (struct t_irc_protocol_ctxt *ctxt, const char *extra_tags)
(ctxt->command && ctxt->command[0]) ? ctxt->command : "",
(is_numeric) ? "," : "",
(is_numeric) ? "irc_numeric" : "",
(str_irc_tags && *str_irc_tags[0]) ? "," : "",
(str_irc_tags && *str_irc_tags[0]) ? *str_irc_tags : "",
(str_irc_tags && (*str_irc_tags)[0]) ? "," : "",
(str_irc_tags && (*str_irc_tags)[0]) ? *str_irc_tags : "",
(extra_tags && extra_tags[0]) ? "," : "",
(extra_tags && extra_tags[0]) ? extra_tags : "",
(ctxt->ignore_tag) ? ",irc_ignored" : "",
@@ -717,7 +717,7 @@ irc_protocol_cap_print_cb (void *data,
str_caps = (char **)data;
if (*str_caps[0])
if ((*str_caps)[0])
weechat_string_dyn_concat (str_caps, " ", -1);
weechat_string_dyn_concat (str_caps, key, -1);
if (value)
@@ -767,7 +767,7 @@ irc_protocol_cap_to_enable (const char *capabilities, int sasl_requested)
",");
if (supported_caps)
{
if (*str_caps[0])
if ((*str_caps)[0])
weechat_string_dyn_concat (str_caps, ",", -1);
weechat_string_dyn_concat (str_caps, supported_caps, -1);
free (supported_caps);
@@ -775,7 +775,7 @@ irc_protocol_cap_to_enable (const char *capabilities, int sasl_requested)
}
else
{
if (*str_caps[0])
if ((*str_caps)[0])
weechat_string_dyn_concat (str_caps, ",", -1);
weechat_string_dyn_concat (str_caps, caps[i], -1);
}
@@ -786,7 +786,7 @@ irc_protocol_cap_to_enable (const char *capabilities, int sasl_requested)
if (sasl_requested)
{
if (*str_caps[0])
if ((*str_caps)[0])
weechat_string_dyn_concat (str_caps, ",", -1);
weechat_string_dyn_concat (str_caps, "sasl", -1);
}
@@ -897,7 +897,7 @@ irc_protocol_cap_sync (struct t_irc_server *server, int sasl)
{
if (sasl && strcmp (caps_server[i], "sasl") == 0)
sasl_to_do = 1;
if (*cap_req[0])
if ((*cap_req)[0])
weechat_string_dyn_concat (cap_req, " ", -1);
weechat_string_dyn_concat (cap_req, caps_server[i], -1);
}
@@ -1165,7 +1165,7 @@ IRC_PROTOCOL_CALLBACK(cap)
{
if (caps_supported[j][0] == '-')
{
if (*str_caps_disabled[0])
if ((*str_caps_disabled)[0])
weechat_string_dyn_concat (str_caps_disabled, " ", -1);
weechat_string_dyn_concat (str_caps_disabled,
caps_supported[j] + 1,
@@ -1177,7 +1177,7 @@ IRC_PROTOCOL_CALLBACK(cap)
}
else
{
if (*str_caps_enabled[0])
if ((*str_caps_enabled)[0])
weechat_string_dyn_concat (str_caps_enabled, " ", -1);
weechat_string_dyn_concat (str_caps_enabled,
caps_supported[j],
@@ -1192,7 +1192,7 @@ IRC_PROTOCOL_CALLBACK(cap)
}
weechat_string_free_split (caps_supported);
}
if (*str_caps_enabled[0] && *str_caps_disabled[0])
if ((*str_caps_enabled)[0] && (*str_caps_disabled)[0])
{
weechat_printf_datetime_tags (
ctxt->server->buffer,
@@ -1203,7 +1203,7 @@ IRC_PROTOCOL_CALLBACK(cap)
weechat_prefix ("network"), IRC_PLUGIN_NAME,
*str_caps_enabled, *str_caps_disabled);
}
else if (*str_caps_enabled[0])
else if ((*str_caps_enabled)[0])
{
weechat_printf_datetime_tags (
ctxt->server->buffer,
@@ -1214,7 +1214,7 @@ IRC_PROTOCOL_CALLBACK(cap)
weechat_prefix ("network"), IRC_PLUGIN_NAME,
*str_caps_enabled);
}
else if (*str_caps_disabled[0])
else if ((*str_caps_disabled)[0])
{
weechat_printf_datetime_tags (
ctxt->server->buffer,
@@ -6206,7 +6206,7 @@ IRC_PROTOCOL_CALLBACK(353)
}
else if (!ptr_channel && str_nicks)
{
if (*str_nicks[0])
if ((*str_nicks)[0])
{
weechat_string_dyn_concat (str_nicks, IRC_COLOR_RESET, -1);
weechat_string_dyn_concat (str_nicks, " ", -1);
@@ -6471,7 +6471,7 @@ irc_protocol_get_string_channel_nicks (struct t_irc_server *server,
if (!filter_ok)
continue;
if (*str_nicks[0])
if ((*str_nicks)[0])
{
weechat_string_dyn_concat (str_nicks,
IRC_COLOR_RESET,
@@ -6606,7 +6606,7 @@ irc_protocol_get_string_channel_nicks_count (struct t_irc_server *server,
snprintf (str_mode_name, sizeof (str_mode_name),
"+%c", ptr_prefix_modes[i]);
}
if (*str_counts[0])
if ((*str_counts)[0])
weechat_string_dyn_concat (str_counts, ", ", -1);
weechat_string_dyn_concat (str_counts, str_count, -1);
weechat_string_dyn_concat (str_counts, str_mode_name, -1);
+6 -6
View File
@@ -6067,19 +6067,19 @@ irc_server_build_autojoin (struct t_irc_server *server)
if (ptr_channel->key)
{
/* add channel with key and the key */
if (*channels_with_key[0])
if ((*channels_with_key)[0])
weechat_string_dyn_concat (channels_with_key, ",", -1);
weechat_string_dyn_concat (channels_with_key,
ptr_channel->name,
-1);
if (*keys[0])
if ((*keys)[0])
weechat_string_dyn_concat (keys, ",", -1);
weechat_string_dyn_concat (keys, ptr_channel->key, -1);
}
else
{
/* add channel without key */
if (*channels_others[0])
if ((*channels_others)[0])
weechat_string_dyn_concat (channels_others, ",", -1);
weechat_string_dyn_concat (channels_others,
ptr_channel->name,
@@ -6096,13 +6096,13 @@ irc_server_build_autojoin (struct t_irc_server *server)
* concatenate channels_with_key + channels_others + keys
* into channels_with_key
*/
if (*channels_others[0])
if ((*channels_others)[0])
{
if (*channels_with_key[0])
if ((*channels_with_key)[0])
weechat_string_dyn_concat (channels_with_key, ",", -1);
weechat_string_dyn_concat (channels_with_key, *channels_others, -1);
}
if (*keys[0])
if ((*keys)[0])
{
weechat_string_dyn_concat (channels_with_key, " ", -1);
weechat_string_dyn_concat (channels_with_key, *keys, -1);
+1 -1
View File
@@ -301,7 +301,7 @@ irc_tag_add_to_string_cb (void *data,
string = (char **)data;
if (*string[0])
if ((*string)[0])
weechat_string_dyn_concat (string, ";", -1);
weechat_string_dyn_concat (string, key, -1);
+1 -1
View File
@@ -192,7 +192,7 @@ weechat_lua_output_flush ()
char *temp_buffer, *command;
int length;
if (!*lua_buffer_output[0])
if (!(*lua_buffer_output)[0])
return;
/* if there's no buffer, we catch the output, so there's no flush */
+1 -1
View File
@@ -229,7 +229,7 @@ weechat_perl_output_flush ()
char *temp_buffer, *command;
int length;
if (!*perl_buffer_output[0])
if (!(*perl_buffer_output)[0])
return;
/* if there's no buffer, we catch the output, so there's no flush */
+1 -1
View File
@@ -292,7 +292,7 @@ weechat_python_output_flush ()
char *temp_buffer, *command;
int length;
if (!*python_buffer_output[0])
if (!(*python_buffer_output)[0])
return;
/* if there's no buffer, we catch the output, so there's no flush */
@@ -156,7 +156,7 @@ relay_remote_build_string_tags (cJSON *json_tags, int line_id, int highlight)
ptr_tag = cJSON_GetStringValue (json_tag);
if (ptr_tag)
{
if (*tags[0])
if ((*tags)[0])
weechat_string_dyn_concat (tags, ",", -1);
if (highlight && (strncmp (ptr_tag, "notify_", 7) == 0))
{
@@ -177,14 +177,14 @@ relay_remote_build_string_tags (cJSON *json_tags, int line_id, int highlight)
*/
if (highlight && !tag_notify_highlight)
{
if (*tags[0])
if ((*tags)[0])
weechat_string_dyn_concat (tags, ",", -1);
weechat_string_dyn_concat (tags, "notify_highlight", -1);
}
/* add tag with remote line id */
snprintf (str_tag_id, sizeof (str_tag_id), "relay_remote_line_id_%d", line_id);
if (*tags[0])
if ((*tags)[0])
weechat_string_dyn_concat (tags, ",", -1);
weechat_string_dyn_concat (tags, str_tag_id, -1);
+1 -1
View File
@@ -354,7 +354,7 @@ weechat_ruby_output_flush ()
char *temp_buffer, *command;
int length;
if (!*ruby_buffer_output[0])
if (!(*ruby_buffer_output)[0])
return;
/* if there's no buffer, we catch the output, so there's no flush */
+3 -3
View File
@@ -123,7 +123,7 @@ script_action_run_list_input (struct t_gui_buffer *buffer,
ptr_script = weechat_hdata_get_list (hdata, "scripts");
while (ptr_script)
{
if (*output[0])
if ((*output)[0])
{
weechat_string_dyn_concat (output, ", ", -1);
}
@@ -152,7 +152,7 @@ script_action_run_list_input (struct t_gui_buffer *buffer,
}
}
if (!*output[0])
if (!(*output)[0])
{
weechat_string_dyn_concat (
output,
@@ -1257,7 +1257,7 @@ script_action_add (struct t_gui_buffer *buffer, const char *action)
return;
}
if (*script_actions[0])
if ((*script_actions)[0])
weechat_string_dyn_concat (script_actions, "\n", -1);
weechat_string_dyn_concat (
+1 -1
View File
@@ -54,7 +54,7 @@ typing_bar_item_nicks_map_cb (void *data,
if ((ptr_typing_status->state == TYPING_STATUS_STATE_TYPING)
|| (ptr_typing_status->state == TYPING_STATUS_STATE_PAUSED))
{
if (*str_nicks_typing[0])
if ((*str_nicks_typing)[0])
weechat_string_dyn_concat (str_nicks_typing, ", ", -1);
if (ptr_typing_status->state == TYPING_STATUS_STATE_PAUSED)
weechat_string_dyn_concat (str_nicks_typing, "(", -1);