[evolution-ews] Fix/mute issues found by Coverity scan
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Fix/mute issues found by Coverity scan
- Date: Fri, 15 Nov 2013 12:57:09 +0000 (UTC)
commit 9844f7cdaee1f6466cf95ec8811cc52bd90f3d7c
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 15 13:55:50 2013 +0100
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.
src/calendar/e-cal-backend-ews-utils.c | 14 ++++++++------
src/camel/camel-ews-folder.c | 14 ++++++++------
src/camel/camel-ews-store.c | 3 ---
src/camel/camel-ews-summary.c | 1 +
src/camel/camel-ews-utils.c | 3 ---
src/collection/e-ews-backend.c | 10 +++-------
src/configuration/e-ews-config-utils.c | 9 ---------
.../e-mail-config-ews-delegates-page.c | 3 ++-
src/server/e-ews-connection.c | 11 +----------
9 files changed, 23 insertions(+), 45 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index 6414b69..1add02c 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -535,7 +535,6 @@ ewscal_set_reccurence (ESoapMessage *msg,
{
gchar buffer[256];
gint i, len;
- gboolean is_relative = FALSE;
/* MSDN reference: http://msdn.microsoft.com/en-us/library/aa580471%28v=EXCHG.80%29.aspx
*/
@@ -603,10 +602,13 @@ ewscal_set_reccurence (ESoapMessage *msg,
break;
case ICAL_YEARLY_RECURRENCE:
+ #if 0 /* FIXME */
if (is_relative) {
ewscal_add_rrule (msg, rrule);
- } else {
+ } else
+ #endif
+ {
e_soap_message_start_element (msg, "AbsoluteYearlyRecurrence", NULL, NULL);
/* work according to RFC5545 ยง3.3.10
@@ -765,12 +767,12 @@ e_ews_collect_organizer (icalcomponent *comp)
org_prop = icalcomponent_get_first_property (comp, ICAL_ORGANIZER_PROPERTY);
org = icalproperty_get_organizer (org_prop);
if (!org)
- org = "";
+ return NULL;
if (g_ascii_strncasecmp (org, "MAILTO:", 7) == 0)
- org_email_address = (org) + 7;
- else
- org_email_address = org;
+ org = org + 7;
+
+ org_email_address = org;
if (org_email_address && !*org_email_address)
org_email_address = NULL;
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index 7912eca..5141f81 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -199,7 +199,10 @@ camel_ews_folder_get_message_from_cache (CamelEwsFolder *ews_folder,
gchar *new_fname = ews_data_cache_get_filename (
ews_folder->cache,
"cur", uid, error);
- g_rename (old_fname, new_fname);
+ if (g_rename (old_fname, new_fname) == -1) {
+ g_warning ("%s: Failed to rename '%s' to '%s': %s", G_STRFUNC,
+ old_fname, new_fname, g_strerror (errno));
+ }
g_free (new_fname);
stream = ews_data_cache_get (ews_folder->cache, "cur", uid, error);
}
@@ -365,7 +368,10 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
goto exit_save;
if (camel_stream_close (newstream, NULL, error) == -1)
goto exit_save;
- g_remove (mime_fname);
+ if (g_remove (mime_fname) == -1) {
+ g_warning ("%s: Failed to remove file '%s': %s",
+ G_STRFUNC, mime_fname, g_strerror (errno));
+ }
success = TRUE;
exit_save:
if (fd != -1)
@@ -401,7 +407,6 @@ camel_ews_folder_get_message (CamelFolder *folder,
CamelEwsStore *ews_store;
const gchar *mime_content;
CamelMimeMessage *message = NULL;
- CamelStream *tmp_stream = NULL;
GSList *ids = NULL, *items = NULL;
gchar *mime_dir;
gchar *cache_file;
@@ -571,9 +576,6 @@ exit:
g_slist_free (items);
}
- if (tmp_stream)
- g_object_unref (tmp_stream);
-
if (mime_fname_new)
g_free (mime_fname_new);
g_object_unref (cnc);
diff --git a/src/camel/camel-ews-store.c b/src/camel/camel-ews-store.c
index bedfca2..f534d2e 100644
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@ -3417,11 +3417,8 @@ ews_store_unset_oof_settings_state (CamelSession *session,
e_ews_oof_settings_set_state (oof_settings, E_EWS_OOF_STATE_DISABLED);
e_ews_oof_settings_submit_sync (oof_settings, cancellable, error);
g_object_unref (oof_settings);
- if (local_error != NULL)
- g_propagate_error (error, local_error);
camel_operation_pop_message (cancellable);
-
}
void
diff --git a/src/camel/camel-ews-summary.c b/src/camel/camel-ews-summary.c
index 1bb7b2d..966a8e8 100644
--- a/src/camel/camel-ews-summary.c
+++ b/src/camel/camel-ews-summary.c
@@ -300,6 +300,7 @@ camel_ews_summary_add_message (CamelFolderSummary *summary,
tag = camel_message_info_user_tags (info);
while (tag) {
+ /* coverity[unchecked_value] */
camel_message_info_set_user_tag ((CamelMessageInfo *) mi, tag->name, tag->value);
tag = tag->next;
}
diff --git a/src/camel/camel-ews-utils.c b/src/camel/camel-ews-utils.c
index 66e19ad..e17f48a 100644
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@ -303,9 +303,6 @@ sync_created_folders (CamelEwsStore *ews_store,
* let's worry about that in a later commit. */
add_folder_to_summary (ews_store, folder);
- if (ftype != E_EWS_FOLDER_TYPE_MAILBOX)
- continue;
-
if (created_folder_ids) {
*created_folder_ids = g_slist_append (*created_folder_ids, g_strdup (fid->id));
} else {
diff --git a/src/collection/e-ews-backend.c b/src/collection/e-ews-backend.c
index ff83660..89749e6 100644
--- a/src/collection/e-ews-backend.c
+++ b/src/collection/e-ews-backend.c
@@ -377,7 +377,7 @@ ews_backend_add_gal_source (EEwsBackend *backend)
const gchar *display_name;
const gchar *extension_name;
const gchar *gal_uid;
- const gchar *oal_id;
+ const gchar *oal_id = NULL;
const gchar *uid;
gchar *oal_selected;
@@ -426,12 +426,8 @@ ews_backend_add_gal_source (EEwsBackend *backend)
g_free (backend->priv->oal_selected);
backend->priv->oal_selected = oal_selected; /* takes ownership */
- if (oal_id != NULL)
- source = e_collection_backend_new_child (
- collection_backend, oal_id);
- else
- source = e_collection_backend_new_child (
- collection_backend, "Global Address List");
+ source = e_collection_backend_new_child (
+ collection_backend, oal_id);
e_source_set_display_name (source, display_name);
diff --git a/src/configuration/e-ews-config-utils.c b/src/configuration/e-ews-config-utils.c
index e2efab4..5cff7bf 100644
--- a/src/configuration/e-ews-config-utils.c
+++ b/src/configuration/e-ews-config-utils.c
@@ -289,15 +289,6 @@ ews_config_utils_authenticator_try_password_sync (ESourceAuthenticator *auth,
g_free (hosturl);
g_free (user);
- if (local_error) {
- g_warn_if_fail (!authenticator->conn);
- authenticator->conn = NULL;
-
- g_propagate_error (error, local_error);
-
- return E_SOURCE_AUTHENTICATION_ERROR;
- }
-
g_warn_if_fail (authenticator->conn);
/* test whether connection works with some simple operation */
diff --git a/src/configuration/e-mail-config-ews-delegates-page.c
b/src/configuration/e-mail-config-ews-delegates-page.c
index 0e8920d..a365870 100644
--- a/src/configuration/e-mail-config-ews-delegates-page.c
+++ b/src/configuration/e-mail-config-ews-delegates-page.c
@@ -490,6 +490,8 @@ add_permission_level_combo_row (GtkGrid *grid,
gtk_combo_box_text_append_text (combo, C_("PermissionsLevel", "Editor (can read, create and modify
items)"));
switch (preselect) {
+ /* to make compiler happy */
+ /* coverity[dead_error_begin] */
case EwsPermissionLevel_Unknown:
break;
case EwsPermissionLevel_None:
@@ -1191,7 +1193,6 @@ mail_config_ews_delegates_page_constructed (GObject *object)
widget = gtk_radio_button_new_with_mnemonic (radio_group, _("My delegates a_nd me"));
page->priv->deliver_delegates_and_me_radio = widget;
- radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
gtk_grid_attach (grid, widget, 0, row, 2, 1);
g_signal_connect_swapped (
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index be02aca..4020279 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -983,6 +983,7 @@ handle_get_items_response_cb (EwsAsyncData *async_data, ESoapParameter *param)
const gchar *name = (const gchar *) subparam->name;
if (g_str_has_suffix (name, "ResponseMessage")) {
+ /* coverity[unchecked_value] */
ews_get_response_status (subparam, &error);
ews_handle_items_param (subparam, async_data, error);
} else {
@@ -7471,16 +7472,6 @@ get_delegate_response_cb (ESoapResponse *response,
if (!param)
return;
- /* Sanity check */
- g_return_if_fail (
- (param != NULL && error == NULL) ||
- (param == NULL && error != NULL));
-
- if (error != NULL) {
- g_simple_async_result_take_error (simple, error);
- return;
- }
-
subparam = e_soap_parameter_get_first_child (param);
while (subparam != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]