[evolution/wip/tpopela/composer-dnd: 5/7] Fix issues found by Coverity scan



commit c087f056c5cc638d9a67f6839e28c0e6827f1f41
Author: Tomas Popela <tpopela redhat com>
Date:   Wed Mar 15 13:54:20 2017 +0100

    Fix issues found by Coverity scan

 src/mail/e-mail-display.c                          |    2 +-
 src/modules/webkit-editor/e-webkit-editor.c        |    6 +--
 .../web-extension/e-editor-dom-functions.c         |   39 ++++++--------------
 .../web-extension/e-editor-undo-redo-manager.c     |    7 ++--
 src/web-extensions/e-dom-utils.c                   |    2 +-
 5 files changed, 20 insertions(+), 36 deletions(-)
---
diff --git a/src/mail/e-mail-display.c b/src/mail/e-mail-display.c
index d92d667..6dbc710 100644
--- a/src/mail/e-mail-display.c
+++ b/src/mail/e-mail-display.c
@@ -524,7 +524,7 @@ headers_collapsed_signal_cb (GDBusConnection *connection,
                              GVariant *parameters,
                              EMailDisplay *display)
 {
-       gboolean expanded;
+       gboolean expanded = TRUE;
 
        if (g_strcmp0 (signal_name, "HeadersCollapsed") != 0)
                return;
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 6831c1f..053fc88 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -1787,8 +1787,7 @@ webkit_editor_insert_content (EContentEditor *editor,
                }
 
                if (strstr (content, "data-evo-draft") && !(wk_editor->priv->html_mode)) {
-                       if (content && *content)
-                               set_convert_in_situ (wk_editor, TRUE);
+                       set_convert_in_situ (wk_editor, TRUE);
                        wk_editor->priv->reload_in_progress = TRUE;
                        webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk_editor), content, "file://");
                        return;
@@ -1805,8 +1804,7 @@ webkit_editor_insert_content (EContentEditor *editor,
                                        return;
                                }
                        }
-                       if (content && *content)
-                               set_convert_in_situ (wk_editor, TRUE);
+                       set_convert_in_situ (wk_editor, TRUE);
                }
 
                wk_editor->priv->reload_in_progress = TRUE;
