[evolution] Address some of the clang compiler warnings



commit 5df319080f19d6156027f7f067209a2c468dadf3
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 7 11:57:41 2016 +0200

    Address some of the clang compiler warnings

 calendar/gui/e-comp-editor-page-recurrence.c |   21 +++++++++--------
 composer/e-msg-composer.c                    |   32 +++++++++++++------------
 configure.ac                                 |    8 +++++-
 e-util/e-config.c                            |    5 +++-
 e-util/e-config.h                            |    2 +
 e-util/e-event.c                             |    2 +-
 e-util/e-event.h                             |    1 +
 mail/e-mail-reader-utils.c                   |    6 +---
 mail/message-list.c                          |    2 +-
 modules/itip-formatter/itip-view.c           |    2 +-
 modules/mail/e-mail-shell-view.c             |    4 +-
 smime/gui/certificate-manager.c              |   19 ++++++++++++---
 12 files changed, 64 insertions(+), 40 deletions(-)
---
diff --git a/calendar/gui/e-comp-editor-page-recurrence.c b/calendar/gui/e-comp-editor-page-recurrence.c
index 0f901e7..74621e4 100644
--- a/calendar/gui/e-comp-editor-page-recurrence.c
+++ b/calendar/gui/e-comp-editor-page-recurrence.c
@@ -41,6 +41,7 @@
 #include "e-comp-editor-page-recurrence.h"
 
 enum month_num_options {
+       MONTH_NUM_INVALID = -1,
        MONTH_NUM_FIRST,
        MONTH_NUM_SECOND,
        MONTH_NUM_THIRD,
@@ -1262,25 +1263,25 @@ ecep_recurrence_simple_recur_to_comp (ECompEditorPageRecurrence *page_recurrence
 
                ii = 0;
 
-               if (e_weekday_chooser_get_selected (chooser, E_DATE_SUNDAY))
+               if (e_weekday_chooser_get_selected (chooser, G_DATE_SUNDAY))
                        r.by_day[ii++] = ICAL_SUNDAY_WEEKDAY;
 
-               if (e_weekday_chooser_get_selected (chooser, E_DATE_MONDAY))
+               if (e_weekday_chooser_get_selected (chooser, G_DATE_MONDAY))
                        r.by_day[ii++] = ICAL_MONDAY_WEEKDAY;
 
-               if (e_weekday_chooser_get_selected (chooser, E_DATE_TUESDAY))
+               if (e_weekday_chooser_get_selected (chooser, G_DATE_TUESDAY))
                        r.by_day[ii++] = ICAL_TUESDAY_WEEKDAY;
 
-               if (e_weekday_chooser_get_selected (chooser, E_DATE_WEDNESDAY))
+               if (e_weekday_chooser_get_selected (chooser, G_DATE_WEDNESDAY))
                        r.by_day[ii++] = ICAL_WEDNESDAY_WEEKDAY;
 
-               if (e_weekday_chooser_get_selected (chooser, E_DATE_THURSDAY))
+               if (e_weekday_chooser_get_selected (chooser, G_DATE_THURSDAY))
                        r.by_day[ii++] = ICAL_THURSDAY_WEEKDAY;
 
-               if (e_weekday_chooser_get_selected (chooser, E_DATE_FRIDAY))
+               if (e_weekday_chooser_get_selected (chooser, G_DATE_FRIDAY))
                        r.by_day[ii++] = ICAL_FRIDAY_WEEKDAY;
 
-               if (e_weekday_chooser_get_selected (chooser, E_DATE_SATURDAY))
+               if (e_weekday_chooser_get_selected (chooser, G_DATE_SATURDAY))
                        r.by_day[ii] = ICAL_SATURDAY_WEEKDAY;
 
                break;
@@ -1300,15 +1301,15 @@ ecep_recurrence_simple_recur_to_comp (ECompEditorPageRecurrence *page_recurrence
                month_day = e_dialog_combo_box_get (page_recurrence->priv->month_day_combo, 
month_day_options_map);
 
                if (month_num == MONTH_NUM_LAST)
-                       month_num = -1;
-               else if (month_num != -1)
+                       month_num = MONTH_NUM_INVALID;
+               else if (month_num != MONTH_NUM_INVALID)
                        month_num++;
                else
                        g_warn_if_reached ();
 
                switch (month_day) {
                case MONTH_DAY_NTH:
-                       if (month_num == -1)
+                       if (month_num == MONTH_NUM_INVALID)
                                r.by_month_day[0] = -1;
                        else
                                r.by_month_day[0] = page_recurrence->priv->month_index;
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index fe49d14..c7a57a1 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -353,9 +353,10 @@ text_requires_quoted_printable (const gchar *text,
        return FALSE;
 }
 
-static CamelTransferEncoding
+static gboolean
 best_encoding (GByteArray *buf,
-               const gchar *charset)
+               const gchar *charset,
+              CamelTransferEncoding *encoding)
 {
        gchar *in, *out, outbuf[256], *ch;
        gsize inlen, outlen;
@@ -363,11 +364,11 @@ best_encoding (GByteArray *buf,
        iconv_t cd;
 
        if (!charset)
-               return -1;
+               return FALSE;
 
        cd = camel_iconv_open (charset, "utf-8");
        if (cd == (iconv_t) -1)
-               return -1;
+               return FALSE;
 
        in = (gchar *) buf->data;
        inlen = buf->len;
@@ -383,16 +384,18 @@ best_encoding (GByteArray *buf,
        camel_iconv_close (cd);
 
        if (status == (gsize) -1 || status > 0)
-               return -1;
+               return FALSE;
 
        if ((count == 0) && (buf->len < LINE_LEN) &&
                !text_requires_quoted_printable (
                (const gchar *) buf->data, buf->len))
-               return CAMEL_TRANSFER_ENCODING_7BIT;
+               *encoding = CAMEL_TRANSFER_ENCODING_7BIT;
        else if (count <= buf->len * 0.17)
-               return CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE;
+               *encoding = CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE;
        else
-               return CAMEL_TRANSFER_ENCODING_BASE64;
+               *encoding = CAMEL_TRANSFER_ENCODING_BASE64;
+
+       return TRUE;
 }
 
 static gchar *
@@ -403,19 +406,17 @@ best_charset (GByteArray *buf,
        const gchar *charset;
 
        /* First try US-ASCII */
-       *encoding = best_encoding (buf, "US-ASCII");
-       if (*encoding == CAMEL_TRANSFER_ENCODING_7BIT)
+       if (best_encoding (buf, "US-ASCII", encoding) &&
+           *encoding == CAMEL_TRANSFER_ENCODING_7BIT)
                return NULL;
 
        /* Next try the user-specified charset for this message */
-       *encoding = best_encoding (buf, default_charset);
-       if (*encoding != -1)
+       if (best_encoding (buf, default_charset, encoding))
                return g_strdup (default_charset);
 
        /* Now try the user's default charset from the mail config */
        charset = e_composer_get_default_charset ();
-       *encoding = best_encoding (buf, charset);
-       if (*encoding != -1)
+       if (best_encoding (buf, charset, encoding))
                return g_strdup (charset);
 
        /* Try to find something that will work */
@@ -426,7 +427,8 @@ best_charset (GByteArray *buf,
                return NULL;
        }
 
-       *encoding = best_encoding (buf, charset);
+       if (!best_encoding (buf, charset, encoding))
+               *encoding = CAMEL_TRANSFER_ENCODING_BASE64;
 
        return g_strdup (charset);
 }
diff --git a/configure.ac b/configure.ac
index 4a6f89a..b9238bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,7 @@ dnl ******************************
 dnl Compiler Warning Flags
 dnl ******************************
 proposed_warning_flags=
+append_warning_flags=
 
 if test "x$enable_maintainer_mode" = "xyes" ; then
        proposed_warning_flags="-Wall -Wextra -Wdeprecated-declarations"
@@ -81,6 +82,10 @@ else
        proposed_warning_flags="-Wno-deprecated-declarations"
 fi
 
+if test "$CC" = "clang" ; then
+       append_warning_flags="-Wno-parentheses-equality -Wno-format-nonliteral"
+fi
+
 AS_COMPILER_FLAGS(WARNING_FLAGS,
        "$proposed_warning_flags
        -Wno-missing-field-initializers
@@ -91,7 +96,8 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
        -Wformat -Wformat-security -Winit-self
        -Wmissing-declarations -Wmissing-include-dirs
        -Wmissing-noreturn -Wnested-externs -Wpointer-arith
-       -Wredundant-decls -Wundef -Wwrite-strings")
+       -Wredundant-decls -Wundef -Wwrite-strings
+       $append_warning_flags")
 AC_SUBST(WARNING_FLAGS)
 
 dnl Other useful compiler warnings for test builds only.
diff --git a/e-util/e-config.c b/e-util/e-config.c
index 008fa74..709f7c9 100644
--- a/e-util/e-config.c
+++ b/e-util/e-config.c
@@ -405,6 +405,9 @@ ec_rebuild (EConfig *config)
 
                /* Now process the item */
                switch (item->type) {
+               case E_CONFIG_INVALID:
+                       g_warn_if_reached ();
+                       break;
                case E_CONFIG_BOOK:
                        /* This is used by the defining code to mark the
                         * type of the config window.  It is cross-checked
@@ -1194,7 +1197,7 @@ config_hook_construct_item (EPluginHook *eph,
 
        d (printf ("  loading config item\n"));
        item = g_malloc0 (sizeof (*item));
-       if ((item->type = e_plugin_hook_id (root, config_hook_item_types, "type")) == -1)
+       if ((item->type = e_plugin_hook_id (root, config_hook_item_types, "type")) == E_CONFIG_INVALID)
                goto error;
        item->path = e_plugin_xml_prop (root, "path");
        item->label = e_plugin_xml_prop_domain (root, "label", eph->plugin->domain);
diff --git a/e-util/e-config.h b/e-util/e-config.h
index 66ae8e7..61ad44c 100644
--- a/e-util/e-config.h
+++ b/e-util/e-config.h
@@ -132,6 +132,8 @@ enum _e_config_target_change_t {
  * display.
  **/
 enum _e_config_t {
+       E_CONFIG_INVALID = -1,
+
        /* use one and only one of these for any given config-window id */
        E_CONFIG_BOOK,
 
diff --git a/e-util/e-event.c b/e-util/e-event.c
index 1fe23d9..34a00be 100644
--- a/e-util/e-event.c
+++ b/e-util/e-event.c
@@ -435,7 +435,7 @@ emph_construct_item (EPluginHook *eph,
                goto error;
        item->target_type = map->id;
        item->type = e_plugin_hook_id (root, emph_item_types, "type");
-       if (item->type == -1)
+       if (item->type == E_EVENT_INVALID)
                item->type = E_EVENT_PASS;
        item->priority = e_plugin_xml_int (root, "priority", 0);
        item->id = e_plugin_xml_prop (root, "id");
diff --git a/e-util/e-event.h b/e-util/e-event.h
index c75d9f8..35e4682 100644
--- a/e-util/e-event.h
+++ b/e-util/e-event.h
@@ -77,6 +77,7 @@ typedef void (*EEventFactoryFunc)(EEvent *ee, gpointer);
  * Events should normally be @E_EVENT_PASS.
  **/
 enum _e_event_t {
+       E_EVENT_INVALID = -1,
        E_EVENT_PASS,           /* passthrough */
        E_EVENT_SINK            /* sink events */
 };
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index d0d5cfd..ad07912 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -390,8 +390,7 @@ e_mail_reader_delete_folder_name (EMailReader *reader,
 
        camel_store_get_folder (
                store, folder_name,
-               CAMEL_STORE_FOLDER_INFO_FAST,
-               G_PRIORITY_DEFAULT, cancellable,
+               0, G_PRIORITY_DEFAULT, cancellable,
                mail_reader_delete_folder_name_cb,
                async_context);
 
@@ -547,8 +546,7 @@ e_mail_reader_expunge_folder_name (EMailReader *reader,
 
        camel_store_get_folder (
                store, folder_name,
-               CAMEL_STORE_FOLDER_INFO_FAST,
-               G_PRIORITY_DEFAULT, cancellable,
+               0, G_PRIORITY_DEFAULT, cancellable,
                mail_reader_expunge_folder_name_cb,
                async_context);
 
diff --git a/mail/message-list.c b/mail/message-list.c
index 9d8c404..19f40e5 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -2683,7 +2683,7 @@ ml_tree_drag_motion (ETree *tree,
                if (has_selection) {
                        selected_folder = camel_store_get_folder_sync (
                                selected_store, selected_folder_name,
-                               CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL);
+                               0, NULL, NULL);
                        g_object_unref (selected_store);
                        g_free (selected_folder_name);
                }
diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c
index ba58904..42b7669 100644
--- a/modules/itip-formatter/itip-view.c
+++ b/modules/itip-formatter/itip-view.c
@@ -1939,7 +1939,7 @@ itip_view_set_item_type (ItipView *view,
 ECalClientSourceType
 itip_view_get_item_type (ItipView *view)
 {
-       g_return_val_if_fail (ITIP_IS_VIEW (view), ITIP_VIEW_MODE_NONE);
+       g_return_val_if_fail (ITIP_IS_VIEW (view), E_CAL_CLIENT_SOURCE_TYPE_LAST);
 
        return view->priv->type;
 }
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 433792c..6fae60a 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -727,7 +727,7 @@ all_accounts:
                if (selected_store != NULL && selected_folder_name != NULL) {
                        folder = camel_store_get_folder_sync (
                                selected_store, selected_folder_name,
-                               CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL);
+                               0, NULL, NULL);
                        e_mail_reader_set_folder (reader, folder);
                        g_object_unref (folder);
                }
@@ -835,7 +835,7 @@ current_account:
                if (selected_store != NULL && selected_folder_name != NULL) {
                        folder = camel_store_get_folder_sync (
                                selected_store, selected_folder_name,
-                               CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL);
+                               0, NULL, NULL);
                        e_mail_reader_set_folder (reader, folder);
                        g_object_unref (folder);
                }
diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c
index daf2870..66c36d4 100644
--- a/smime/gui/certificate-manager.c
+++ b/smime/gui/certificate-manager.c
@@ -259,6 +259,8 @@ load_treeview_state (GtkTreeView *treeview)
        GtkTreeModel *model;
        gchar *cfg_file;
        const gchar *tree_name;
+       gint sort_column, sort_order;
+       GError *error = NULL;
 
        g_return_if_fail (treeview && GTK_IS_TREE_VIEW (treeview));
 
@@ -324,11 +326,20 @@ load_treeview_state (GtkTreeView *treeview)
                g_list_free (columns);
        }
 
+       sort_column = g_key_file_get_integer (keyfile, tree_name, "sort-column", &error);
+       if (error) {
+               sort_column = 0;
+               g_clear_error (&error);
+       }
+
+       sort_order = g_key_file_get_integer (keyfile, tree_name, "sort-order", &error);
+       if (error) {
+               sort_order = GTK_SORT_ASCENDING;
+               g_clear_error (&error);
+       }
+
        sortable = GTK_TREE_SORTABLE (gtk_tree_view_get_model (treeview));
-       gtk_tree_sortable_set_sort_column_id (
-               sortable,
-               g_key_file_get_integer (keyfile, tree_name, "sort-column", 0),
-               g_key_file_get_integer (keyfile, tree_name, "sort-order", GTK_SORT_ASCENDING));
+       gtk_tree_sortable_set_sort_column_id (sortable, sort_column, sort_order);
 
  exit:
        g_free (cfg_file);


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