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/gui | |
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/gui')
-rw-r--r-- | src/gui/gui-bar-item.c | 2 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 8 | ||||
-rw-r--r-- | src/gui/gui-filter.c | 2 | ||||
-rw-r--r-- | src/gui/gui-layout.c | 4 | ||||
-rw-r--r-- | src/gui/gui-line.c | 6 | ||||
-rw-r--r-- | src/gui/gui-window.c | 2 |
6 files changed, 12 insertions, 12 deletions
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index f9e59b285..33b6e9113 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -557,7 +557,7 @@ gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name, /* add bar item to bar items queue */ new_bar_item->prev_item = last_gui_bar_item; - if (gui_bar_items) + if (last_gui_bar_item) last_gui_bar_item->next_item = new_bar_item; else gui_bar_items = new_bar_item; diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 54a52a2cf..f30a78db7 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -501,7 +501,7 @@ gui_buffer_insert (struct t_gui_buffer *buffer) } buffer->prev_buffer = last_gui_buffer; buffer->next_buffer = NULL; - if (gui_buffers) + if (last_gui_buffer) last_gui_buffer->next_buffer = buffer; else gui_buffers = buffer; @@ -3670,7 +3670,7 @@ gui_buffer_sort_by_layout_number () /* move the buffer in a temporary list */ ptr_buffer->prev_buffer = last_extra_buffer; ptr_buffer->next_buffer = NULL; - if (extra_buffers) + if (last_extra_buffer) last_extra_buffer->next_buffer = ptr_buffer; else extra_buffers = ptr_buffer; @@ -3807,7 +3807,7 @@ gui_buffer_undo_add (struct t_gui_buffer *buffer) /* add undo to the list */ new_undo->prev_undo = buffer->last_input_undo; new_undo->next_undo = NULL; - if (buffer->input_undo) + if (buffer->last_input_undo) (buffer->last_input_undo)->next_undo = new_undo; else buffer->input_undo = new_undo; @@ -4014,7 +4014,7 @@ gui_buffer_visited_add (struct t_gui_buffer *buffer) new_buffer_visited->prev_buffer = last_gui_buffer_visited; new_buffer_visited->next_buffer = NULL; - if (gui_buffers_visited) + if (last_gui_buffer_visited) last_gui_buffer_visited->next_buffer = new_buffer_visited; else gui_buffers_visited = new_buffer_visited; diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c index e32f2be4a..15338b022 100644 --- a/src/gui/gui-filter.c +++ b/src/gui/gui-filter.c @@ -417,7 +417,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name, /* add filter to filters list */ new_filter->prev_filter = last_gui_filter; - if (gui_filters) + if (last_gui_filter) last_gui_filter->next_filter = new_filter; else gui_filters = new_filter; diff --git a/src/gui/gui-layout.c b/src/gui/gui-layout.c index 4ca295a87..2a0128f55 100644 --- a/src/gui/gui-layout.c +++ b/src/gui/gui-layout.c @@ -122,7 +122,7 @@ gui_layout_add (struct t_gui_layout *layout) layout->prev_layout = last_gui_layout; layout->next_layout = NULL; - if (gui_layouts) + if (last_gui_layout) last_gui_layout->next_layout = layout; else gui_layouts = layout; @@ -234,7 +234,7 @@ gui_layout_buffer_add (struct t_gui_layout *layout, /* add layout buffer to list */ new_layout_buffer->prev_layout = layout->last_layout_buffer; - if (layout->layout_buffers) + if (layout->last_layout_buffer) (layout->last_layout_buffer)->next_layout = new_layout_buffer; else layout->layout_buffers = new_layout_buffer; diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 63cfa6523..c34a7a970 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -937,10 +937,10 @@ gui_line_add_to_list (struct t_gui_lines *lines, { int prefix_length, prefix_is_nick; - if (!lines->first_line) - lines->first_line = line; - else + if (lines->last_line) (lines->last_line)->next_line = line; + else + lines->first_line = line; line->prev_line = lines->last_line; line->next_line = NULL; lines->last_line = line; diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index f3aaafc31..722dce13e 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -678,7 +678,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer, /* add window to windows queue */ new_window->prev_window = last_gui_window; - if (gui_windows) + if (last_gui_window) last_gui_window->next_window = new_window; else gui_windows = new_window; |