diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-10 16:21:11 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-10 16:21:11 +0200 |
commit | 54bf589d7da7b714002bf675f20c053426544d6f (patch) | |
tree | d0ce6d388ad7cfe9eb9e8b08ff5b589425b97d44 /src/core | |
parent | 8c8a0c0826ce66c83b08baf9470a2e6a6140b201 (diff) | |
download | weechat-54bf589d7da7b714002bf675f20c053426544d6f.zip |
core, plugins: fix conditions to insert elements in linked lists
This removes scan-build warnings about dereference of last_xxx null pointers.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-config-file.c | 4 | ||||
-rw-r--r-- | src/core/wee-config.c | 12 | ||||
-rw-r--r-- | src/core/wee-infolist.c | 14 | ||||
-rw-r--r-- | src/core/wee-proxy.c | 2 | ||||
-rw-r--r-- | src/core/wee-upgrade-file.c | 2 |
5 files changed, 17 insertions, 17 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 199b0d1bc..208a4924b 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -166,7 +166,7 @@ config_file_new (struct t_weechat_plugin *plugin, const char *name, new_config_file->prev_config = last_config_file; new_config_file->next_config = NULL; - if (config_files) + if (last_config_file) last_config_file->next_config = new_config_file; else config_files = new_config_file; @@ -286,7 +286,7 @@ config_file_new_section (struct t_config_file *config_file, const char *name, new_section->prev_section = config_file->last_section; new_section->next_section = NULL; - if (config_file->sections) + if (config_file->last_section) config_file->last_section->next_section = new_section; else config_file->sections = new_section; diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 441d8ef2b..3589a042a 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -1705,10 +1705,10 @@ config_weechat_proxy_read_cb (const void *pointer, void *data, /* add new proxy at the end */ ptr_temp_proxy->prev_proxy = last_weechat_temp_proxy; ptr_temp_proxy->next_proxy = NULL; - if (!weechat_temp_proxies) - weechat_temp_proxies = ptr_temp_proxy; - else + if (last_weechat_temp_proxy) last_weechat_temp_proxy->next_proxy = ptr_temp_proxy; + else + weechat_temp_proxies = ptr_temp_proxy; last_weechat_temp_proxy = ptr_temp_proxy; } } @@ -1785,10 +1785,10 @@ config_weechat_bar_read_cb (const void *pointer, void *data, /* add new bar at the end */ ptr_temp_bar->prev_bar = last_gui_temp_bar; ptr_temp_bar->next_bar = NULL; - if (!gui_temp_bars) - gui_temp_bars = ptr_temp_bar; - else + if (last_gui_temp_bar) last_gui_temp_bar->next_bar = ptr_temp_bar; + else + gui_temp_bars = ptr_temp_bar; last_gui_temp_bar = ptr_temp_bar; } } diff --git a/src/core/wee-infolist.c b/src/core/wee-infolist.c index 99678cfbb..bf393e11c 100644 --- a/src/core/wee-infolist.c +++ b/src/core/wee-infolist.c @@ -57,7 +57,7 @@ infolist_new (struct t_weechat_plugin *plugin) new_infolist->prev_infolist = last_weechat_infolist; new_infolist->next_infolist = NULL; - if (weechat_infolists) + if (last_weechat_infolist) last_weechat_infolist->next_infolist = new_infolist; else weechat_infolists = new_infolist; @@ -114,7 +114,7 @@ infolist_new_item (struct t_infolist *infolist) new_item->prev_item = infolist->last_item; new_item->next_item = NULL; - if (infolist->items) + if (infolist->last_item) infolist->last_item->next_item = new_item; else infolist->items = new_item; @@ -150,7 +150,7 @@ infolist_new_var_integer (struct t_infolist_item *item, new_var->prev_var = item->last_var; new_var->next_var = NULL; - if (item->vars) + if (item->last_var) item->last_var->next_var = new_var; else item->vars = new_var; @@ -184,7 +184,7 @@ infolist_new_var_string (struct t_infolist_item *item, new_var->prev_var = item->last_var; new_var->next_var = NULL; - if (item->vars) + if (item->last_var) item->last_var->next_var = new_var; else item->vars = new_var; @@ -218,7 +218,7 @@ infolist_new_var_pointer (struct t_infolist_item *item, new_var->prev_var = item->last_var; new_var->next_var = NULL; - if (item->vars) + if (item->last_var) item->last_var->next_var = new_var; else item->vars = new_var; @@ -255,7 +255,7 @@ infolist_new_var_buffer (struct t_infolist_item *item, new_var->prev_var = item->last_var; new_var->next_var = NULL; - if (item->vars) + if (item->last_var) item->last_var->next_var = new_var; else item->vars = new_var; @@ -291,7 +291,7 @@ infolist_new_var_time (struct t_infolist_item *item, new_var->prev_var = item->last_var; new_var->next_var = NULL; - if (item->vars) + if (item->last_var) item->last_var->next_var = new_var; else item->vars = new_var; diff --git a/src/core/wee-proxy.c b/src/core/wee-proxy.c index 57489daa3..2bb1b1880 100644 --- a/src/core/wee-proxy.c +++ b/src/core/wee-proxy.c @@ -403,7 +403,7 @@ proxy_new_with_options (const char *name, /* add proxy to proxies list */ new_proxy->prev_proxy = last_weechat_proxy; - if (weechat_proxies) + if (last_weechat_proxy) last_weechat_proxy->next_proxy = new_proxy; else weechat_proxies = new_proxy; diff --git a/src/core/wee-upgrade-file.c b/src/core/wee-upgrade-file.c index 89694c8f6..d2bfbd69d 100644 --- a/src/core/wee-upgrade-file.c +++ b/src/core/wee-upgrade-file.c @@ -245,7 +245,7 @@ upgrade_file_new (const char *filename, /* add upgrade file to list of upgrade files */ new_upgrade_file->prev_upgrade = last_upgrade_file; new_upgrade_file->next_upgrade = NULL; - if (upgrade_files) + if (last_upgrade_file) last_upgrade_file->next_upgrade = new_upgrade_file; else upgrade_files = new_upgrade_file; |