[evolution-data-server] Fix/mute issues found by Coverity scan



commit a317be96dcffe6ce2c5900fe4e76d955e2294ce9
Author: Milan Crha <mcrha redhat com>
Date:   Wed Nov 13 09:40:46 2013 +0100

    Fix/mute issues found by Coverity scan
    
    This makes the code free of Coverity scan issues, except of the doc/
    folder. 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.

 addressbook/backends/ldap/e-book-backend-ldap.c    |    3 +-
 .../backends/webdav/e-book-backend-webdav.c        |    4 +-
 addressbook/libebook/e-book-client.c               |  100 ++++++++--
 addressbook/libebook/e-book.c                      |   10 +-
 addressbook/libebook/e-destination.c               |   10 +-
 addressbook/libedata-book/e-book-backend-summary.c |   10 +-
 calendar/backends/caldav/e-cal-backend-caldav.c    |    3 +-
 .../backends/contacts/e-cal-backend-contacts.c     |   10 +-
 calendar/backends/file/e-cal-backend-file.c        |    4 +-
 calendar/libecal/e-cal-client.c                    |  191 ++++++++++++++++----
 camel/camel-block-file.c                           |    4 +-
 camel/camel-certdb.c                               |   10 +-
 camel/camel-db.c                                   |    5 +
 camel/camel-disco-diary.c                          |    2 +-
 camel/camel-file-utils.c                           |    8 +-
 camel/camel-folder-search.c                        |    3 +-
 camel/camel-gpg-context.c                          |   18 +-
 camel/camel-lock-client.c                          |    4 +-
 camel/camel-lock-helper.c                          |   23 ++-
 camel/camel-lock.c                                 |    2 +-
 camel/camel-mime-parser.c                          |    3 +
 camel/camel-mime-part.c                            |    2 +
 camel/camel-movemail.c                             |    2 +-
 camel/camel-network-service.c                      |   12 +-
 camel/camel-object.c                               |    3 +-
 camel/camel-sasl-ntlm.c                            |   11 +-
 camel/camel-search-private.c                       |    6 +-
 camel/camel-service.c                              |    5 +-
 camel/camel-session.c                              |   12 +-
 camel/camel-smime-context.c                        |    2 +-
 camel/camel-stream-process.c                       |    5 +-
 camel/camel-text-index.c                           |    5 +-
 camel/camel-url-scanner.c                          |    1 +
 camel/camel-vee-store.c                            |    1 +
 .../imapx/camel-imapx-namespace-response.c         |    3 -
 camel/providers/imapx/camel-imapx-search.c         |    2 +-
 camel/providers/imapx/camel-imapx-server.c         |   16 +-
 camel/providers/imapx/camel-imapx-store.c          |    1 -
 camel/providers/imapx/camel-imapx-utils.c          |    2 +
 camel/providers/local/camel-maildir-store.c        |   18 ++-
 camel/providers/local/camel-maildir-summary.c      |    4 +-
 camel/providers/local/camel-mbox-folder.c          |   17 +-
 camel/providers/local/camel-mbox-summary.c         |   13 +-
 camel/providers/local/camel-mh-store.c             |    7 +-
 camel/providers/nntp/camel-nntp-stream.c           |    1 +
 camel/providers/pop3/camel-pop3-folder.c           |    7 +-
 camel/providers/pop3/camel-pop3-store.c            |    1 +
 camel/providers/pop3/camel-pop3-stream.c           |    1 +
 libebackend/e-authentication-session.c             |    1 +
 libedataserver/e-categories.c                      |    8 +-
 libedataserver/e-source-authenticator.c            |    5 +-
 tests/cursor-example/cursor-data.c                 |   32 ----
 tests/cursor-example/cursor-example.c              |    5 +-
 tests/cursor-example/cursor-navigator.c            |    1 -
 tests/cursor-example/cursor-search.c               |    4 +-
 tests/libebook/client/test-client-custom-summary.c |    5 +-
 tests/libebook/client/test-client-modify-contact.c |    3 +-
 tests/libebook/test-ebook-commit-contact.c         |    3 +-
 58 files changed, 447 insertions(+), 207 deletions(-)
