diff options
author | Milan Crha <mcrha@redhat.com> | 2013-11-15 16:06:57 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-11-15 16:06:57 +0800 |
commit | 570c6374806d0f1ec59cf7a72543efe6b5b637be (patch) | |
tree | c5390b1fcb73f30c28bf37168add9bf1dc622b42 /e-util | |
parent | 1be51f232560f864ba8795a38e55d472b5b0e2b3 (diff) | |
download | gsoc2013-evolution-570c6374806d0f1ec59cf7a72543efe6b5b637be.tar gsoc2013-evolution-570c6374806d0f1ec59cf7a72543efe6b5b637be.tar.gz gsoc2013-evolution-570c6374806d0f1ec59cf7a72543efe6b5b637be.tar.bz2 gsoc2013-evolution-570c6374806d0f1ec59cf7a72543efe6b5b637be.tar.lz gsoc2013-evolution-570c6374806d0f1ec59cf7a72543efe6b5b637be.tar.xz gsoc2013-evolution-570c6374806d0f1ec59cf7a72543efe6b5b637be.tar.zst gsoc2013-evolution-570c6374806d0f1ec59cf7a72543efe6b5b637be.zip |
Fix/mute issues found by Coverity scan
This makes the code free of Coverity scan issues.
It is sometimes quite pedantic and expects/suggests some
coding habits, thus certain changes may look weird, but for a good
thing, I hope. The code is also tagged with Coverity scan
suppressions, to keep the code as is and hide the warning too.
Also note that Coverity treats g_return_if_fail(), g_assert() and
similar macros as unreliable, and it's true these can be disabled
during the compile time, thus it brings in other set of 'weird'
changes.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-attachment-store.c | 12 | ||||
-rw-r--r-- | e-util/e-attachment.c | 17 | ||||
-rw-r--r-- | e-util/e-canvas-background.c | 14 | ||||
-rw-r--r-- | e-util/e-canvas.c | 12 | ||||
-rw-r--r-- | e-util/e-cell-text.c | 8 | ||||
-rw-r--r-- | e-util/e-filter-color.c | 3 | ||||
-rw-r--r-- | e-util/e-filter-rule.c | 6 | ||||
-rw-r--r-- | e-util/e-misc-utils.c | 1 | ||||
-rw-r--r-- | e-util/e-name-selector-list.c | 5 | ||||
-rw-r--r-- | e-util/e-send-options.c | 2 | ||||
-rw-r--r-- | e-util/e-stock-request.c | 7 | ||||
-rw-r--r-- | e-util/e-table-click-to-add.c | 1 | ||||
-rw-r--r-- | e-util/e-table-config.c | 2 | ||||
-rw-r--r-- | e-util/e-table-group-container.c | 2 | ||||
-rw-r--r-- | e-util/e-table-header-item.c | 2 | ||||
-rw-r--r-- | e-util/e-table-header-utils.c | 1 | ||||
-rw-r--r-- | e-util/e-table-item.c | 9 | ||||
-rw-r--r-- | e-util/e-text.c | 9 | ||||
-rw-r--r-- | e-util/gal-a11y-e-cell-tree.c | 8 | ||||
-rw-r--r-- | e-util/gal-a11y-e-cell.c | 5 | ||||
-rw-r--r-- | e-util/gal-a11y-e-table-item.c | 61 | ||||
-rw-r--r-- | e-util/test-calendar.c | 7 |
22 files changed, 112 insertions, 82 deletions
diff --git a/e-util/e-attachment-store.c b/e-util/e-attachment-store.c index 3720baf16b..c7128ec182 100644 --- a/e-util/e-attachment-store.c +++ b/e-util/e-attachment-store.c @@ -824,8 +824,10 @@ e_attachment_store_get_uris_finish (EAttachmentStore *store, g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) + return NULL; + uris = g_simple_async_result_get_op_res_gpointer (simple); - g_simple_async_result_propagate_error (simple, error); return uris; } @@ -982,8 +984,8 @@ e_attachment_store_load_finish (EAttachmentStore *store, g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE); simple = G_SIMPLE_ASYNC_RESULT (result); - success = g_simple_async_result_get_op_res_gboolean (simple); - g_simple_async_result_propagate_error (simple, error); + success = !g_simple_async_result_propagate_error (simple, error) && + g_simple_async_result_get_op_res_gboolean (simple); return success; } @@ -1332,8 +1334,10 @@ e_attachment_store_save_finish (EAttachmentStore *store, g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) + return NULL; + uris = g_simple_async_result_get_op_res_gpointer (simple); - g_simple_async_result_propagate_error (simple, error); return uris; } diff --git a/e-util/e-attachment.c b/e-util/e-attachment.c index e2b64ab92b..42d5e93caf 100644 --- a/e-util/e-attachment.c +++ b/e-util/e-attachment.c @@ -2191,6 +2191,11 @@ e_attachment_load_finish (EAttachment *attachment, g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE); simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) { + attachment_set_loading (attachment, FALSE); + return FALSE; + } + load_context = g_simple_async_result_get_op_res_gpointer (simple); if (load_context != NULL && load_context->mime_part != NULL) { @@ -2206,8 +2211,6 @@ e_attachment_load_finish (EAttachment *attachment, attachment, load_context->mime_part); } - g_simple_async_result_propagate_error (simple, error); - attachment_set_loading (attachment, FALSE); return (load_context != NULL); @@ -2529,8 +2532,8 @@ e_attachment_open_finish (EAttachment *attachment, g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE); simple = G_SIMPLE_ASYNC_RESULT (result); - success = g_simple_async_result_get_op_res_gboolean (simple); - g_simple_async_result_propagate_error (simple, error); + success = !g_simple_async_result_propagate_error (simple, error) && + g_simple_async_result_get_op_res_gboolean (simple); return success; } @@ -3066,10 +3069,14 @@ e_attachment_save_finish (EAttachment *attachment, g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) { + attachment_set_saving (attachment, FALSE); + return NULL; + } + destination = g_simple_async_result_get_op_res_gpointer (simple); if (destination != NULL) g_object_ref (destination); - g_simple_async_result_propagate_error (simple, error); attachment_set_saving (attachment, FALSE); diff --git a/e-util/e-canvas-background.c b/e-util/e-canvas-background.c index 6379697719..0c5c28a282 100644 --- a/e-util/e-canvas-background.c +++ b/e-util/e-canvas-background.c @@ -121,13 +121,13 @@ ecb_set_property (GObject *object, switch (property_id) { case PROP_FILL_COLOR: - if (g_value_get_string (value)) - gdk_color_parse (g_value_get_string (value), &color); - - ecb->priv->rgba = ((color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00) | - 0xff); + if (g_value_get_string (value) && + gdk_color_parse (g_value_get_string (value), &color)) { + ecb->priv->rgba = ((color.red & 0xff00) << 16 | + (color.green & 0xff00) << 8 | + (color.blue & 0xff00) | + 0xff); + } break; case PROP_FILL_COLOR_GDK: diff --git a/e-util/e-canvas.c b/e-util/e-canvas.c index 93304065e3..2bac10fac6 100644 --- a/e-util/e-canvas.c +++ b/e-util/e-canvas.c @@ -678,14 +678,12 @@ e_canvas_item_grab_focus (GnomeCanvasItem *item, gtk_widget_grab_focus (GTK_WIDGET (item->canvas)); } - if (item) { - ev.focus_change.type = GDK_FOCUS_CHANGE; - ev.focus_change.window = bin_window; - ev.focus_change.send_event = FALSE; - ev.focus_change.in = TRUE; + ev.focus_change.type = GDK_FOCUS_CHANGE; + ev.focus_change.window = bin_window; + ev.focus_change.send_event = FALSE; + ev.focus_change.in = TRUE; - canvas_emit_event (item->canvas, &ev); - } + canvas_emit_event (item->canvas, &ev); } static void diff --git a/e-util/e-cell-text.c b/e-util/e-cell-text.c index 6026185e9a..d7e38ebe9c 100644 --- a/e-util/e-cell-text.c +++ b/e-util/e-cell-text.c @@ -467,7 +467,7 @@ layout_with_preedit (ECellTextView *text_view, edit->im_context, &preedit_string,&preedit_attrs, NULL); - preedit_length = edit->preedit_length = strlen (preedit_string);; + preedit_length = edit->preedit_length = preedit_string ? strlen (preedit_string) : 0; layout = edit->layout; @@ -2237,12 +2237,10 @@ _get_position (ECellTextView *text_view, case E_TEP_BACKWARD_PAGE: return edit->selection_end; default: - return edit->selection_end; + break; } - g_return_val_if_reached (0); - - return 0; /* Kill warning */ + return edit->selection_end; } static void diff --git a/e-util/e-filter-color.c b/e-util/e-filter-color.c index 213530fbb2..63c27b7079 100644 --- a/e-util/e-filter-color.c +++ b/e-util/e-filter-color.c @@ -84,7 +84,8 @@ filter_color_xml_decode (EFilterElement *element, prop = xmlGetProp (node, (xmlChar *)"spec"); if (prop != NULL) { - gdk_color_parse ((gchar *) prop, &fc->color); + if (!gdk_color_parse ((gchar *) prop, &fc->color)) + g_warning ("%s: Failed to parse color from string '%s'", G_STRFUNC, prop); xmlFree (prop); } else { /* try reading the old RGB properties */ diff --git a/e-util/e-filter-rule.c b/e-util/e-filter-rule.c index 8dc9a17a8a..842cf63061 100644 --- a/e-util/e-filter-rule.c +++ b/e-util/e-filter-rule.c @@ -100,7 +100,11 @@ part_combobox_changed (GtkComboBox *combobox, /* traverse until reached index */ } - g_return_if_fail (part != NULL); + if (!part) { + g_warn_if_reached (); + return; + } + g_return_if_fail (i == index); /* dont update if we haven't changed */ diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c index 1ae9301aa3..1e9cd1d0c1 100644 --- a/e-util/e-misc-utils.c +++ b/e-util/e-misc-utils.c @@ -1232,6 +1232,7 @@ e_format_number (gint number) default: last_count = *grouping; grouping++; + /* coverity[fallthrough] */ case 0: divider = epow10 (last_count); if (number >= divider) { diff --git a/e-util/e-name-selector-list.c b/e-util/e-name-selector-list.c index 52516a5621..8e51e41667 100644 --- a/e-util/e-name-selector-list.c +++ b/e-util/e-name-selector-list.c @@ -465,8 +465,9 @@ enl_tree_button_press_event (GtkWidget *widget, if (!gtk_widget_has_grab (GTK_WIDGET (list->priv->popup))) enl_popup_grab (list, (GdkEvent *) event); - gtk_tree_view_get_dest_row_at_pos ( - tree_view, event->x, event->y, &path, NULL); + if (!gtk_tree_view_get_dest_row_at_pos ( + tree_view, event->x, event->y, &path, NULL)) + return FALSE; selection = gtk_tree_view_get_selection (tree_view); if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path)) return FALSE; diff --git a/e-util/e-send-options.c b/e-util/e-send-options.c index f586f36f66..c105571f1c 100644 --- a/e-util/e-send-options.c +++ b/e-util/e-send-options.c @@ -573,6 +573,7 @@ setup_widgets (ESendOptionsDialog *sod, priv->help_section = g_strdup ("groupwise-placeholder"); gtk_widget_hide (priv->completed_label); gtk_widget_hide (priv->when_completed); + break; case E_ITEM_TASK: priv->help_section = g_strdup ("groupwise-placeholder"); gtk_widget_hide (priv->security_label); @@ -636,6 +637,7 @@ e_send_options_cb (GtkDialog *dialog, switch (state) { case GTK_RESPONSE_OK: e_send_options_get_widgets_data (sod); + /* coverity[fallthrough] */ case GTK_RESPONSE_CANCEL: gtk_widget_hide (priv->main); gtk_widget_destroy (priv->main); diff --git a/e-util/e-stock-request.c b/e-util/e-stock-request.c index 0ce7d8c254..b8cb21ba87 100644 --- a/e-util/e-stock-request.c +++ b/e-util/e-stock-request.c @@ -107,8 +107,11 @@ handle_stock_request_idle_cb (gpointer user_data) filename = gtk_icon_info_get_filename (icon_info); if (filename != NULL) { - g_file_get_contents ( - filename, &buffer, &buff_len, &local_error); + if (!g_file_get_contents ( + filename, &buffer, &buff_len, &local_error)) { + buffer = NULL; + buff_len = 0; + } priv->content_type = g_content_type_guess (filename, NULL, 0, NULL); diff --git a/e-util/e-table-click-to-add.c b/e-util/e-table-click-to-add.c index d5202f7a03..c9abf037c5 100644 --- a/e-util/e-table-click-to-add.c +++ b/e-util/e-table-click-to-add.c @@ -437,6 +437,7 @@ etcta_event (GnomeCanvasItem *item, case GDK_FOCUS_CHANGE: if (!e->focus_change.in) return TRUE; + /* coverity[fallthrough] */ case GDK_BUTTON_PRESS: if (etcta->text) { diff --git a/e-util/e-table-config.c b/e-util/e-table-config.c index 5fbb6b0329..8c5fecd90a 100644 --- a/e-util/e-table-config.c +++ b/e-util/e-table-config.c @@ -231,7 +231,7 @@ static ETableColumnSpecification * find_column_spec_by_name (ETableSpecification *spec, const gchar *s) { - ETableColumnSpecification *column; + ETableColumnSpecification *column = NULL; GPtrArray *array; guint ii; diff --git a/e-util/e-table-group-container.c b/e-util/e-table-group-container.c index d828ddec3e..426c544a63 100644 --- a/e-util/e-table-group-container.c +++ b/e-util/e-table-group-container.c @@ -1453,7 +1453,7 @@ e_table_group_container_print_page (EPrintable *ep, break; } - child = child->next; + child = child ? child->next : NULL; if (!child) { child_printable = NULL; break; diff --git a/e-util/e-table-header-item.c b/e-util/e-table-header-item.c index 06d003007b..556c8a2e35 100644 --- a/e-util/e-table-header-item.c +++ b/e-util/e-table-header-item.c @@ -1222,7 +1222,7 @@ static void ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event) { - GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); + GtkWidget *widget; GtkTargetList *list; GdkDragContext *context; ETableCol *ecol; diff --git a/e-util/e-table-header-utils.c b/e-util/e-table-header-utils.c index 66efb01d30..5baf7f1a37 100644 --- a/e-util/e-table-header-utils.c +++ b/e-util/e-table-header-utils.c @@ -272,6 +272,7 @@ e_table_header_draw_button (cairo_t *cr, break; } + /* coverity[dead_error_begin] */ default: cairo_restore (cr); g_return_if_reached (); diff --git a/e-util/e-table-item.c b/e-util/e-table-item.c index 3f88d8cb7e..1a1956fdcc 100644 --- a/e-util/e-table-item.c +++ b/e-util/e-table-item.c @@ -3076,9 +3076,12 @@ eti_event (GnomeCanvasItem *item, e_table_item_leave_edit_(eti); } } + return_val = FALSE; + break; default: return_val = FALSE; + break; } /* d(g_print("%s: returning: %s\n", __FUNCTION__, return_val?"true":"false"));*/ @@ -3601,9 +3604,11 @@ e_table_item_enter_edit (ETableItem *eti, eti->editing_col = col; eti->editing_row = row; - eti->edit_ctx = e_cell_enter_edit (eti->cell_views[col], view_to_model_col (eti, col), col, row); + if (col >= 0) { + eti->edit_ctx = e_cell_enter_edit (eti->cell_views[col], view_to_model_col (eti, col), col, row); - g_object_notify (G_OBJECT (eti), "is-editing"); + g_object_notify (G_OBJECT (eti), "is-editing"); + } } /** diff --git a/e-util/e-text.c b/e-util/e-text.c index d13b4a637e..3fda17268d 100644 --- a/e-util/e-text.c +++ b/e-util/e-text.c @@ -726,8 +726,11 @@ e_text_set_property (GObject *object, break; case PROP_FILL_COLOR: - if (g_value_get_string (value)) - gdk_color_parse (g_value_get_string (value), &color); + if (g_value_get_string (value) && + !gdk_color_parse (g_value_get_string (value), &color)) { + g_warning ("%s: Failed to parse color '%s'", G_STRFUNC, g_value_get_string (value)); + break; + } text->rgba = ((color.red & 0xff00) << 16 | (color.green & 0xff00) << 8 | @@ -1275,7 +1278,7 @@ e_text_draw (GnomeCanvasItem *item, if (text->editing) { if (text->selection_start != text->selection_end) { - cairo_region_t *clip_region = cairo_region_create (); + cairo_region_t *clip_region; gint indices[2]; GtkStateType state; diff --git a/e-util/gal-a11y-e-cell-tree.c b/e-util/gal-a11y-e-cell-tree.c index e0757f5300..07d6ac331b 100644 --- a/e-util/gal-a11y-e-cell-tree.c +++ b/e-util/gal-a11y-e-cell-tree.c @@ -191,15 +191,14 @@ gal_a11y_e_cell_tree_new (ETableItem *item, { AtkObject *subcell_a11y; GalA11yECellTree *a11y; - ETreePath node; ETreeModel *tree_model; ETreeTableAdapter *tree_table_adapter; - ECellView *subcell_view; + subcell_view = e_cell_tree_view_get_subcell_view (cell_view); - if (subcell_view->ecell) { + if (subcell_view && subcell_view->ecell) { subcell_a11y = gal_a11y_e_cell_registry_get_object ( NULL, item, @@ -233,8 +232,7 @@ gal_a11y_e_cell_tree_new (ETableItem *item, if (e_tree_table_adapter_node_is_expanded (tree_table_adapter, node)) gal_a11y_e_cell_add_state (GAL_A11Y_E_CELL (subcell_a11y), ATK_STATE_EXPANDED, FALSE); } - } - else + } else subcell_a11y = NULL; /* create a companion a11y object, this object has type GalA11yECellTree diff --git a/e-util/gal-a11y-e-cell.c b/e-util/gal-a11y-e-cell.c index 9f16b34fd9..b05f38d750 100644 --- a/e-util/gal-a11y-e-cell.c +++ b/e-util/gal-a11y-e-cell.c @@ -359,7 +359,10 @@ gal_a11y_e_cell_remove_action_by_name (GalA11yECell *cell, } } - g_return_val_if_fail (list_node != NULL, FALSE); + if (!list_node) { + g_warn_if_reached (); + return FALSE; + } _gal_a11y_e_cell_destroy_action_info (list_node->data, NULL); cell->action_list = g_list_remove_link (cell->action_list, list_node); diff --git a/e-util/gal-a11y-e-table-item.c b/e-util/gal-a11y-e-table-item.c index 51bce1725b..c3bbded403 100644 --- a/e-util/gal-a11y-e-table-item.c +++ b/e-util/gal-a11y-e-table-item.c @@ -1141,41 +1141,38 @@ gal_a11y_e_table_item_new (ETableItem *item) if (GET_PRIVATE (a11y)->columns == NULL) return NULL; - if (item) { - g_signal_connect ( - item, "selection_model_removed", - G_CALLBACK (eti_a11y_selection_model_removed_cb), NULL); + g_signal_connect ( + item, "selection_model_removed", + G_CALLBACK (eti_a11y_selection_model_removed_cb), NULL); + g_signal_connect ( + item, "selection_model_added", + G_CALLBACK (eti_a11y_selection_model_added_cb), NULL); + if (item->selection) + gal_a11y_e_table_item_ref_selection ( + a11y, + item->selection); + + /* find the TableItem's parent: table or tree */ + GET_PRIVATE (a11y)->widget = gtk_widget_get_parent ( + GTK_WIDGET (item->parent.canvas)); + parent = gtk_widget_get_accessible (GET_PRIVATE (a11y)->widget); + name = atk_object_get_name (parent); + if (name) + atk_object_set_name (accessible, name); + atk_object_set_parent (accessible, parent); + + if (E_IS_TREE (GET_PRIVATE (a11y)->widget)) { + ETreeModel *model; + model = e_tree_get_model (E_TREE (GET_PRIVATE (a11y)->widget)); g_signal_connect ( - item, "selection_model_added", - G_CALLBACK (eti_a11y_selection_model_added_cb), NULL); - if (item->selection) - gal_a11y_e_table_item_ref_selection ( - a11y, - item->selection); - - /* find the TableItem's parent: table or tree */ - GET_PRIVATE (a11y)->widget = gtk_widget_get_parent ( - GTK_WIDGET (item->parent.canvas)); - parent = gtk_widget_get_accessible (GET_PRIVATE (a11y)->widget); - name = atk_object_get_name (parent); - if (name) - atk_object_set_name (accessible, name); - atk_object_set_parent (accessible, parent); - - if (E_IS_TREE (GET_PRIVATE (a11y)->widget)) { - ETreeModel *model; - model = e_tree_get_model (E_TREE (GET_PRIVATE (a11y)->widget)); - g_signal_connect ( - model, "node_changed", - G_CALLBACK (eti_tree_model_node_changed_cb), item); - accessible->role = ATK_ROLE_TREE_TABLE; - } else if (E_IS_TABLE (GET_PRIVATE (a11y)->widget)) { - accessible->role = ATK_ROLE_TABLE; - } + model, "node_changed", + G_CALLBACK (eti_tree_model_node_changed_cb), item); + accessible->role = ATK_ROLE_TREE_TABLE; + } else if (E_IS_TABLE (GET_PRIVATE (a11y)->widget)) { + accessible->role = ATK_ROLE_TABLE; } - if (item) - g_object_weak_ref (G_OBJECT (item), item_finalized, g_object_ref (a11y)); + g_object_weak_ref (G_OBJECT (item), item_finalized, g_object_ref (a11y)); esm = item->selection; diff --git a/e-util/test-calendar.c b/e-util/test-calendar.c index 9d36e9027a..790b710104 100644 --- a/e-util/test-calendar.c +++ b/e-util/test-calendar.c @@ -108,10 +108,13 @@ on_date_range_changed (ECalendarItem *calitem) gint start_year, start_month, start_day; gint end_year, end_month, end_day; - e_calendar_item_get_date_range ( + if (!e_calendar_item_get_date_range ( calitem, &start_year, &start_month, &start_day, - &end_year, &end_month, &end_day); + &end_year, &end_month, &end_day)) { + g_warning ("%s: Failed to get date range", G_STRFUNC); + return; + } g_print ( "Date range changed (D/M/Y): %i/%i/%i - %i/%i/%i\n", |