diff --git a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 618e7a4..bd8481c 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -2720,12 +2720,9 @@ save_history_before_event_in_table (EEditorPage *editor_page,
                ev = g_new0 (EEditorHistoryEvent, 1);
                ev->type = HISTORY_TABLE_INPUT;
 
-               if (block) {
-                       e_editor_dom_selection_save (editor_page);
-                       ev->data.dom.from = g_object_ref (webkit_dom_node_clone_node_with_error 
(WEBKIT_DOM_NODE (block), TRUE, NULL));
-                       e_editor_dom_selection_restore (editor_page);
-               } else
-                       ev->data.dom.from = NULL;
+               e_editor_dom_selection_save (editor_page);
+               ev->data.dom.from = g_object_ref (webkit_dom_node_clone_node_with_error (WEBKIT_DOM_NODE 
(block), TRUE, NULL));
+               e_editor_dom_selection_restore (editor_page);
 
                e_editor_dom_selection_get_coordinates (editor_page,
                        &ev->before.start.x,
@@ -5250,7 +5247,7 @@ parse_html_into_blocks (EEditorPage *editor_page,
                if (camel_debug ("webkit:editor"))
                        printf ("\tto_process: '%s'\n", to_process);
 
-               if (!*to_process && processing_last) {
+               if (to_process && !*to_process && processing_last) {
                        g_free (to_process);
                        to_process = g_strdup (next_token);
                        next_token = NULL;
@@ -15558,7 +15555,6 @@ e_editor_dom_selection_set_monospace (EEditorPage *editor_page,
        } else {
                gboolean is_bold = FALSE, is_italic = FALSE;
                gboolean is_underline = FALSE, is_strikethrough = FALSE;
-               guint font_size = 0;
                WebKitDOMElement *tt_element;
                WebKitDOMNode *node;
 
@@ -16397,7 +16393,7 @@ process_block_to_block (EEditorPage *editor_page,
 
                                word_wrap_length =
                                        e_editor_page_get_word_wrap_length (editor_page);
-                               quote = citation_level ? citation_level * 2 : 0;
+                               quote = citation_level * 2;
 
                                element = e_editor_dom_wrap_paragraph_length (
                                        editor_page, element, word_wrap_length - quote);
@@ -16742,8 +16738,7 @@ format_change_list_from_list (EEditorPage *editor_page,
                                WEBKIT_DOM_ELEMENT (item), new_list, to);
 
                        webkit_dom_node_append_child (
-                               after_selection_end ?
-                                       source_list_clone : WEBKIT_DOM_NODE (new_list),
+                               WEBKIT_DOM_NODE (new_list),
                                WEBKIT_DOM_NODE (processed_list),
                                NULL);
                } else if (node_is_list (item) && !after_selection_end) {
@@ -16765,10 +16760,7 @@ format_change_list_from_list (EEditorPage *editor_page,
                                        WEBKIT_DOM_NODE (new_list), FALSE, NULL);
 
                                webkit_dom_node_append_child (
-                                       after_selection_end ?
-                                               source_list_clone : WEBKIT_DOM_NODE (new_list),
-                                       clone,
-                                       NULL);
+                                       WEBKIT_DOM_NODE (new_list), clone, NULL);
 
                                while ((child = webkit_dom_node_get_first_child (item))) {
                                        webkit_dom_node_append_child (clone, child, NULL);
@@ -16778,10 +16770,7 @@ format_change_list_from_list (EEditorPage *editor_page,
 
                                if (webkit_dom_node_get_first_child (item))
                                        webkit_dom_node_append_child (
-                                               after_selection_end ?
-                                                       source_list_clone : WEBKIT_DOM_NODE (new_list),
-                                               item,
-                                               NULL);
+                                               WEBKIT_DOM_NODE (new_list), item, NULL);
                                else
                                        remove_node (item);
                        } else {
@@ -17606,10 +17595,8 @@ e_editor_dom_selection_get_coordinates (EEditorPage *editor_page,
                parent = webkit_dom_element_get_offset_parent (parent);
        }
 
-       if (start_x)
-               *start_x = local_x;
-       if (start_y)
-               *start_y = local_y;
+       *start_x = local_x;
+       *start_y = local_y;
 
        if (e_editor_dom_selection_is_collapsed (editor_page)) {
                *end_x = local_x;
@@ -17634,10 +17621,8 @@ e_editor_dom_selection_get_coordinates (EEditorPage *editor_page,
                parent = webkit_dom_element_get_offset_parent (parent);
        }
 
-       if (end_x)
-               *end_x = local_x;
-       if (end_y)
-               *end_y = local_y;
+       *end_x = local_x;
+       *end_y = local_y;
 
        if (created_selection_markers)
                e_editor_dom_selection_restore (editor_page);
diff --git a/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c 
b/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
index 5d80228..541ff49 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
@@ -1723,11 +1723,12 @@ undo_redo_replace_all (EEditorUndoRedoManager *manager,
                        if (prev_event->type == HISTORY_REPLACE) {
                                undo_redo_replace (editor_page, prev_event, undo);
                                prev_item = prev_item->prev;
-                       } else
+                       } else {
+                               manager->priv->history = prev_item->next;
                                break;
+                       }
                }
 
-               manager->priv->history = prev_item->next;
        }
 }
 
@@ -2731,7 +2732,7 @@ e_editor_undo_redo_manager_redo (EEditorUndoRedoManager *manager)
                        return;
        }
 
-       if (history->prev && history->prev->prev) {
+       if (history->prev->prev) {
                event = history->prev->prev->data;
                if (event->type == HISTORY_AND) {
                        manager->priv->history = manager->priv->history->prev->prev;
diff --git a/src/web-extensions/e-dom-utils.c b/src/web-extensions/e-dom-utils.c
index 96e8b03..3fdcadc 100644
--- a/src/web-extensions/e-dom-utils.c
+++ b/src/web-extensions/e-dom-utils.c
@@ -522,7 +522,7 @@ e_dom_utils_add_css_rule_into_style_sheet_in_document (WebKitDOMDocument *docume
                rule_text = webkit_dom_css_rule_get_css_text (rule);
 
                /* Find the start of the style => end of the selector */
-               if (rule_text && selector && g_str_has_prefix (rule_text, selector) &&
+               if (rule_text && g_str_has_prefix (rule_text, selector) &&
                    rule_text[selector_length] == ' ' && rule_text[selector_length + 1] == '{') {
                        /* If exists remove it */
                        webkit_dom_css_style_sheet_remove_rule (


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]