aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2013-11-15 16:06:57 +0800
committerMilan Crha <mcrha@redhat.com>2013-11-15 16:06:57 +0800
commit570c6374806d0f1ec59cf7a72543efe6b5b637be (patch)
treec5390b1fcb73f30c28bf37168add9bf1dc622b42 /addressbook
parent1be51f232560f864ba8795a38e55d472b5b0e2b3 (diff)
downloadgsoc2013-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 'addressbook')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c38
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c60
-rw-r--r--addressbook/printing/Makefile.am21
-rw-r--r--addressbook/printing/test-print.c51
-rw-r--r--addressbook/tools/evolution-addressbook-export-list-folders.c2
5 files changed, 54 insertions, 118 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 1a771fe98b..27c0f5b5c2 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -433,6 +433,7 @@ style_makes_sense (const EContactName *name,
else
return FALSE;
}
+ return FALSE;
case 3:
if (company && *company)
return TRUE;
@@ -1125,7 +1126,7 @@ extract_email (EContactEditor *editor)
{
GList *attr_list = NULL;
GList *old_attr_list;
- GList *l, *l_next;
+ GList *ll;
gint i;
for (i = 1; i <= EMAIL_SLOTS; i++) {
@@ -1157,14 +1158,12 @@ extract_email (EContactEditor *editor)
/* Splice in the old attributes, minus the EMAIL_SLOTS first */
old_attr_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL);
- for (l = old_attr_list, i = 1; l && i <= EMAIL_SLOTS; l = l_next, i++) {
- l_next = g_list_next (l);
-
- e_vcard_attribute_free (l->data);
- l = g_list_delete_link (l, l);
+ for (ll = old_attr_list, i = 1; ll && i <= EMAIL_SLOTS; i++) {
+ e_vcard_attribute_free (ll->data);
+ ll = g_list_delete_link (ll, ll);
}
- old_attr_list = l;
+ old_attr_list = ll;
attr_list = g_list_concat (attr_list, old_attr_list);
e_contact_set_attributes (editor->contact, E_CONTACT_EMAIL, attr_list);
@@ -1468,7 +1467,7 @@ extract_phone (EContactEditor *editor)
{
GList *attr_list = NULL;
GList *old_attr_list;
- GList *l, *l_next;
+ GList *ll;
gint i;
for (i = 1; i <= PHONE_SLOTS; i++) {
@@ -1509,14 +1508,12 @@ extract_phone (EContactEditor *editor)
/* Splice in the old attributes, minus the PHONE_SLOTS first */
old_attr_list = get_attributes_named (E_VCARD (editor->contact), "TEL");
- for (l = old_attr_list, i = 1; l && i <= PHONE_SLOTS; l = l_next, i++) {
- l_next = g_list_next (l);
-
- e_vcard_attribute_free (l->data);
- l = g_list_delete_link (l, l);
+ for (ll = old_attr_list, i = 1; ll && i <= PHONE_SLOTS; i++) {
+ e_vcard_attribute_free (ll->data);
+ ll = g_list_delete_link (ll, ll);
}
- old_attr_list = l;
+ old_attr_list = ll;
attr_list = g_list_concat (attr_list, old_attr_list);
set_attributes_named (E_VCARD (editor->contact), "TEL", attr_list);
@@ -1913,7 +1910,7 @@ extract_im (EContactEditor *editor)
for (i = 0; i < G_N_ELEMENTS (im_service); i++) {
GList *old_service_attr_list;
gint filled_in_slots;
- GList *l, *l_next;
+ GList *ll;
gint j;
/* Splice in the old attributes, minus the filled_in_slots first */
@@ -1925,15 +1922,14 @@ extract_im (EContactEditor *editor)
g_list_length (old_service_attr_list));
remaining_slots -= filled_in_slots;
- for (l = old_service_attr_list, j = 0;
- l && j < filled_in_slots; l = l_next, j++) {
- l_next = g_list_next (l);
+ for (ll = old_service_attr_list, j = 0;
+ ll && j < filled_in_slots; j++) {
- e_vcard_attribute_free (l->data);
- l = g_list_delete_link (l, l);
+ e_vcard_attribute_free (ll->data);
+ ll = g_list_delete_link (ll, ll);
}
- old_service_attr_list = l;
+ old_service_attr_list = ll;
service_attr_list[i] = g_list_concat (
service_attr_list[i], old_service_attr_list);
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 4bcaa9bbfb..8a5dbf087e 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -502,9 +502,9 @@ contact_list_editor_selection_changed_cb (GtkTreeSelection *selection,
gtk_widget_set_sensitive (WIDGET (UP_BUTTON), FALSE);
}
- gtk_tree_model_get_iter (model, &iter, g_list_last (selected)->data);
/* Item below last selected exists => enable Down/Bottom buttons */
- if (gtk_tree_model_iter_next (model, &iter)) {
+ if (gtk_tree_model_get_iter (model, &iter, g_list_last (selected)->data) &&
+ gtk_tree_model_iter_next (model, &iter)) {
gtk_widget_set_sensitive (WIDGET (DOWN_BUTTON), TRUE);
gtk_widget_set_sensitive (WIDGET (BOTTOM_BUTTON), TRUE);
} else {
@@ -888,9 +888,11 @@ contact_list_editor_remove_button_clicked_cb (GtkWidget *widget)
path = gtk_tree_row_reference_get_path (reference);
valid = gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_path_free (path);
- g_assert (valid);
-
- e_contact_list_model_remove_row (E_CONTACT_LIST_MODEL (model), &iter);
+ if (valid) {
+ e_contact_list_model_remove_row (E_CONTACT_LIST_MODEL (model), &iter);
+ } else {
+ g_warn_if_reached ();
+ }
gtk_tree_row_reference_free (reference);
}
@@ -967,7 +969,9 @@ contact_list_editor_select_button_clicked_cb (GtkWidget *widget)
for (iter = list; iter != NULL; iter = iter->next) {
EDestination *destination = iter->data;
- contact_list_editor_add_destination (widget, destination);
+ if (!contact_list_editor_add_destination (widget, destination))
+ g_warning ("%s: Failed to add destination", G_STRFUNC);
+
e_destination_store_remove_destination (store, destination);
}
@@ -1066,9 +1070,9 @@ contact_list_editor_top_button_clicked_cb (GtkButton *button)
for (l = references; l; l = l->next) {
path = gtk_tree_row_reference_get_path (l->data);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_store_move_after (
- GTK_TREE_STORE (model), &iter, NULL);
+ if (gtk_tree_model_get_iter (model, &iter, path))
+ gtk_tree_store_move_after (
+ GTK_TREE_STORE (model), &iter, NULL);
gtk_tree_path_free (path);
}
@@ -1105,16 +1109,19 @@ contact_list_editor_up_button_clicked_cb (GtkButton *button)
/* Get iter of item above the first selected item */
path = gtk_tree_path_copy (selected->data);
gtk_tree_path_prev (path);
- gtk_tree_model_get_iter (model, &iter, path);
+ if (!gtk_tree_model_get_iter (model, &iter, path)) {
+ gtk_tree_path_free (path);
+ g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
+ return;
+ }
gtk_tree_path_free (path);
/* Get iter of the last selected item */
- gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data);
+ if (gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data)) {
+ gtk_tree_store_move_after (GTK_TREE_STORE (model), &iter, &iter2);
+ }
- gtk_tree_store_move_after (GTK_TREE_STORE (model), &iter, &iter2);
-
- g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (selected);
+ g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
contact_list_editor_selection_changed_cb (selection, editor);
}
@@ -1141,16 +1148,21 @@ contact_list_editor_down_button_clicked_cb (GtkButton *button)
selected = gtk_tree_selection_get_selected_rows (selection, &model);
/* Iter of the first selected item */
- gtk_tree_model_get_iter (model, &iter, selected->data);
+ if (!gtk_tree_model_get_iter (model, &iter, selected->data)) {
+ g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
+ return;
+ }
/* Iter of item below the last selected item */
- gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data);
- gtk_tree_model_iter_next (model, &iter2);
+ if (!gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data) ||
+ !gtk_tree_model_iter_next (model, &iter2)) {
+ g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
+ return;
+ }
gtk_tree_store_move_before (GTK_TREE_STORE (model), &iter2, &iter);
- g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (selected);
+ g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
contact_list_editor_selection_changed_cb (selection, editor);
}
@@ -1828,10 +1840,10 @@ save_contact_list (GtkTreeModel *model,
g_free (uid);
/* Set new_iter to first child of iter */
- gtk_tree_model_iter_children (model, &new_iter, iter);
-
- /* Go recursive */
- save_contact_list (model, &new_iter, attrs, parent_id);
+ if (gtk_tree_model_iter_children (model, &new_iter, iter)) {
+ /* Go recursive */
+ save_contact_list (model, &new_iter, attrs, parent_id);
+ }
} else {
attr = e_vcard_attribute_new (NULL, EVC_EMAIL);
e_destination_export_to_vcard_attribute (dest, attr);
diff --git a/addressbook/printing/Makefile.am b/addressbook/printing/Makefile.am
index c51eb14d3b..58f2ca12d2 100644
--- a/addressbook/printing/Makefile.am
+++ b/addressbook/printing/Makefile.am
@@ -29,27 +29,6 @@ libecontactprint_la_LIBADD = \
$(GNOME_PLATFORM_LIBS) \
$(GTKHTML_LIBS)
-noinst_PROGRAMS = contact-print-test
-
-contact_print_test_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -DG_LOG_DOMAIN=\"addressbook-printing\" \
- -I$(top_srcdir)/addressbook \
- -I$(top_srcdir) \
- -DEVOLUTION_ECPSDIR=\""$(ecpsdir)"\" \
- $(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS)
-
-contact_print_test_SOURCES = test-print.c
-
-contact_print_test_LDADD = \
- libecontactprint.la \
- $(top_builddir)/addressbook/util/libeabutil.la \
- $(top_builddir)/shell/libevolution-shell.la \
- $(top_builddir)/e-util/libevolution-util.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS)
-
EXTRA_DIST = \
$(ecps_DATA)
diff --git a/addressbook/printing/test-print.c b/addressbook/printing/test-print.c
deleted file mode 100644
index 6f461959c3..0000000000
--- a/addressbook/printing/test-print.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include "e-contact-print.h"
-
-gint
-main (gint argc,
- gchar *argv[])
-{
- GList *shown_fields = NULL;
-
- gtk_init (&argc, &argv);
-
- shown_fields = g_list_append (shown_fields, (gpointer) "First field");
- shown_fields = g_list_append (shown_fields, (gpointer) "Second field");
- shown_fields = g_list_append (shown_fields, (gpointer) "Third field");
- shown_fields = g_list_append (shown_fields, (gpointer) "Fourth field");
-
- /* does nothing */
- e_contact_print (NULL, NULL, NULL, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-
- gtk_main ();
-
- /* Not reached. */
- return 0;
-}
diff --git a/addressbook/tools/evolution-addressbook-export-list-folders.c b/addressbook/tools/evolution-addressbook-export-list-folders.c
index 2ff9d790a4..538ea4f063 100644
--- a/addressbook/tools/evolution-addressbook-export-list-folders.c
+++ b/addressbook/tools/evolution-addressbook-export-list-folders.c
@@ -67,7 +67,7 @@ action_list_folders_init (ActionContext *p_actctx)
client = e_book_client_connect_sync (source, NULL, &error);
/* Sanity check. */
- g_return_if_fail (
+ g_warn_if_fail (
((client != NULL) && (error == NULL)) ||
((client == NULL) && (error != NULL)));