---
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index 8aa1b70..adec34c 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -4075,8 +4075,7 @@ build_contact_from_entry (EBookBackendLDAP *bl,
                                                        /* get the e-mail id for each member and add them to 
the list */
 
                                                        book_view = find_book_view (bl);
-                                                       if (view_limit == -1 || view_limit > 
bl->priv->ldap_limit)
-                                                               view_limit = bl->priv->ldap_limit;
+                                                       view_limit = bl->priv->ldap_limit;
 
                                                        count = ldap_count_values (values);
                                                        member_info = g_new0 (gchar *, count + 1);
diff --git a/addressbook/backends/webdav/e-book-backend-webdav.c 
b/addressbook/backends/webdav/e-book-backend-webdav.c
index c5b101a..24d62ff 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav.c
+++ b/addressbook/backends/webdav/e-book-backend-webdav.c
@@ -296,8 +296,6 @@ upload_contact (EBookBackendWebdav *webdav,
        extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
        webdav_extension = e_source_get_extension (source, extension_name);
 
-       source = e_backend_get_source (E_BACKEND (webdav));
-
        uri = e_contact_get (contact, E_CONTACT_UID);
        if (uri == NULL) {
                g_warning ("can't upload contact without UID");
@@ -1626,7 +1624,7 @@ book_backend_webdav_try_password_sync (ESourceAuthenticator *authenticator,
 static void
 e_book_backend_webdav_class_init (EBookBackendWebdavClass *class)
 {
-       GObjectClass      *object_class = G_OBJECT_CLASS (class);
+       GObjectClass *object_class;
        EBookBackendClass *backend_class;
 
        g_type_class_add_private (class, sizeof (EBookBackendWebdavPrivate));
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index 421ad02..f5b0d40 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -1740,6 +1740,7 @@ e_book_client_get_self (ESourceRegistry *registry,
        if (uid) {
                /* Don't care about errors because
                 * we'll create a new card on failure. */
+               /* coverity[unchecked_value] */
                e_book_client_get_contact_sync (
                        book_client, uid, &contact, NULL, NULL);
                g_free (uid);
@@ -1859,11 +1860,17 @@ book_client_add_contact_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_add_contact_sync (
+       if (!e_book_client_add_contact_sync (
                E_BOOK_CLIENT (source_object),
                async_context->contact,
                &async_context->uid,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -2024,11 +2031,17 @@ book_client_add_contacts_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_add_contacts_sync (
+       if (!e_book_client_add_contacts_sync (
                E_BOOK_CLIENT (source_object),
                async_context->object_list,
                &async_context->string_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -2231,10 +2244,16 @@ book_client_modify_contact_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_modify_contact_sync (
+       if (!e_book_client_modify_contact_sync (
                E_BOOK_CLIENT (source_object),
                async_context->contact,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -2355,10 +2374,16 @@ book_client_modify_contacts_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_modify_contacts_sync (
+       if (!e_book_client_modify_contacts_sync (
                E_BOOK_CLIENT (source_object),
                async_context->object_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -2507,10 +2532,16 @@ book_client_remove_contact_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_remove_contact_sync (
+       if (!e_book_client_remove_contact_sync (
                E_BOOK_CLIENT (source_object),
                async_context->contact,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -2634,10 +2665,16 @@ book_client_remove_contact_by_uid_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_remove_contact_by_uid_sync (
+       if (!e_book_client_remove_contact_by_uid_sync (
                E_BOOK_CLIENT (source_object),
                async_context->uid,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -2758,10 +2795,16 @@ book_client_remove_contacts_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_remove_contacts_sync (
+       if (!e_book_client_remove_contacts_sync (
                E_BOOK_CLIENT (source_object),
                async_context->string_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -2909,11 +2952,16 @@ book_client_get_contact_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_get_contact_sync (
+       if (!e_book_client_get_contact_sync (
                E_BOOK_CLIENT (source_object),
                async_context->uid,
                &async_context->contact,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+                       if (!local_error)
+                               local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                                  E_CLIENT_ERROR_OTHER_ERROR,
+                                                                  _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -3097,11 +3145,17 @@ book_client_get_contacts_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_get_contacts_sync (
+       if (!e_book_client_get_contacts_sync (
                E_BOOK_CLIENT (source_object),
                async_context->sexp,
                &async_context->object_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -3308,11 +3362,17 @@ book_client_get_contacts_uids_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_book_client_get_contacts_uids_sync (
+       if (!e_book_client_get_contacts_uids_sync (
                E_BOOK_CLIENT (source_object),
                async_context->sexp,
                &async_context->string_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 952efa7..018b98c 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -1069,8 +1069,14 @@ get_contact_reply (GObject *source_object,
        EContact *contact = NULL;
        GError *error = NULL;
 
-       e_book_client_get_contact_finish (
-               E_BOOK_CLIENT (source_object), result, &contact, &error);
+       if (!e_book_client_get_contact_finish (
+               E_BOOK_CLIENT (source_object), result, &contact, &error)) {
+
+               if (!error)
+                       error = g_error_new_literal (E_CLIENT_ERROR,
+                                                    E_CLIENT_ERROR_OTHER_ERROR,
+                                                    _("Unknown error"));
+       }
 
        if (cb != NULL && error == NULL)
                cb (data->book, E_BOOK_ERROR_OK, contact, data->closure);
diff --git a/addressbook/libebook/e-destination.c b/addressbook/libebook/e-destination.c
index 9001482..2fa08d6 100644
--- a/addressbook/libebook/e-destination.c
+++ b/addressbook/libebook/e-destination.c
@@ -144,7 +144,7 @@ destination_finalize (GObject *object)
 static void
 e_destination_class_init (EDestinationClass *class)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
+       GObjectClass *object_class;
 
        g_type_class_add_private (class, sizeof (EDestinationPrivate));
 
@@ -891,8 +891,8 @@ e_destination_get_name (const EDestination *dest)
                        if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
                                const gchar *camel_name = NULL;
 
-                               camel_internet_address_get (addr, 0, &camel_name, NULL);
-                               priv->name = g_strdup (camel_name);
+                               if (camel_internet_address_get (addr, 0, &camel_name, NULL))
+                                       priv->name = g_strdup (camel_name);
                        }
 
                        g_object_unref (addr);
@@ -967,8 +967,8 @@ e_destination_get_email (const EDestination *dest)
 
                        if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
                                const gchar *camel_email = NULL;
-                               camel_internet_address_get (addr, 0, NULL, &camel_email);
-                               priv->email = g_strdup (camel_email);
+                               if (camel_internet_address_get (addr, 0, NULL, &camel_email))
+                                       priv->email = g_strdup (camel_email);
                        }
 
                        g_object_unref (addr);
diff --git a/addressbook/libedata-book/e-book-backend-summary.c 
b/addressbook/libedata-book/e-book-backend-summary.c
index c29f72d..c41ee69 100644
--- a/addressbook/libedata-book/e-book-backend-summary.c
+++ b/addressbook/libedata-book/e-book-backend-summary.c
@@ -440,7 +440,10 @@ e_book_backend_summary_open (EBookBackendSummary *summary)
                        return FALSE;
                }
                else {
-                       g_rename (new_filename, summary->priv->summary_path);
+                       if (g_rename (new_filename, summary->priv->summary_path) == -1) {
+                               g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC,
+                                          new_filename, summary->priv->summary_path, g_strerror (errno));
+                       }
                        g_free (new_filename);
                }
        }
@@ -687,7 +690,10 @@ e_book_backend_summary_save (EBookBackendSummary *summary)
 
        /* unlink the old summary and rename the new one */
        g_unlink (summary->priv->summary_path);
-       g_rename (new_filename, summary->priv->summary_path);
+       if (g_rename (new_filename, summary->priv->summary_path) == -1) {
+               g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC,
+                          new_filename, summary->priv->summary_path, g_strerror (errno));
+       }
 
        g_free (new_filename);
 
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 904235c..e9c638d 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -1868,7 +1868,8 @@ caldav_gen_file_from_uid_cal (ECalBackendCalDAV *cbdav,
                     subcomp;
                     subcomp = icalcomponent_get_next_component (icalcomp, my_kind)) {
                        uid = icalcomponent_get_uid (subcomp);
-                       break;
+                       if (uid && *uid)
+                               break;
                }
        } else if (icalcomponent_isa (icalcomp) == my_kind) {
                uid = icalcomponent_get_uid (icalcomp);
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c 
b/calendar/backends/contacts/e-cal-backend-contacts.c
index 03aa26e..0f8a5c1 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -261,8 +261,14 @@ book_record_get_view_thread (gpointer user_data)
        query_sexp = e_book_query_to_string (query);
        e_book_query_unref (query);
 
-       e_book_client_get_view_sync (
-               br->book_client, query_sexp, &book_view, NULL, &error);
+       if (!e_book_client_get_view_sync (
+               br->book_client, query_sexp, &book_view, NULL, &error)) {
+
+               if (!error)
+                       error = g_error_new_literal (E_CLIENT_ERROR,
+                                                    E_CLIENT_ERROR_OTHER_ERROR,
+                                                    _("Unknown error"));
+       }
 
        /* Sanity check. */
        g_return_val_if_fail (
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index 420b988..bb68093 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -2593,8 +2593,10 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                                g_list_free (detached);
                        }
                        break;
+               /* coverity[dead_error_begin] */
                case E_CAL_OBJ_MOD_ONLY_THIS:
                        /* not reached, keep compiler happy */
+                       g_warn_if_reached ();
                        break;
                }
 
@@ -2911,7 +2913,7 @@ e_cal_backend_file_remove_objects (ECalBackendSync *backend,
                        ECalComponent *old_component = NULL;
                        ECalComponent *new_component = NULL;
 
-                       obj_data = remove_instance (
+                       remove_instance (
                                cbfile, obj_data, id->uid, recur_id, mod,
                                &old_component, &new_component, error);
 
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index 6ac3828..1989117 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -2343,6 +2343,17 @@ generate_instances (ECalClient *client,
                                end_zone = default_zone;
                        }
 
+                       if (!dtstart.value) {
+                               g_warn_if_reached ();
+
+                               e_cal_component_free_datetime (&dtstart);
+                               e_cal_component_free_datetime (&dtend);
+                               g_object_unref (G_OBJECT (ci->comp));
+                               g_free (ci);
+
+                               continue;
+                       }
+
                        ci->start = icaltime_as_timet_with_zone (
                                *dtstart.value, start_zone);
 
@@ -3206,10 +3217,16 @@ cal_client_get_default_object_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_default_object_sync (
+       if (!e_cal_client_get_default_object_sync (
                E_CAL_CLIENT (source_object),
                &async_context->out_comp,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -3370,12 +3387,18 @@ cal_client_get_object_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_object_sync (
+       if (!e_cal_client_get_object_sync (
                E_CAL_CLIENT (source_object),
                async_context->uid,
                async_context->rid,
                &async_context->out_comp,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -3628,11 +3651,17 @@ cal_client_get_objects_for_uid_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_objects_for_uid_sync (
+       if (!e_cal_client_get_objects_for_uid_sync (
                E_CAL_CLIENT (source_object),
                async_context->uid,
                &async_context->object_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -3862,11 +3891,17 @@ cal_client_get_object_list_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_object_list_sync (
+       if (!e_cal_client_get_object_list_sync (
                E_CAL_CLIENT (source_object),
                async_context->sexp,
                &async_context->comp_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -4043,11 +4078,17 @@ cal_client_get_object_list_as_comps_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_object_list_as_comps_sync (
+       if (!e_cal_client_get_object_list_as_comps_sync (
                E_CAL_CLIENT (source_object),
                async_context->sexp,
                &async_context->object_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -4227,12 +4268,18 @@ cal_client_get_free_busy_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_free_busy_sync (
+       if (!e_cal_client_get_free_busy_sync (
                E_CAL_CLIENT (source_object),
                async_context->start,
                async_context->end,
                async_context->string_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -4391,11 +4438,17 @@ cal_client_create_object_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_create_object_sync (
+       if (!e_cal_client_create_object_sync (
                E_CAL_CLIENT (source_object),
                async_context->in_comp,
                &async_context->uid,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -4553,11 +4606,17 @@ cal_client_create_objects_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_create_objects_sync (
+       if (!e_cal_client_create_objects_sync (
                E_CAL_CLIENT (source_object),
                async_context->comp_list,
                &async_context->string_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -4749,11 +4808,17 @@ cal_client_modify_object_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_modify_object_sync (
+       if (!e_cal_client_modify_object_sync (
                E_CAL_CLIENT (source_object),
                async_context->in_comp,
                async_context->mod,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -4892,11 +4957,17 @@ cal_client_modify_objects_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_modify_objects_sync (
+       if (!e_cal_client_modify_objects_sync (
                E_CAL_CLIENT (source_object),
                async_context->comp_list,
                async_context->mod,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -5078,12 +5149,18 @@ cal_client_remove_object_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_remove_object_sync (
+       if (!e_cal_client_remove_object_sync (
                E_CAL_CLIENT (source_object),
                async_context->uid,
                async_context->rid,
                async_context->mod,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -5225,11 +5302,17 @@ cal_client_remove_objects_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_remove_objects_sync (
+       if (!e_cal_client_remove_objects_sync (
                E_CAL_CLIENT (source_object),
                async_context->string_list,
                async_context->mod,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -5436,10 +5519,16 @@ cal_client_receive_objects_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_receive_objects_sync (
+       if (!e_cal_client_receive_objects_sync (
                E_CAL_CLIENT (source_object),
                async_context->in_comp,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -5581,12 +5670,18 @@ cal_client_send_objects_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_send_objects_sync (
+       if (!e_cal_client_send_objects_sync (
                E_CAL_CLIENT (source_object),
                async_context->in_comp,
                &async_context->string_list,
                &async_context->out_comp,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -5800,12 +5895,18 @@ cal_client_get_attachment_uris_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_attachment_uris_sync (
+       if (!e_cal_client_get_attachment_uris_sync (
                E_CAL_CLIENT (source_object),
                async_context->uid,
                async_context->rid,
                &async_context->string_list,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -5989,12 +6090,18 @@ cal_client_discard_alarm_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_discard_alarm_sync (
+       if (!e_cal_client_discard_alarm_sync (
                E_CAL_CLIENT (source_object),
                async_context->uid,
                async_context->rid,
                async_context->auid,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -6346,11 +6453,17 @@ cal_client_get_timezone_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_get_timezone_sync (
+       if (!e_cal_client_get_timezone_sync (
                E_CAL_CLIENT (source_object),
                async_context->tzid,
                &async_context->zone,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
@@ -6554,10 +6667,16 @@ cal_client_add_timezone_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       e_cal_client_add_timezone_sync (
+       if (!e_cal_client_add_timezone_sync (
                E_CAL_CLIENT (source_object),
                async_context->zone,
-               cancellable, &local_error);
+               cancellable, &local_error)) {
+
+               if (!local_error)
+                       local_error = g_error_new_literal (E_CLIENT_ERROR,
+                                                          E_CLIENT_ERROR_OTHER_ERROR,
+                                                          _("Unknown error"));
+       }
 
        if (local_error != NULL)
                g_simple_async_result_take_error (simple, local_error);
diff --git a/camel/camel-block-file.c b/camel/camel-block-file.c
index 2453f56..32bc80f 100644
--- a/camel/camel-block-file.c
+++ b/camel/camel-block-file.c
@@ -1165,7 +1165,9 @@ camel_key_file_write (CamelKeyFile *kf,
 
        /* FIXME: Use io util functions? */
        next = kf->last;
-       fseek (kf->fp, kf->last, SEEK_SET);
+       if (fseek (kf->fp, kf->last, SEEK_SET) == -1)
+               return -1;
+
        fwrite (parent, sizeof (*parent), 1, kf->fp);
        fwrite (&size, sizeof (size), 1, kf->fp);
        fwrite (records, sizeof (records[0]), len, kf->fp);
diff --git a/camel/camel-certdb.c b/camel/camel-certdb.c
index 750fae3..ff7e2ba 100644
--- a/camel/camel-certdb.c
+++ b/camel/camel-certdb.c
@@ -377,9 +377,10 @@ camel_certdb_load (CamelCertDB *certdb)
        if (!class->header_load || !class->cert_load) {
                fclose (in);
                in = NULL;
+               g_warn_if_reached ();
+
+               return -1;
        }
-       g_return_val_if_fail (class->header_load != NULL, -1);
-       g_return_val_if_fail (class->cert_load != NULL, -1);
 
        g_mutex_lock (&certdb->priv->io_lock);
        if (class->header_load (certdb, in) == -1)
@@ -458,9 +459,10 @@ camel_certdb_save (CamelCertDB *certdb)
        if (!class->header_save || !class->cert_save) {
                fclose (out);
                out = NULL;
+               g_warn_if_reached ();
+
+               return -1;
        }
-       g_return_val_if_fail (class->header_save != NULL, -1);
-       g_return_val_if_fail (class->cert_save != NULL, -1);
 
        g_mutex_lock (&certdb->priv->io_lock);
 
diff --git a/camel/camel-db.c b/camel/camel-db.c
index 54d6cd5..7b53c35 100644
--- a/camel/camel-db.c
+++ b/camel/camel-db.c
@@ -1659,6 +1659,11 @@ write_mir (CamelDB *cdb,
        /*char *del_query;*/
        gchar *ins_query;
 
+       if (!record) {
+               g_warn_if_reached ();
+               return -1;
+       }
+
        /* FIXME: We should migrate from this DELETE followed by INSERT model to an INSERT OR REPLACE model 
as pointed out by pvanhoof */
 
        /* NB: UGLIEST Hack. We can't modify the schema now. We are using dirty (an unsed one to notify of 
FLAGGED/Dirty infos */
diff --git a/camel/camel-disco-diary.c b/camel/camel-disco-diary.c
index e943456..08b256f 100644
--- a/camel/camel-disco-diary.c
+++ b/camel/camel-disco-diary.c
@@ -444,7 +444,7 @@ camel_disco_diary_replay (CamelDiscoDiary *diary,
        diary->folders = NULL;
 
        /* Truncate the log */
-       ftruncate (fileno (diary->file), 0);
+       (void) ftruncate (fileno (diary->file), 0);
        rewind (diary->file);
 
        g_propagate_error (error, local_error);
diff --git a/camel/camel-file-utils.c b/camel/camel-file-utils.c
index a4a80e3..0ef9f98 100644
--- a/camel/camel-file-utils.c
+++ b/camel/camel-file-utils.c
@@ -454,7 +454,7 @@ camel_read (gint fd,
                fd_set rdset;
 
                flags = fcntl (fd, F_GETFL);
-               fcntl (fd, F_SETFL, flags | O_NONBLOCK);
+               (void) fcntl (fd, F_SETFL, flags | O_NONBLOCK);
 
                do {
                        struct timeval tv;
@@ -484,7 +484,7 @@ camel_read (gint fd,
                } while (nread == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
        failed:
                errnosav = errno;
-               fcntl (fd, F_SETFL, flags);
+               (void) fcntl (fd, F_SETFL, flags);
                errno = errnosav;
 #endif
        }
@@ -550,7 +550,7 @@ camel_write (gint fd,
                fd_set rdset, wrset;
 
                flags = fcntl (fd, F_GETFL);
-               fcntl (fd, F_SETFL, flags | O_NONBLOCK);
+               (void) fcntl (fd, F_SETFL, flags | O_NONBLOCK);
 
                fdmax = MAX (fd, cancel_fd) + 1;
                do {
@@ -587,7 +587,7 @@ camel_write (gint fd,
                } while (w != -1 && written < n);
 
                errnosav = errno;
-               fcntl (fd, F_SETFL, flags);
+               (void) fcntl (fd, F_SETFL, flags);
                errno = errnosav;
 #endif
        }
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index ebb1671..2078932 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -1047,12 +1047,13 @@ folder_search_match_threads (CamelSExp *sexp,
                } else {
                        if (type == 3) {
                                scan = node;
+                               /* coverity[check_after_deref] */
                                while (scan && scan->parent) {
                                        scan = scan->parent;
                                        g_hash_table_insert (results, (gchar *) camel_message_info_uid 
(scan->message), GINT_TO_POINTER (1));
                                }
                        } else if (type == 1) {
-                               while (node && node->parent)
+                               while (node != NULL && node->parent)
                                        node = node->parent;
                        }
                        g_hash_table_insert (results, (gchar *) camel_message_info_uid (node->message), 
GINT_TO_POINTER (1));
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index 1b3c91c..2dd52ac 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -645,7 +645,7 @@ gpg_ctx_op_start (struct _GpgCtx *gpg,
                for (i = 3; i < maxfd; i++) {
                        /* don't close the status-fd or passwd-fd */
                        if (i != fds[7] && i != fds[8])
-                               fcntl (i, F_SETFD, FD_CLOEXEC);
+                               (void) fcntl (i, F_SETFD, FD_CLOEXEC);
                }
 
                /* run gpg */
@@ -676,20 +676,20 @@ gpg_ctx_op_start (struct _GpgCtx *gpg,
                close (fds[8]);
                gpg->passwd_fd = fds[9];
                flags = fcntl (gpg->passwd_fd, F_GETFL);
-               fcntl (gpg->passwd_fd, F_SETFL, flags | O_NONBLOCK);
+               (void) fcntl (gpg->passwd_fd, F_SETFL, flags | O_NONBLOCK);
        }
 
        flags = fcntl (gpg->stdin_fd, F_GETFL);
-       fcntl (gpg->stdin_fd, F_SETFL, flags | O_NONBLOCK);
+       (void) fcntl (gpg->stdin_fd, F_SETFL, flags | O_NONBLOCK);
 
        flags = fcntl (gpg->stdout_fd, F_GETFL);
-       fcntl (gpg->stdout_fd, F_SETFL, flags | O_NONBLOCK);
+       (void) fcntl (gpg->stdout_fd, F_SETFL, flags | O_NONBLOCK);
 
        flags = fcntl (gpg->stderr_fd, F_GETFL);
-       fcntl (gpg->stderr_fd, F_SETFL, flags | O_NONBLOCK);
+       (void) fcntl (gpg->stderr_fd, F_SETFL, flags | O_NONBLOCK);
 
        flags = fcntl (gpg->status_fd, F_GETFL);
-       fcntl (gpg->status_fd, F_SETFL, flags | O_NONBLOCK);
+       (void) fcntl (gpg->status_fd, F_SETFL, flags | O_NONBLOCK);
 
        return TRUE;
 
@@ -798,7 +798,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg,
 
                status += 7;
 
-               status = (const guchar *) next_token ((gchar *) status, &key);
+               next_token ((gchar *) status, &key);
                if (key) {
                        gboolean all_zero = *key == '0';
                        gint i = 0;
@@ -841,7 +841,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg,
 
                status += 16;
 
-               status = (const guchar *) next_token ((gchar *) status, &userid);
+               next_token ((gchar *) status, &userid);
                if (!userid) {
                        g_set_error (
                                error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
@@ -856,7 +856,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg,
 
                status += 20;
 
-               status = (const guchar *) next_token ((gchar *) status, &userid);
+               next_token ((gchar *) status, &userid);
                if (!userid) {
                        g_set_error (
                                error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
diff --git a/camel/camel-lock-client.c b/camel/camel-lock-client.c
index 3844aeb..5ccb525 100644
--- a/camel/camel-lock-client.c
+++ b/camel/camel-lock-client.c
@@ -149,8 +149,8 @@ lock_helper_init (GError **error)
                close (lock_stdout_pipe[1]);
 
                /* so the child knows when we vanish */
-               fcntl (lock_stdin_pipe[1], F_SETFD, FD_CLOEXEC);
-               fcntl (lock_stdout_pipe[0], F_SETFD, FD_CLOEXEC);
+               (void) fcntl (lock_stdin_pipe[1], F_SETFD, FD_CLOEXEC);
+               (void) fcntl (lock_stdout_pipe[0], F_SETFD, FD_CLOEXEC);
        }
 
        return 0;
diff --git a/camel/camel-lock-helper.c b/camel/camel-lock-helper.c
index 835d4e8..4d4504f 100644
--- a/camel/camel-lock-helper.c
+++ b/camel/camel-lock-helper.c
@@ -155,11 +155,15 @@ lock_path (const gchar *path,
                if (lock_real_uid != lock_root_uid) {
                        if (seteuid (lock_root_uid) != -1) {
                                if (camel_lock_dot (path, NULL) == -1) {
-                                       seteuid (lock_real_uid);
+                                       if (seteuid (lock_real_uid) == -1) {
+                                               g_warn_if_reached ();
+                                       }
                                        res = CAMEL_LOCK_HELPER_STATUS_SYSTEM;
                                        goto fail;
                                }
-                               seteuid (lock_real_uid);
+                               if (seteuid (lock_real_uid) == -1) {
+                                       g_warn_if_reached ();
+                               }
                        } else {
                                res = CAMEL_LOCK_HELPER_STATUS_SYSTEM;
                                goto fail;
@@ -216,9 +220,13 @@ unlock_id (guint32 lockid)
                        if (info->depth <= 0) {
 #ifdef SETEUID_SAVES
                                if (info->uid != lock_real_uid) {
-                                       seteuid (lock_root_uid);
+                                       if (seteuid (lock_root_uid) == -1) {
+                                               g_warn_if_reached ();
+                                       }
                                        camel_unlock_dot (info->path);
-                                       seteuid (lock_real_uid);
+                                       if (seteuid (lock_real_uid) == -1) {
+                                               g_warn_if_reached ();
+                                       }
                                } else
 #endif
                                        camel_unlock_dot (info->path);
@@ -279,8 +287,11 @@ setup_process (void)
         * portable so may need configure checks */
        lock_real_uid = getuid ();
        lock_root_uid = geteuid ();
-       if (lock_real_uid != lock_root_uid)
-               seteuid (lock_real_uid);
+       if (lock_real_uid != lock_root_uid) {
+               if (seteuid (lock_real_uid) == -1) {
+                       g_warn_if_reached ();
+               }
+       }
 #endif
 }
 
diff --git a/camel/camel-lock.c b/camel/camel-lock.c
index 6cf3578..3d67074 100644
--- a/camel/camel-lock.c
+++ b/camel/camel-lock.c
@@ -240,7 +240,7 @@ camel_unlock_fcntl (gint fd)
 
        memset (&lock, 0, sizeof (lock));
        lock.l_type = F_UNLCK;
-       fcntl (fd, F_SETLK, &lock);
+       (void) fcntl (fd, F_SETLK, &lock);
 #endif
 }
 
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 3a42262..0c22bfd 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -1603,6 +1603,7 @@ tail_recurse:
                        h->from_line = g_byte_array_new ();
                        folder_push_part (s, h);
                        s->state = CAMEL_MIME_PARSER_STATE_PRE_FROM;
+                       goto scan_pre_from;
                } else {
                        s->start_of_from = -1;
                        goto scan_header;
@@ -1610,6 +1611,7 @@ tail_recurse:
 
        case CAMEL_MIME_PARSER_STATE_PRE_FROM:
 
+ scan_pre_from:
                h = s->parts;
                do {
                        hb = folder_scan_content (s, &state, databuffer, datalength);
@@ -1695,6 +1697,7 @@ tail_recurse:
 
        case CAMEL_MIME_PARSER_STATE_HEADER:
                s->state = CAMEL_MIME_PARSER_STATE_BODY;
+               /* coverity[fallthrough] */
 
        case CAMEL_MIME_PARSER_STATE_BODY:
                h = s->parts;
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 84c3b21..1992d42 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -744,6 +744,8 @@ mime_part_construct_from_parser_sync (CamelMimePart *mime_part,
                if (dw->mime_type)
                        camel_content_type_unref (dw->mime_type);
                dw->mime_type = camel_content_type_decode ("message/rfc822");
+               /* coverity[fallthrough] */
+
        case CAMEL_MIME_PARSER_STATE_HEADER:
        case CAMEL_MIME_PARSER_STATE_MULTIPART:
                /* we have the headers, build them into 'us' */
diff --git a/camel/camel-movemail.c b/camel/camel-movemail.c
index 4a5d9fb..22790b4 100644
--- a/camel/camel-movemail.c
+++ b/camel/camel-movemail.c
@@ -151,7 +151,7 @@ camel_movemail (const gchar *source,
         */
        if (res != -1) {
                if (close (dfd) == 0) {
-                       ftruncate (sfd, 0);
+                       (void) ftruncate (sfd, 0);
                } else {
                        g_set_error (
                                error, G_IO_ERROR,
diff --git a/camel/camel-network-service.c b/camel/camel-network-service.c
index 5a89b82..13a55c2 100644
--- a/camel/camel-network-service.c
+++ b/camel/camel-network-service.c
@@ -15,10 +15,13 @@
  * License along with the program; if not, see <http://www.gnu.org/licenses/>
  *
  */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "camel-network-service.h"
 
-#include <config.h>
+#include <errno.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
 
@@ -80,8 +83,11 @@ network_service_get_cert_dir (void)
 
                /* Move the old certificate directory if present. */
                old_dir = g_build_filename (home_dir, ".camel_certs", NULL);
-               if (g_file_test (old_dir, G_FILE_TEST_IS_DIR))
-                       g_rename (old_dir, cert_dir);
+               if (g_file_test (old_dir, G_FILE_TEST_IS_DIR)) {
+                       if (g_rename (old_dir, cert_dir) == -1) {
+                               g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC, old_dir, 
cert_dir, g_strerror (errno));
+                       }
+               }
                g_free (old_dir);
 
                g_mkdir_with_parents (cert_dir, 0700);
diff --git a/camel/camel-object.c b/camel/camel-object.c
index 70fd3e7..00d4deb 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -447,7 +447,8 @@ camel_object_state_write (CamelObject *object)
                    && class->state_write (object, fp) == 0) {
                        if (fclose (fp) == 0) {
                                res = 0;
-                               g_rename (savename, state_filename);
+                               if (g_rename (savename, state_filename) == -1)
+                                       res = -1;
                        }
                } else {
                        fclose (fp);
diff --git a/camel/camel-sasl-ntlm.c b/camel/camel-sasl-ntlm.c
index 6c56b51..112abae 100644
--- a/camel/camel-sasl-ntlm.c
+++ b/camel/camel-sasl-ntlm.c
@@ -74,12 +74,6 @@ G_DEFINE_TYPE (CamelSaslNTLM, camel_sasl_ntlm, CAMEL_TYPE_SASL)
 
 #define NTLM_AUTH_HELPER "/usr/bin/ntlm_auth"
 
-static void ntlm_calc_response   (const guchar key[21],
-                                 const guchar plaintext[8],
-                                 guchar results[24]);
-static void ntlm_lanmanager_hash (const gchar *password, gchar hash[21]);
-static void ntlm_nt_hash         (const gchar *password, gchar hash[21]);
-
 typedef struct {
        guint16 length;
        guint16 allocated;
@@ -152,7 +146,7 @@ ntlm_lanmanager_hash (const gchar *password,
        DES_KS ks;
        gint i;
 
-       for (i = 0; i < 14 && password[i]; i++)
+       for (i = 0; i < 14 && password && password[i]; i++)
                lm_password[i] = toupper ((guchar) password[i]);
 
        for (; i < 15; i++)
@@ -173,6 +167,9 @@ ntlm_nt_hash (const gchar *password,
 {
        guchar *buf, *p;
 
+       if (!password)
+               password = "";
+
        p = buf = g_malloc (strlen (password) * 2);
 
        while (*password) {
diff --git a/camel/camel-search-private.c b/camel/camel-search-private.c
index 58c1950..b3029ab 100644
--- a/camel/camel-search-private.c
+++ b/camel/camel-search-private.c
@@ -294,7 +294,8 @@ camel_ustrcasecmp (const gchar *ps1,
        /* end of one of the strings ? */
        CAMEL_SEARCH_COMPARE (u1, u2, 0);
 
-       /* if we have invalid utf8 sequence ?  */
+       /* if we have invalid utf8 sequence ? */
+       /* coverity[dead_error_begin] */
        CAMEL_SEARCH_COMPARE (s1, s2, NULL);
 
        return 0;
@@ -391,7 +392,8 @@ camel_ustrncasecmp (const gchar *ps1,
        /* end of one of the strings ? */
        CAMEL_SEARCH_COMPARE (u1, u2, 0);
 
-       /* if we have invalid utf8 sequence ?  */
+       /* if we have invalid utf8 sequence ? */
+       /* coverity[dead_error_begin] */
        CAMEL_SEARCH_COMPARE (s1, s2, NULL);
 
        return 0;
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 0fd6c78..4afd979 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -1213,7 +1213,10 @@ camel_service_migrate_files (CamelService *service)
        /* If the old data directory name exists, try renaming
         * it to the new data directory.  Failure is non-fatal. */
        if (old_data_dir != NULL) {
-               g_rename (old_data_dir, new_data_dir);
+               if (g_rename (old_data_dir, new_data_dir) == -1) {
+                       g_warning ("%s: Failed to rename '%s' to '%s': %s",
+                                  G_STRFUNC, old_data_dir, new_data_dir, g_strerror (errno));
+               }
                g_free (old_data_dir);
        }
 }
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 38e5b47..5b23649 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -151,7 +151,9 @@ session_finish_job_cb (CamelSession *session,
        JobData *job_data;
        GError *error = NULL;
 
-       g_simple_async_result_propagate_error (simple, &error);
+       if (!g_simple_async_result_propagate_error (simple, &error))
+               error = NULL;
+
        job_data = g_simple_async_result_get_op_res_gpointer (simple);
 
        g_signal_emit (
@@ -565,11 +567,15 @@ session_authenticate_thread (GSimpleAsyncResult *simple,
 
        async_context = g_simple_async_result_get_op_res_gpointer (simple);
 
-       camel_session_authenticate_sync (
+       if (!camel_session_authenticate_sync (
                CAMEL_SESSION (object),
                async_context->service,
                async_context->auth_mechanism,
-               cancellable, &error);
+               cancellable, &error)) {
+
+               if (!error)
+                       error = g_error_new_literal (CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Unknown error"));
+       }
 
        if (error != NULL)
                g_simple_async_result_take_error (simple, error);
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index bd86013..49f89b7 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -1062,7 +1062,7 @@ smime_context_encrypt_sync (CamelCipherContext *context,
        }
 
        /* Lookup all recipients certs, for later working */
-       recipient_certs = (CERTCertificate **) PORT_ArenaZAlloc (poolp, sizeof (*recipient_certs[0]) * 
(recipients->len + 1));
+       recipient_certs = (CERTCertificate **) PORT_ArenaZAlloc (poolp, sizeof (recipient_certs[0]) * 
(recipients->len + 1));
        if (recipient_certs == NULL) {
                set_nss_error (error, g_strerror (ENOMEM));
                goto fail;
diff --git a/camel/camel-stream-process.c b/camel/camel-stream-process.c
index c25eb9d..d4b16da 100644
--- a/camel/camel-stream-process.c
+++ b/camel/camel-stream-process.c
@@ -208,8 +208,9 @@ do_exec_command (gint fd,
         * leave it as it is. Perhaps we should close it and reopen /dev/null? */
 
        maxopen = sysconf (_SC_OPEN_MAX);
-       for (i = 3; i < maxopen; i++)
-               fcntl (i, F_SETFD, FD_CLOEXEC);
+       for (i = 3; i < maxopen; i++) {
+               (void) fcntl (i, F_SETFD, FD_CLOEXEC);
+       }
 
        setsid ();
 #ifdef TIOCNOTTY
diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c
index b756bed..936211e 100644
--- a/camel/camel-text-index.c
+++ b/camel/camel-text-index.c
@@ -1024,7 +1024,10 @@ camel_text_index_rename (const gchar *old,
                err = errno;
                g_snprintf (oldname, oldname_len, "%s.index", old);
                g_snprintf (newname, newname_len, "%s.index", new);
-               g_rename (newname, oldname);
+               if (g_rename (newname, oldname) == -1) {
+                       g_warning ("%s: Failed to rename '%s' to '%s': %s",
+                                  G_STRFUNC, newname, oldname, g_strerror (errno));
+               }
                errno = err;
                return -1;
        }
diff --git a/camel/camel-url-scanner.c b/camel/camel-url-scanner.c
index 0e1c484..1bae03d 100644
--- a/camel/camel-url-scanner.c
+++ b/camel/camel-url-scanner.c
@@ -456,6 +456,7 @@ camel_url_web_end (const gchar *in,
                        /* we have a '/' so there could be a path - fall through */
                case '/': /* we've detected a path component to our url */
                        inptr++;
+                       /* coverity[fallthrough] */
                case '?':
                        while (inptr < inend && is_urlsafe (*inptr)) {
                                if (*inptr == open_brace) {
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 2d1220f..069d173 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -1002,6 +1002,7 @@ vee_store_rebuild_unmatched_folder (CamelSession *session,
                camel_folder_changed (unmatched_folder, changes);
        camel_folder_change_info_free (changes);
 
+       /* coverity[unchecked_value] */
        g_cancellable_set_error_if_cancelled (cancellable, error);
 }
 
diff --git a/camel/providers/imapx/camel-imapx-namespace-response.c 
b/camel/providers/imapx/camel-imapx-namespace-response.c
index f604c88..30a2283 100644
--- a/camel/providers/imapx/camel-imapx-namespace-response.c
+++ b/camel/providers/imapx/camel-imapx-namespace-response.c
@@ -231,9 +231,6 @@ camel_imapx_namespace_response_new (CamelIMAPXStream *stream,
                        case 2:
                                category = CAMEL_IMAPX_NAMESPACE_SHARED;
                                break;
-                       default:
-                               g_warn_if_reached ();
-                               goto fail;
                }
 
                success = imapx_namespace_response_parse_namespace (
diff --git a/camel/providers/imapx/camel-imapx-search.c b/camel/providers/imapx/camel-imapx-search.c
index bbd94c8..121c69f 100644
--- a/camel/providers/imapx/camel-imapx-search.c
+++ b/camel/providers/imapx/camel-imapx-search.c
@@ -193,7 +193,7 @@ imapx_search_body_contains (CamelSExp *sexp,
        if (search->current != NULL) {
                type = CAMEL_SEXP_RES_BOOL;
                result = camel_sexp_result_new (sexp, type);
-               result->value.boolean = (uids->len > 0);
+               result->value.boolean = (uids && uids->len > 0);
        } else {
                type = CAMEL_SEXP_RES_ARRAY_PTR;
                result = camel_sexp_result_new (sexp, type);
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index cda7bb1..bbecbf5 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2007,7 +2007,10 @@ imapx_untagged_fetch (CamelIMAPXServer *is,
 
                job = imapx_match_active_job (
                        is, IMAPX_JOB_GET_MESSAGE, finfo->uid);
-               g_return_val_if_fail (job != NULL, FALSE);
+               if (job == NULL) {
+                       g_warn_if_reached ();
+                       return FALSE;
+               }
 
                data = camel_imapx_job_get_data (job);
                g_return_val_if_fail (data != NULL, FALSE);
@@ -4879,9 +4882,6 @@ imapx_job_get_message_start (CamelIMAPXJob *job,
                        imapx_command_queue (is, ic);
 
                        camel_imapx_command_unref (ic);
-
-                       if (!success)
-                               break;
                }
        } else {
                ic = camel_imapx_command_new (
@@ -5130,7 +5130,9 @@ imapx_command_append_message_done (CamelIMAPXServer *is,
                        mi->uid = camel_pstring_add (data->appended_uid, FALSE);
 
                        cur = camel_data_cache_get_filename  (ifolder->cache, "cur", mi->uid);
-                       g_rename (data->path, cur);
+                       if (g_rename (data->path, cur) == -1) {
+                               g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC, data->path, 
cur, g_strerror (errno));
+                       }
 
                        /* should we update the message count ? */
                        imapx_set_message_info_flags_for_new_message (
@@ -8401,7 +8403,7 @@ camel_imapx_server_append_message (CamelIMAPXServer *is,
 
                        flag = camel_message_info_user_flags (mi);
                        while (flag != NULL) {
-                               if (flag->name != NULL && *flag->name != '\0')
+                               if (*flag->name != '\0')
                                        camel_flag_set (
                                                &base_info->user_flags,
                                                flag->name, TRUE);
@@ -8410,7 +8412,7 @@ camel_imapx_server_append_message (CamelIMAPXServer *is,
 
                        tag = camel_message_info_user_tags (mi);
                        while (tag != NULL) {
-                               if (tag->name != NULL && *tag->name != '\0')
+                               if (*tag->name != '\0')
                                        camel_tag_set (
                                                &base_info->user_tags,
                                                tag->name, tag->value);
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 9372db5..44f09fd 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -2186,7 +2186,6 @@ imapx_store_rename_folder_sync (CamelStore *store,
 
        g_object_unref (settings);
 
-       imapx_store = CAMEL_IMAPX_STORE (store);
        imapx_server = camel_imapx_store_ref_server (imapx_store, error);
 
        if (imapx_server == NULL)
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index c8ca2b4..140ae17 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -479,6 +479,7 @@ imapx_parse_capability (CamelIMAPXStream *stream,
                        case 43:
                                token = (guchar *) g_strconcat ((gchar *) token, "+", NULL);
                                free_token = TRUE;
+                               /* coverity[fallthrough] */
                        case IMAPX_TOK_TOKEN:
                        case IMAPX_TOK_STRING:
                                p = token;
@@ -804,6 +805,7 @@ imapx_parse_ext_optional (CamelIMAPXStream *is,
 
                        dinfo->disposition = g_strdup ((gchar *) token);
                        imapx_parse_param_list (is, &dinfo->params, cancellable, NULL);
+                       break;
                case IMAPX_TOK_TOKEN:
                        d (is->tagprefix, "body_fld_dsp: NIL\n");
                        break;
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 50c6e0e..e76bda0 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -377,10 +377,10 @@ maildir_store_delete_folder_sync (CamelStore *store,
 
                if (err != 0) {
                        /* easier just to mkdir all (and let them fail), than remember what we got to */
-                       g_mkdir (name, 0700);
-                       g_mkdir (cur, 0700);
-                       g_mkdir (new, 0700);
-                       g_mkdir (tmp, 0700);
+                       (void) g_mkdir (name, 0700);
+                       (void) g_mkdir (cur, 0700);
+                       (void) g_mkdir (new, 0700);
+                       (void) g_mkdir (tmp, 0700);
                        g_set_error (
                                error, G_IO_ERROR,
                                g_io_error_from_errno (err),
@@ -639,7 +639,13 @@ scan_dirs (CamelStore *store,
                CAMEL_MAILDIR_STORE (store)->priv->already_migrated = TRUE;
                meta_path = maildir_get_meta_path ((CamelLocalStore *) store, "?", "maildir++");
                ptr = strrchr (meta_path, '?');
-               g_return_val_if_fail (ptr != NULL, -1);
+               if (!ptr) {
+                       g_warn_if_reached ();
+                       closedir (dir);
+                       res = -1;
+
+                       goto exit;
+               }
 
                /* cannot pass dot inside maildir_get_meta_path(), because it escapes it */
                ptr[0] = '.';
@@ -1195,7 +1201,7 @@ maildir_version_requires_migrate (const gchar *meta_filename,
                                   gint *maildir_version)
 {
        FILE *metafile;
-       gchar cc;
+       gint cc;
        gint verpos = 0;
        gboolean res = FALSE;
 
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c
index e4e8970..7f3bf92 100644
--- a/camel/providers/local/camel-maildir-summary.c
+++ b/camel/providers/local/camel-maildir-summary.c
@@ -816,7 +816,9 @@ maildir_summary_sync (CamelLocalSummary *cls,
                        if (strcmp (newname, camel_maildir_info_filename (mdi))) {
                                name = g_strdup_printf ("%s/cur/%s", cls->folder_path, 
camel_maildir_info_filename (mdi));
                                dest = g_strdup_printf ("%s/cur/%s", cls->folder_path, newname);
-                               g_rename (name, dest);
+                               if (g_rename (name, dest) == -1) {
+                                       g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC, name, 
dest, g_strerror (errno));
+                               }
                                if (g_stat (dest, &st) == -1) {
                                        /* we'll assume it didn't work, but dont change anything else */
                                        g_free (newname);
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 99a84f4..770d8d8 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -257,11 +257,12 @@ fail_write:
                gint fd;
 
                fd = camel_stream_fs_get_fd (CAMEL_STREAM_FS (output_stream));
-
-               /* reset the file to original size */
-               do {
-                       retval = ftruncate (fd, mbs->folder_size);
-               } while (retval == -1 && errno == EINTR);
+               if (fd != -1) {
+                       /* reset the file to original size */
+                       do {
+                               retval = ftruncate (fd, mbs->folder_size);
+                       } while (retval == -1 && errno == EINTR);
+               }
 
                g_object_unref (output_stream);
        }
@@ -457,8 +458,10 @@ mbox_folder_unlock (CamelLocalFolder *lf)
        CamelMboxFolder *mf = (CamelMboxFolder *) lf;
 
        g_assert (mf->lockfd != -1);
-       camel_unlock_folder (lf->folder_path, mf->lockfd);
-       close (mf->lockfd);
+       if (mf->lockfd != -1) {
+               camel_unlock_folder (lf->folder_path, mf->lockfd);
+               close (mf->lockfd);
+       }
        mf->lockfd = -1;
 #endif
 }
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 8c37c61..e14bab1 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -927,11 +927,15 @@ mbox_summary_sync_quick (CamelMboxSummary *mbs,
                /* we write out the xevnew string, assuming its been folded identically to the original too! 
*/
 
                lastpos = lseek (fd, 0, SEEK_CUR);
-               lseek (fd, xevoffset + strlen ("X-Evolution: "), SEEK_SET);
+               (void) lseek (fd, xevoffset + strlen ("X-Evolution: "), SEEK_SET);
                do {
                        len = write (fd, xevnew, strlen (xevnew));
                } while (len == -1 && errno == EINTR);
-               lseek (fd, lastpos, SEEK_SET);
+
+               if (lastpos != -1 && lseek (fd, lastpos, SEEK_SET) == (off_t) -1) {
+                       g_warning ("%s: Failed to rewind file to last position: %s",
+                                  G_STRFUNC, g_strerror (errno));
+               }
                g_free (xevnew);
 
                camel_mime_parser_drop_step (mp);
@@ -967,10 +971,9 @@ mbox_summary_sync_quick (CamelMboxSummary *mbs,
  error:
        g_ptr_array_foreach (summary, (GFunc) camel_pstring_free, NULL);
        g_ptr_array_free (summary, TRUE);
+       g_object_unref (mp);
        if (fd != -1)
                close (fd);
-       if (mp)
-               g_object_unref (mp);
        if (info)
                camel_message_info_unref (info);
 
@@ -1129,7 +1132,7 @@ camel_mbox_summary_sync_mbox (CamelMboxSummary *cls,
        camel_folder_summary_prepare_fetch_all (s, NULL);
        known_uids = camel_folder_summary_get_array (s);
        /* walk them in the same order as stored in the file */
-       if (known_uids->len)
+       if (known_uids && known_uids->len)
                g_ptr_array_sort_with_data (known_uids, cms_sort_frompos, mbs);
        for (i = 0; known_uids && i < known_uids->len; i++) {
                gint pc = (i + 1) * 100 / known_uids->len;
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index c81e9c1..2b0ed67 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -128,7 +128,7 @@ folders_update (const gchar *root,
                                if (ret == -1)
                                        goto fail;
                                mode = UPDATE_NONE;
-                       } else if (tmp == NULL) {
+                       } else if (cmp == 0) {
                                /* already there */
                                mode = UPDATE_NONE;
                        }
@@ -169,8 +169,9 @@ folders_update (const gchar *root,
                goto fail;
 
 done:
-       /* should we care if this fails?  I suppose so ... */
-       g_rename (tmpnew, tmp);
+       if (g_rename (tmpnew, tmp) == -1) {
+               g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC, tmpnew, tmp, g_strerror 
(errno));
+       }
 fail:
        unlink (tmpnew);                /* remove it if its there */
        g_free (line);
diff --git a/camel/providers/nntp/camel-nntp-stream.c b/camel/providers/nntp/camel-nntp-stream.c
index d09ee6e..6d3209d 100644
--- a/camel/providers/nntp/camel-nntp-stream.c
+++ b/camel/providers/nntp/camel-nntp-stream.c
@@ -462,6 +462,7 @@ camel_nntp_stream_getd (CamelNNTPStream *is,
                                }
                        }
                        state = 1;
+                       break;
                case 1:
                        /* Scan for sentinal */
                        while ((*p++) != '\n')
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 9d1c004..47a586e 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -523,6 +523,11 @@ pop3_folder_get_filename (CamelFolder *folder,
        }
 
        pop3_cache = camel_pop3_store_ref_cache (pop3_store);
+       if (!pop3_cache) {
+               g_warn_if_reached ();
+               return NULL;
+       }
+
        filename = camel_data_cache_get_filename (
                pop3_cache, "cache", fi->uid);
        g_clear_object (&pop3_cache);
@@ -977,7 +982,7 @@ pop3_folder_synchronize_sync (CamelFolder *folder,
 
        if (g_cancellable_is_cancelled (cancellable)) {
                if (error && !*error)
-                       g_cancellable_set_error_if_cancelled (cancellable, error);
+                       (void) g_cancellable_set_error_if_cancelled (cancellable, error);
                return FALSE;
        }
 
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 067e76d..60ef714 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -347,6 +347,7 @@ try_sasl (CamelPOP3Store *store,
                    || (resp = (guchar *) camel_sasl_challenge_base64_sync (sasl, (const gchar *) line + 2, 
cancellable, &local_error)) == NULL) {
                        camel_stream_write_string (
                                CAMEL_STREAM (pop3_stream), "*\r\n", cancellable, NULL);
+                       /* coverity[unchecked_value] */
                        camel_pop3_stream_line (pop3_stream, &line, &len, cancellable, NULL);
 
                        if (local_error) {
diff --git a/camel/providers/pop3/camel-pop3-stream.c b/camel/providers/pop3/camel-pop3-stream.c
index f8ab50d..115e547 100644
--- a/camel/providers/pop3/camel-pop3-stream.c
+++ b/camel/providers/pop3/camel-pop3-stream.c
@@ -426,6 +426,7 @@ camel_pop3_stream_getd (CamelPOP3Stream *is,
                                }
                        }
                        state = 1;
+                       break;
                case 1:
                        /* Scan for sentinal */
                        while ((*p++) != '\n')
diff --git a/libebackend/e-authentication-session.c b/libebackend/e-authentication-session.c
index 3d71b2e..867aff7 100644
--- a/libebackend/e-authentication-session.c
+++ b/libebackend/e-authentication-session.c
@@ -711,6 +711,7 @@ exit:
                        authentication_session_msg (
                                session, "Complete (DISMISSED)");
                        break;
+               /* coverity[dead_error_begin] */
                default:
                        g_warn_if_reached ();
        }
diff --git a/libedataserver/e-categories.c b/libedataserver/e-categories.c
index db74763..49f9063 100644
--- a/libedataserver/e-categories.c
+++ b/libedataserver/e-categories.c
@@ -17,7 +17,11 @@
  * Boston, MA 02110-1301, USA.
  */
 
+#if HAVE_CONFIG_H
 #include <config.h>
+#endif
+
+#include <errno.h>
 #include <string.h>
 #include <libxml/parser.h>
 #include <glib/gstdio.h>
@@ -136,7 +140,9 @@ build_categories_filename (void)
                old_filename = g_build_filename (
                        g_get_home_dir (), ".evolution",
                        "categories.xml", NULL);
-               g_rename (old_filename, filename);
+               if (g_rename (old_filename, filename) == -1) {
+                       g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC, old_filename, 
filename, g_strerror (errno));
+               }
                g_free (old_filename);
        }
 
diff --git a/libedataserver/e-source-authenticator.c b/libedataserver/e-source-authenticator.c
index f7530a2..3366c39 100644
--- a/libedataserver/e-source-authenticator.c
+++ b/libedataserver/e-source-authenticator.c
@@ -115,10 +115,7 @@ source_authenticator_get_prompt_strings (ESourceAuthenticator *auth,
 
        extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
        if (e_source_has_extension (source, extension_name)) {
-               if (type == TYPE_UNKNOWN)
-                       type = TYPE_ADDRESS_BOOK;
-               else
-                       type = TYPE_AMBIGUOUS;
+               type = TYPE_ADDRESS_BOOK;
        }
 
        extension_name = E_SOURCE_EXTENSION_CALENDAR;
diff --git a/tests/cursor-example/cursor-data.c b/tests/cursor-example/cursor-data.c
index a2e8437..7a4745c 100644
--- a/tests/cursor-example/cursor-data.c
+++ b/tests/cursor-example/cursor-data.c
@@ -107,8 +107,6 @@ cursor_load_data (const gchar        *vcard_path,
        ESourceRegistry *registry;
        ESource *scratch;
        ESourceBackend *backend = NULL;
-       ESourceBackendSummarySetup *setup = NULL;
-       EBookClientCursor *cursor = NULL;
        GMainLoop *loop;
        GError  *error = NULL;
        GSList *contacts = NULL;
@@ -256,36 +254,6 @@ load_contacts (EBookClient *client,
                g_error ("No contacts found in vcard directory: %s", vcard_directory);
 }
 
-
-
-static gchar *
-get_addressbook_directory (ESourceRegistry *registry,
-                          ESource         *source)
-{
-       ESource *builtin_source;
-       const gchar *user_data_dir;
-       const gchar *uid;
-       gchar *filename = NULL;
-
-       uid = e_source_get_uid (source);
-       g_return_val_if_fail (uid != NULL, NULL);
-
-       user_data_dir = e_get_user_data_dir ();
-
-       builtin_source = e_source_registry_ref_builtin_address_book (registry);
-
-       /* Special case directory for the builtin addressbook source */
-       if (builtin_source != NULL && e_source_equal (source, builtin_source))
-               uid = "system";
-
-       filename = g_build_filename (user_data_dir, "addressbook", uid, NULL);
-
-       if (builtin_source)
-               g_object_unref (builtin_source);
-
-       return filename;
-}
-
 static EBookClientCursor *
 get_cursor (EBookClient *book_client)
 {
diff --git a/tests/cursor-example/cursor-example.c b/tests/cursor-example/cursor-example.c
index 0a15cd7..3e16a08 100644
--- a/tests/cursor-example/cursor-example.c
+++ b/tests/cursor-example/cursor-example.c
@@ -24,6 +24,7 @@
 #include "cursor-example.h"
 #include "cursor-navigator.h"
 #include "cursor-search.h"
+#include "cursor-slot.h"
 #include "cursor-data.h"
 
 #define N_SLOTS         10
@@ -77,7 +78,6 @@ static gboolean        cursor_example_move_cursor             (CursorExample
 static gboolean        cursor_example_load_page               (CursorExample      *example,
                                                               gboolean           *full_results);
 static void            cursor_example_update_status           (CursorExample      *example);
-static void            cursor_example_update_sensitivity      (CursorExample      *example);
 static void            cursor_example_update_current_index    (CursorExample      *example,
                                                               EContact           *contact);
 static void            cursor_example_ensure_timeout          (CursorExample      *example,
@@ -499,7 +499,7 @@ cursor_example_load_page (CursorExample     *example,
                        if (i == 0 && contact)
                                cursor_example_update_current_index (example, contact);
 
-                       cursor_slot_set_from_contact (priv->slots[i], contact);
+                       cursor_slot_set_from_contact (CURSOR_SLOT (priv->slots[i]), contact);
                }
        }
 
@@ -515,7 +515,6 @@ static void
 cursor_example_update_status (CursorExample *example)
 {
        CursorExamplePrivate *priv = example->priv;
-       GError               *error = NULL;
        gint                  total, position;
        gchar                *txt;
        gboolean              up_sensitive;
diff --git a/tests/cursor-example/cursor-navigator.c b/tests/cursor-example/cursor-navigator.c
index 6ae2d90..b9ee9a0 100644
--- a/tests/cursor-example/cursor-navigator.c
+++ b/tests/cursor-example/cursor-navigator.c
@@ -99,7 +99,6 @@ static void
 cursor_navigator_constructed (GObject *object)
 {
        CursorNavigator        *navigator = CURSOR_NAVIGATOR (object);
-       CursorNavigatorPrivate *priv = navigator->priv;
        GtkAdjustment          *adj = NULL;
 
        G_OBJECT_CLASS (cursor_navigator_parent_class)->constructed (object);
diff --git a/tests/cursor-example/cursor-search.c b/tests/cursor-example/cursor-search.c
index 6b2b45e..6f370a1 100644
--- a/tests/cursor-example/cursor-search.c
+++ b/tests/cursor-example/cursor-search.c
@@ -104,9 +104,7 @@ cursor_search_class_init (CursorSearchClass *klass)
 static void
 cursor_search_init (CursorSearch *search)
 {
-       CursorSearchPrivate *priv;
-
-       search->priv = priv = cursor_search_get_instance_private (search);
+       search->priv = cursor_search_get_instance_private (search);
 
        gtk_widget_init_template (GTK_WIDGET (search));
 
diff --git a/tests/libebook/client/test-client-custom-summary.c 
b/tests/libebook/client/test-client-custom-summary.c
index 889a6dd..fb3dc28 100644
--- a/tests/libebook/client/test-client-custom-summary.c
+++ b/tests/libebook/client/test-client-custom-summary.c
@@ -317,7 +317,10 @@ main (gint argc,
        g_test_bug_base ("http://bugzilla.gnome.org/";);
 
        /* Change environment so that the addressbook factory inherits this setting */
-       g_setenv ("LC_ALL", "en_US.UTF-8", TRUE);
+       if (!g_setenv ("LC_ALL", "en_US.UTF-8", TRUE)) {
+               g_warn_if_reached ();
+               return 1;
+       }
        setlocale (LC_ALL, "");
 
 #if defined (LC_ADDRESS)
diff --git a/tests/libebook/client/test-client-modify-contact.c 
b/tests/libebook/client/test-client-modify-contact.c
index 61ae72d..371345e 100644
--- a/tests/libebook/client/test-client-modify-contact.c
+++ b/tests/libebook/client/test-client-modify-contact.c
@@ -28,7 +28,8 @@ verify_modify (EContact *contact)
        EVCardAttribute *attr;
        gchar *email_value;
 
-       g_assert ((attr = e_vcard_get_attribute (E_VCARD (contact), EVC_EMAIL)));
+       attr = e_vcard_get_attribute (E_VCARD (contact), EVC_EMAIL);
+       g_assert (attr != NULL);
        g_assert (e_vcard_attribute_is_single_valued (attr));
        email_value = e_vcard_attribute_get_value (attr);
        g_assert (!g_strcmp0 (email_value, EMAIL_ADD));
diff --git a/tests/libebook/test-ebook-commit-contact.c b/tests/libebook/test-ebook-commit-contact.c
index e088f36..2294c2c 100644
--- a/tests/libebook/test-ebook-commit-contact.c
+++ b/tests/libebook/test-ebook-commit-contact.c
@@ -32,7 +32,8 @@ verify_commit (EContact *contact)
        EVCardAttribute *attr;
        gchar *email_value;
 
-       g_assert ((attr = e_vcard_get_attribute (E_VCARD (contact), EVC_EMAIL)));
+       attr = e_vcard_get_attribute (E_VCARD (contact), EVC_EMAIL);
+       g_assert (attr != NULL);
        g_assert (e_vcard_attribute_is_single_valued (attr));
        email_value = e_vcard_attribute_get_value (attr);
        g_assert (!g_strcmp0 (email_value, EMAIL_ADD));


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