aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-folder-tree.c
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 /mail/em-folder-tree.c
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 'mail/em-folder-tree.c')
-rw-r--r--mail/em-folder-tree.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 27091e2f5c..aaf3488307 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -554,6 +554,8 @@ folder_tree_maybe_expand_row (EMFolderTreeModel *model,
if (u) {
gchar *c = strrchr (key, '/');
+ /* 'c' cannot be NULL, because the above contructed 'key' has it there */
+ /* coverity[dereference] */
*c = '\0';
folder_tree_expand_node (key, folder_tree);
@@ -3036,12 +3038,10 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree,
g_slist_append (priv->select_uris, u);
}
- end = strrchr (expand_key, '/');
- do {
+ while (end = strrchr (expand_key, '/'), end) {
folder_tree_expand_node (expand_key, folder_tree);
*end = 0;
- end = strrchr (expand_key, '/');
- } while (end);
+ }
if (expand_only)
folder_tree_free_select_uri (u);
@@ -3108,33 +3108,39 @@ em_folder_tree_select_next_path (EMFolderTree *folder_tree,
current_path = gtk_tree_model_get_path (model, &iter);
do {
- if (gtk_tree_model_iter_has_child (model, &iter)) {
- gtk_tree_model_iter_children (model, &child, &iter);
- path = gtk_tree_model_get_path (model, &child);
- iter = child;
- } else {
- while (1) {
- gboolean has_parent;
+ if (gtk_tree_model_iter_has_child (model, &iter)) {
+ if (!gtk_tree_model_iter_children (model, &child, &iter))
+ break;
+ path = gtk_tree_model_get_path (model, &child);
+ iter = child;
+ } else {
+ while (1) {
+ gboolean has_parent;
- has_parent = gtk_tree_model_iter_parent (
- model, &parent, &iter);
+ has_parent = gtk_tree_model_iter_parent (
+ model, &parent, &iter);
- if (gtk_tree_model_iter_next (model, &iter)) {
- path = gtk_tree_model_get_path (model, &iter);
- break;
- } else {
- if (has_parent) {
- iter = parent;
- } else {
- /* Reached end. Wrapup*/
- gtk_tree_model_get_iter_first (model, &iter);
+ if (gtk_tree_model_iter_next (model, &iter)) {
path = gtk_tree_model_get_path (model, &iter);
break;
+ } else {
+ if (has_parent) {
+ iter = parent;
+ } else {
+ /* Reached end. Wrapup*/
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ path = gtk_tree_model_get_path (model, &iter);
+ else
+ path = NULL;
+ break;
+ }
}
}
+
+ if (!path)
+ break;
}
- }
- gtk_tree_model_get (model, &iter, COL_UINT_UNREAD, &unread, -1);
+ gtk_tree_model_get (model, &iter, COL_UINT_UNREAD, &unread, -1);
/* TODO : Flags here for better options */
} while (skip_read_folders && unread <=0 &&
@@ -3153,6 +3159,7 @@ em_folder_tree_select_next_path (EMFolderTree *folder_tree,
}
gtk_tree_view_scroll_to_cell (tree_view, path, NULL, TRUE, 0.5f, 0.0f);
}
+
return;
}