[evolution-data-server] Address some of the clang compiler warnings



commit 25f8e7a43898bd5c9c39004119c49699f1d226b2
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 7 11:53:06 2016 +0200

    Address some of the clang compiler warnings

 addressbook/libedata-book/e-book-sqlite.c |   76 ++++++++++++++++------------
 calendar/libecal/e-cal-recur.c            |   39 ++++++--------
 calendar/libedata-cal/e-cal-backend.c     |    2 +-
 camel/camel-store.c                       |    4 +-
 camel/providers/imapx/camel-imapx-store.c |    8 ++--
 configure.ac                              |    8 +++-
 libebackend/e-dbhash.c                    |    1 -
 7 files changed, 74 insertions(+), 64 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-sqlite.c b/addressbook/libedata-book/e-book-sqlite.c
index cee1ea7..f3f85ad 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -127,27 +127,52 @@ ebsql_init_debug (void)
        }
 }
 
+static const gchar *
+ebsql_error_str (EBookSqliteError code)
+{
+       switch (code) {
+               case E_BOOK_SQLITE_ERROR_ENGINE:
+                       return "engine";
+               case E_BOOK_SQLITE_ERROR_CONSTRAINT:
+                       return "constraint";
+               case E_BOOK_SQLITE_ERROR_CONTACT_NOT_FOUND:
+                       return "contact not found";
+               case E_BOOK_SQLITE_ERROR_INVALID_QUERY:
+                       return "invalid query";
+               case E_BOOK_SQLITE_ERROR_UNSUPPORTED_QUERY:
+                       return "unsupported query";
+               case E_BOOK_SQLITE_ERROR_UNSUPPORTED_FIELD:
+                       return "unsupported field";
+               case E_BOOK_SQLITE_ERROR_END_OF_LIST:
+                       return "end of list";
+               case E_BOOK_SQLITE_ERROR_LOAD:
+                       return "load";
+       }
+
+       return "(unknown)";
+}
+
+static const gchar *
+ebsql_origin_str (EbSqlCursorOrigin origin)
+{
+       switch (origin) {
+               case EBSQL_CURSOR_ORIGIN_CURRENT:
+                       return "current";
+               case EBSQL_CURSOR_ORIGIN_BEGIN:
+                       return "begin";
+               case EBSQL_CURSOR_ORIGIN_END:
+                       return "end";
+       }
+
+       return "(invalid)";
+}
+
 #define EBSQL_NOTE(type,action) \
        G_STMT_START { \
                if (ebsql_debug_flags & EBSQL_DEBUG_##type) \
                        { action; }; \
        } G_STMT_END
 
-#define EBSQL_ERROR_STR(code) \
-       ((code) == E_BOOK_SQLITE_ERROR_ENGINE ? "engine" : \
-        (code) == E_BOOK_SQLITE_ERROR_CONSTRAINT ? "constraint" : \
-        (code) == E_BOOK_SQLITE_ERROR_CONTACT_NOT_FOUND ? "contact not found" : \
-        (code) == E_BOOK_SQLITE_ERROR_INVALID_QUERY ? "invalid query" : \
-        (code) == E_BOOK_SQLITE_ERROR_UNSUPPORTED_QUERY ? "unsupported query" : \
-        (code) == E_BOOK_SQLITE_ERROR_UNSUPPORTED_FIELD ? "unsupported field" : \
-        (code) == E_BOOK_SQLITE_ERROR_END_OF_LIST ? "end of list" : \
-        (code) == E_BOOK_SQLITE_ERROR_LOAD ? "load" : "(unknown)")
-
-#define EBSQL_ORIGIN_STR(origin) \
-       ((origin) == EBSQL_CURSOR_ORIGIN_CURRENT ? "current" : \
-        (origin) == EBSQL_CURSOR_ORIGIN_BEGIN ? "begin" : \
-        (origin) == EBSQL_CURSOR_ORIGIN_END ? "end" : "(invalid)")
-
 #define EBSQL_LOCK_MUTEX(mutex) \
        G_STMT_START { \
                if (ebsql_debug_flags & EBSQL_DEBUG_LOCKS) { \
@@ -177,7 +202,7 @@ ebsql_init_debug (void)
                        gchar *format = g_strdup_printf ( \
                                "ERR [%%s]: Set error code '%%s': %s\n", fmt); \
                        g_printerr (format, G_STRFUNC, \
-                                   EBSQL_ERROR_STR (code), ## args); \
+                                   ebsql_error_str (code), ## args); \
                        g_free (format); \
                } \
                g_set_error (error, E_BOOK_SQLITE_ERROR, code, fmt, ## args); \
@@ -189,7 +214,7 @@ ebsql_init_debug (void)
                        g_printerr ("ERR [%s]: " \
                                    "Set error code %s: %s\n", \
                                    G_STRFUNC, \
-                                   EBSQL_ERROR_STR (code), detail); \
+                                   ebsql_error_str (code), detail); \
                } \
                g_set_error_literal (error, E_BOOK_SQLITE_ERROR, code, detail); \
        } G_STMT_END
@@ -4113,21 +4138,6 @@ constraints_insert (GPtrArray *array,
 #endif
 }
 
-static inline QueryElement *
-constraints_take (GPtrArray *array,
-                  gint idx)
-{
-       QueryElement *element;
-
-       g_return_val_if_fail (idx >= 0 && idx < (gint) array->len, NULL);
-
-       element = array->pdata[idx];
-       array->pdata[idx] = NULL;
-       g_ptr_array_remove_index (array, idx);
-
-       return element;
-}
-
 static inline void
 constraints_insert_delimiter (GPtrArray *array,
                               gint idx,
@@ -8090,7 +8100,7 @@ e_book_sqlite_cursor_step (EBookSqlite *ebsql,
                CURSOR,
                g_printerr (
                        "Cursor requested to step by %d with origin %s will move: %s will fetch: %s\n",
-                       count, EBSQL_ORIGIN_STR (origin),
+                       count, ebsql_origin_str (origin),
                        (flags & EBSQL_CURSOR_STEP_MOVE) ? "yes" : "no",
                        (flags & EBSQL_CURSOR_STEP_FETCH) ? "yes" : "no"));
 
diff --git a/calendar/libecal/e-cal-recur.c b/calendar/libecal/e-cal-recur.c
index 66b8170..b86caf3 100644
--- a/calendar/libecal/e-cal-recur.c
+++ b/calendar/libecal/e-cal-recur.c
@@ -947,8 +947,8 @@ static GArray *     cal_obj_generate_set_default    (RecurData      *recur_data,
                                                 ECalRecurVTable *vtable,
                                                 CalObjTime     *occ);
 
-static ECalRecurVTable cal_obj_get_vtable      (ECalRecurrence *recur,
-                                                gboolean *vtable_valid);
+static gboolean cal_obj_get_vtable             (ECalRecurrence *recur,
+                                                ECalRecurVTable *out_vtable);
 static void    cal_obj_initialize_recur_data   (RecurData      *recur_data,
                                                 ECalRecurrence *recur,
                                                 CalObjTime     *event_start);
@@ -2229,7 +2229,6 @@ cal_obj_expand_recurrence (CalObjTime *event_start,
        RecurData recur_data;
        CalObjTime occ, *cotime;
        GArray *all_occs, *occs;
-       gboolean vtable_valid = FALSE;
        gint len;
 
        /* This is the resulting array of CalObjTime elements. */
@@ -2237,8 +2236,7 @@ cal_obj_expand_recurrence (CalObjTime *event_start,
 
        *finished = TRUE;
 
-       vtable = cal_obj_get_vtable (recur, &vtable_valid);
-       if (!vtable_valid)
+       if (!cal_obj_get_vtable (recur, &vtable))
                return all_occs;
 
        /* Calculate some useful data such as some fast lookup tables. */
@@ -2541,47 +2539,44 @@ cal_obj_generate_set_default (RecurData *recur_data,
 }
 
 /* Returns the function table corresponding to the recurrence frequency. */
-static ECalRecurVTable
+static gboolean
 cal_obj_get_vtable (ECalRecurrence *recur,
-                   gboolean *vtable_valid)
+                   ECalRecurVTable *out_vtable)
 {
-       ECalRecurVTable vtable;
-
-       *vtable_valid = TRUE;
+       gboolean valid = TRUE;
 
        switch (recur->freq) {
        case ICAL_YEARLY_RECURRENCE:
-               vtable = cal_obj_yearly_vtable;
+               *out_vtable = cal_obj_yearly_vtable;
                break;
        case ICAL_MONTHLY_RECURRENCE:
-               vtable = cal_obj_monthly_vtable;
+               *out_vtable = cal_obj_monthly_vtable;
                if (recur->bymonthday && recur->byday)
-                       vtable.bymonthday_filter = cal_obj_bymonthday_filter;
+                       out_vtable->bymonthday_filter = cal_obj_bymonthday_filter;
                else
-                       vtable.bymonthday_filter = cal_obj_bymonthday_expand;
+                       out_vtable->bymonthday_filter = cal_obj_bymonthday_expand;
                break;
        case ICAL_WEEKLY_RECURRENCE:
-               vtable = cal_obj_weekly_vtable;
+               *out_vtable = cal_obj_weekly_vtable;
                break;
        case ICAL_DAILY_RECURRENCE:
-               vtable = cal_obj_daily_vtable;
+               *out_vtable = cal_obj_daily_vtable;
                break;
        case ICAL_HOURLY_RECURRENCE:
-               vtable = cal_obj_hourly_vtable;
+               *out_vtable = cal_obj_hourly_vtable;
                break;
        case ICAL_MINUTELY_RECURRENCE:
-               vtable = cal_obj_minutely_vtable;
+               *out_vtable = cal_obj_minutely_vtable;
                break;
        case ICAL_SECONDLY_RECURRENCE:
-               vtable = cal_obj_secondly_vtable;
+               *out_vtable = cal_obj_secondly_vtable;
                break;
        default:
                g_warning ("Unknown recurrence frequency");
-               *vtable_valid = FALSE;
+               valid = FALSE;
        }
 
-       /* coverity[uninit] */
-       return vtable;
+       return valid;
 }
 
 /* This creates a number of fast lookup tables used when filtering with the
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 53bd7ae..62c92c0 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -4052,7 +4052,7 @@ e_cal_backend_get_timezone_finish (ECalBackend *backend,
        if (!tzobject)
                g_set_error_literal (error,
                        E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND,
-                       e_client_error_to_string (E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND));
+                       e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND));
 
        g_warn_if_fail (g_queue_is_empty (&async_context->result_queue));
 
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 490f863..43411d2 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -438,7 +438,7 @@ store_synchronize_sync (CamelStore *store,
                /* ensure all folders are used when expunging */
                CamelFolderInfo *root, *fi;
 
-               g_atomic_int_add (&store->priv->maintenance_lock, 1);
+               (void) g_atomic_int_add (&store->priv->maintenance_lock, 1);
 
                folders = g_ptr_array_new ();
                root = camel_store_get_folder_info_sync (
@@ -504,7 +504,7 @@ store_synchronize_sync (CamelStore *store,
 
        /* Unlock it before the call, thus it's actually done. */
        if (expunge)
-               g_atomic_int_add (&store->priv->maintenance_lock, -1);
+               (void) g_atomic_int_add (&store->priv->maintenance_lock, -1);
 
        if (!local_error && expunge) {
                camel_store_maybe_run_db_maintenance (store, &local_error);
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 9d900e3..cca9c25 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -466,7 +466,7 @@ imapx_store_process_mailbox_attributes (CamelIMAPXStore *store,
        }
 
        folder_path = camel_imapx_mailbox_to_folder_path (mailbox_name, separator);
-       fi = imapx_store_build_folder_info (store, folder_path, flags);
+       fi = imapx_store_build_folder_info (store, folder_path, (CamelFolderInfoFlags) flags);
 
        /* Figure out which signals to emit, if any. */
        if (use_subscriptions || camel_imapx_namespace_get_category (camel_imapx_mailbox_get_namespace 
(mailbox)) != CAMEL_IMAPX_NAMESPACE_PERSONAL) {
@@ -1435,7 +1435,7 @@ imapx_store_remove_unknown_mailboxes_cb (gpointer key,
 
                folder_path = camel_imapx_mailbox_dup_folder_path (mailbox);
                fi = imapx_store_build_folder_info (imapx_store, folder_path,
-                       imapx_store_mailbox_attributes_to_flags (mailbox));
+                       (CamelFolderInfoFlags) imapx_store_mailbox_attributes_to_flags (mailbox));
                camel_store_folder_created (CAMEL_STORE (imapx_store), fi);
                camel_subscribable_folder_subscribed (CAMEL_SUBSCRIBABLE (imapx_store), fi);
                camel_folder_info_free (fi);
@@ -1578,7 +1578,7 @@ sync_folders (CamelIMAPXStore *imapx_store,
        }
 
        /* Don't need to test for zero, just decrement atomically. */
-       g_atomic_int_dec_and_test (&imapx_store->priv->syncing_folders);
+       (void) g_atomic_int_dec_and_test (&imapx_store->priv->syncing_folders);
 
        if (!success)
                goto exit;
@@ -2253,7 +2253,7 @@ exit:
 
        /* This enables CamelStore signal emissions
         * in imapx_store_process_mailbox_attributes() again. */
-       g_atomic_int_dec_and_test (&imapx_store->priv->syncing_folders);
+       (void) g_atomic_int_dec_and_test (&imapx_store->priv->syncing_folders);
 
        return success;
 }
diff --git a/configure.ac b/configure.ac
index 53e1d1d..9781e35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -199,6 +199,7 @@ dnl ******************************
 dnl Compiler Warning Flags
 dnl ******************************
 proposed_warning_flags=
+append_c_warning_flags=
 
 if test "x$enable_maintainer_mode" = "xyes" ; then
        proposed_warning_flags="-Wall -Wextra -Wdeprecated-declarations"
@@ -206,6 +207,10 @@ else
        proposed_warning_flags="-Wno-deprecated-declarations"
 fi
 
+if test "$CC" = "clang" ; then
+       append_c_warning_flags="-Wno-parentheses-equality -Wno-format-nonliteral"
+fi
+
 proposed_warning_flags="$proposed_warning_flags
                -Werror-implicit-function-declaration
                -Wformat -Wformat-security -Winit-self
@@ -218,7 +223,8 @@ proposed_c_warning_flags="$proposed_warning_flags
        -Wno-missing-field-initializers
        -Wno-sign-compare
        -Wno-unused-parameter
-       -Wnested-externs"
+       -Wnested-externs
+       $append_c_warning_flags"
 
 proposed_cxx_warning_flags="$proposed_warning_flags
        -Wabi -Wnoexcept"
diff --git a/libebackend/e-dbhash.c b/libebackend/e-dbhash.c
index 86db929..cfe729d 100644
--- a/libebackend/e-dbhash.c
+++ b/libebackend/e-dbhash.c
@@ -246,7 +246,6 @@ e_dbhash_compare (EDbHash *edbh,
        g_return_val_if_fail (edbh != NULL, FALSE);
        g_return_val_if_fail (edbh->priv != NULL, FALSE);
        g_return_val_if_fail (key != NULL, FALSE);
-       g_return_val_if_fail (compare_hash != NULL, FALSE);
 
        db = edbh->priv->db;
 


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