From f437bc152701d9a9b7cb75988ef04b30bbb0c8b4 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 13 Nov 2007 08:34:26 +0000 Subject: [PATCH] * coverity fixes: unused params, missing checks pmo-trunk-r3716 --- src/dbus_api/modest-dbus-callbacks.c | 10 ++++-- src/maemo/modest-address-book.c | 3 -- src/maemo/modest-maemo-global-settings-dialog.c | 5 --- src/maemo/modest-main-window.c | 44 +++++++++++------------ 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 9fb5984..a5a2e06 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -549,8 +549,8 @@ on_idle_delete_message (gpointer user_data) msg = find_message_by_url (uri, &account); if (!msg) { - g_warning ("modest: %s: Could not find message '%s'", __FUNCTION__, uri); - return OSSO_ERROR; /* FIXME: is this TRUE or FALSE?! */ + g_warning ("%s: Could not find message '%s'", __FUNCTION__, uri); + return OSSO_ERROR; } main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), @@ -560,6 +560,12 @@ on_idle_delete_message (gpointer user_data) uid = tny_header_get_uid (msg_header); folder = tny_msg_get_folder (msg); + if (!folder) { + g_warning ("%s: Could not find folder (uri:'%s')", __FUNCTION__, uri); + g_object_unref (msg); + return OSSO_ERROR; + } + /* tny_msg_get_header () flaw: * From tinythingy doc: You can't use the returned instance with the * TnyFolder operations diff --git a/src/maemo/modest-address-book.c b/src/maemo/modest-address-book.c index 8fe6536..85369e6 100644 --- a/src/maemo/modest-address-book.c +++ b/src/maemo/modest-address-book.c @@ -170,12 +170,9 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor) GSList *email_addrs_per_contact = NULL; gchar *econtact_id; gboolean focus_recpt_editor = FALSE; - GtkWidget *toplevel; g_return_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor)); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (recpt_editor)); - if (!open_addressbook ()) { if (contact_model) { g_object_unref (contact_model); diff --git a/src/maemo/modest-maemo-global-settings-dialog.c b/src/maemo/modest-maemo-global-settings-dialog.c index 9e48a69..2c71d02 100644 --- a/src/maemo/modest-maemo-global-settings-dialog.c +++ b/src/maemo/modest-maemo-global-settings-dialog.c @@ -181,13 +181,8 @@ on_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gp { /* grab the focus to the default element in the current page */ GtkWidget *selected_page = NULL, *focus_item = NULL; - ModestGlobalSettingsDialogPrivate *ppriv; - ModestMaemoGlobalSettingsDialogPrivate *priv; SwitchPageHelper *helper; - priv = MODEST_MAEMO_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data); - ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data); - selected_page = gtk_notebook_get_nth_page (notebook, page_num); focus_item = GTK_WIDGET(g_object_get_data (G_OBJECT(selected_page), DEFAULT_FOCUS_WIDGET)); if (!focus_item) { diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 1e2090b..89a5f41 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -598,10 +598,8 @@ update_menus (ModestMainWindow* self) default_account = modest_account_mgr_get_default_account (mgr); active_account_name = modest_window_get_active_account (MODEST_WINDOW (self)); - if (active_account_name == NULL) - { - modest_window_set_active_account (MODEST_WINDOW (self), default_account); - } + if (!active_account_name) + modest_window_set_active_account (MODEST_WINDOW (self), default_account); priv->view_additions_group = gtk_action_group_new (MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS); radio_group = NULL; @@ -609,20 +607,24 @@ update_menus (ModestMainWindow* self) gchar *display_name = NULL; ModestAccountData *account_data = (ModestAccountData *) g_slist_nth_data (accounts, i); + if (!account_data) { + g_warning ("%s: BUG: account_data == NULL", __FUNCTION__); + continue; + } + if (default_account && account_data->account_name && - !(strcmp (default_account, account_data->account_name) == 0)) { + !(strcmp (default_account, account_data->account_name) == 0)) { display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_default"), account_data->display_name); - } - else { + } else { display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_mailbox_n"), account_data->display_name); } - + /* Create action and add it to the action group. The action name must be the account name, this way we could know in the handlers the account to show */ - if(account_data && account_data->account_name) { + if (account_data && account_data->account_name) { gchar* item_name, *refresh_action_name; guint8 merge_id = 0; GtkAction *view_account_action, *refresh_account_action; @@ -1543,17 +1545,18 @@ create_empty_view (void) static gchar * get_gray_color_markup (GtkWidget *styled_widget) { - gchar *gray_color_markup; - + gchar *gray_color_markup = NULL; +#ifndef MODEST_HAVE_HILDON0_WIDGETS /* Obtain the secondary text color. We need a realized widget, that's why we get styled_widget from outside */ -#ifndef MODEST_HAVE_HILDON0_WIDGETS GdkColor color; - gtk_style_lookup_color (styled_widget->style, "SecondaryTextColor", &color); - gray_color_markup = modest_text_utils_get_color_string (&color); -#else - gray_color_markup = g_strdup ("#BBBBBB"); -#endif + if (gtk_style_lookup_color (styled_widget->style, "SecondaryTextColor", &color)) + gray_color_markup = modest_text_utils_get_color_string (&color); +#endif /*MODEST_HAVE_HILDON0_WIDGETS*/ + + if (!gray_color_markup) + gray_color_markup = g_strdup ("#BBBBBB"); + return gray_color_markup; } @@ -2355,9 +2358,7 @@ on_zoom_minus_plus_not_implemented (ModestWindow *window) } static gboolean -on_folder_view_focus_in (GtkWidget *widget, - GdkEventFocus *event, - gpointer userdata) +on_folder_view_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer userdata) { ModestMainWindow *main_window = NULL; @@ -2376,11 +2377,10 @@ on_header_view_focus_in (GtkWidget *widget, gpointer userdata) { ModestMainWindow *main_window = NULL; - ModestMainWindowPrivate *priv = NULL; g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (userdata), FALSE); + main_window = MODEST_MAIN_WINDOW (userdata); - priv = MODEST_MAIN_WINDOW_GET_PRIVATE (main_window); /* Update toolbar dimming state */ modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window)); -- 1.7.9.5