[gnome-calendar] project: fix build warnings



commit cd50bec506e95a9f95cc6be9075f9bab3588c754
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Aug 29 23:08:39 2016 -0300

    project: fix build warnings
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770466

 src/Makefile.am            |    1 +
 src/e-cal-data-model.c     |   14 ++++----
 src/gcal-application.c     |   23 ++++++------
 src/gcal-application.h     |    4 +-
 src/gcal-edit-dialog.c     |   83 +++++++++++++++-----------------------------
 src/gcal-event.c           |    2 -
 src/gcal-manager.c         |   12 ++++--
 src/gcal-month-view.c      |    2 +-
 src/gcal-source-dialog.c   |   23 +++++++-----
 src/gcal-subscriber-view.c |    1 -
 src/gcal-week-view.c       |    6 ++--
 src/gcal-window.c          |   15 ++++++--
 12 files changed, 87 insertions(+), 99 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 96bbc33..ab79ae7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,6 +4,7 @@ AM_CPPFLAGS =                                             \
     -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"                \
     -DUI_DATA_DIR=\""$(pkgdatadir)/style"\"               \
     $(WARN_CFLAGS)                                        \
+    -Wno-sign-compare                                     \
     -DEDS_DISABLE_DEPRECATED                              \
     -DGOA_API_IS_SUBJECT_TO_CHANGE                        \
     $(CALENDAR_CFLAGS)
diff --git a/src/e-cal-data-model.c b/src/e-cal-data-model.c
index 0295345..2d14cc9 100644
--- a/src/e-cal-data-model.c
+++ b/src/e-cal-data-model.c
@@ -1248,7 +1248,7 @@ cal_data_model_process_modified_or_added_objects (ECalClientView *view,
                cal_data_model_thaw_all_subscribers (data_model);
 
                if (to_expand_recurrences) {
-                       ECalClient *client = e_cal_client_view_ref_client (view);
+                       ECalClient *rclient = e_cal_client_view_ref_client (view);
 
                        view_data_lock (view_data);
                        view_data->to_expand_recurrences = g_slist_concat (
@@ -1257,7 +1257,7 @@ cal_data_model_process_modified_or_added_objects (ECalClientView *view,
                        view_data_unlock (view_data);
 
                        cal_data_model_submit_internal_thread_job (data_model,
-                               cal_data_model_expand_recurrences_thread, client);
+                               cal_data_model_expand_recurrences_thread, rclient);
                }
        }
 
@@ -1881,9 +1881,9 @@ cal_data_model_set_property (GObject *object,
                                E_CAL_DATA_MODEL (object),
                                g_value_get_pointer (value));
                        return;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        }
-
-       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
 
 static void
@@ -1906,9 +1906,9 @@ cal_data_model_get_property (GObject *object,
                                e_cal_data_model_get_timezone (
                                E_CAL_DATA_MODEL (object)));
                        return;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        }
-
-       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
 
 static void
@@ -2646,7 +2646,7 @@ e_cal_data_model_subscribe (ECalDataModel *data_model,
        LOCK_PROPS ();
 
        for (link = data_model->priv->subscribers; link; link = g_slist_next (link)) {
-               SubscriberData *subs_data = link->data;
+               subs_data = link->data;
 
                if (!subs_data)
                        continue;
diff --git a/src/gcal-application.c b/src/gcal-application.c
index 723be69..9330261 100644
--- a/src/gcal-application.c
+++ b/src/gcal-application.c
@@ -447,7 +447,7 @@ gcal_application_show_about (GSimpleAction *simple,
 {
   GcalApplication *self;
   char *copyright;
-  GDateTime *date;
+  GDateTime *dt;
   int created_year = 2012;
   const gchar *authors[] = {
     "Erick PĂ©rez Castellanos <erickpc gnome org>",
@@ -464,9 +464,9 @@ gcal_application_show_about (GSimpleAction *simple,
   };
 
   self = GCAL_APPLICATION (user_data);
-  date = g_date_time_new_now_local ();
+  dt = g_date_time_new_now_local ();
 
-  if (g_date_time_get_year (date) == created_year)
+  if (g_date_time_get_year (dt) == created_year)
     {
       copyright = g_strdup_printf (_("Copyright \xC2\xA9 %d "
                                      "The Calendar authors"),
@@ -476,7 +476,7 @@ gcal_application_show_about (GSimpleAction *simple,
     {
       copyright = g_strdup_printf (_("Copyright \xC2\xA9 %d\xE2\x80\x93%d "
                                      "The Calendar authors"),
-                                   created_year, g_date_time_get_year (date));
+                                   created_year, g_date_time_get_year (dt));
     }
 
   gtk_show_about_dialog (GTK_WINDOW (self->window),
@@ -489,8 +489,9 @@ gcal_application_show_about (GSimpleAction *simple,
                          "logo-icon-name", "org.gnome.Calendar",
                          "translator-credits", _("translator-credits"),
                          NULL);
-  g_free (copyright);
-  g_date_time_unref (date);
+
+  g_clear_pointer (&copyright, g_free);
+  g_clear_pointer (&dt, g_date_time_unref);
 }
 
 static void
@@ -530,16 +531,16 @@ gcal_application_get_settings (GcalApplication *app)
 
 void
 gcal_application_set_uuid (GcalApplication *application,
-                           const gchar     *uuid)
+                           const gchar     *app_uuid)
 {
   g_free (application->uuid);
-  application->uuid = g_strdup (uuid);
+  application->uuid = g_strdup (app_uuid);
 }
 
 void
 gcal_application_set_initial_date (GcalApplication *application,
-                                   GDateTime       *date)
+                                   GDateTime       *initial_date)
 {
-  g_free (application->initial_date);
-  application->initial_date = datetime_to_icaltime (date);
+  g_clear_pointer (&application->initial_date, g_date_time_unref);
+  application->initial_date = datetime_to_icaltime (initial_date);
 }
diff --git a/src/gcal-application.h b/src/gcal-application.h
index 82664b3..64db08b 100644
--- a/src/gcal-application.h
+++ b/src/gcal-application.h
@@ -34,10 +34,10 @@ GcalApplication*  gcal_application_new          (void);
 GcalManager*      gcal_application_get_manager  (GcalApplication *app);
 GSettings*        gcal_application_get_settings (GcalApplication *app);
 void              gcal_application_set_uuid     (GcalApplication *application,
-                                                 const gchar     *uuid);
+                                                 const gchar     *app_uuid);
 
 void              gcal_application_set_initial_date (GcalApplication *application,
-                                                     GDateTime       *date);
+                                                     GDateTime       *initial_date);
 
 G_END_DECLS
 
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index 777bb18..d83f491 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -662,31 +662,35 @@ gcal_edit_dialog_all_day_changed (GtkWidget *widget,
 /*
  * Alarm related functions
  */
+
+#define OFFSET(x)             (G_STRUCT_OFFSET (GcalEditDialog, x))
+#define WIDGET_FROM_OFFSET(x) (G_STRUCT_MEMBER (GtkWidget*, self, x))
+
+struct
+{
+  gint minutes;
+  gint button_offset;
+} minutes_button[] = {
+    { 5,     OFFSET (five_minutes_button) },
+    { 10,    OFFSET (ten_minutes_button) },
+    { 30,    OFFSET (thirty_minutes_button) },
+    { 60,    OFFSET (one_hour_button) },
+    { 1440,  OFFSET (one_day_button) },
+    { 2880,  OFFSET (two_days_button) },
+    { 4320,  OFFSET (three_days_button) },
+    { 10080, OFFSET (one_week_button) }
+};
+
 static GtkWidget*
 get_row_fow_alarm_trigger_minutes (GcalEditDialog *self,
                                    gint            minutes)
 {
-  gint i;
-
-  struct
-  {
-    gint       minutes;
-    GtkWidget *button;
-  } minutes_button[] = {
-      { 5,     self->five_minutes_button },
-      { 10,    self->ten_minutes_button },
-      { 30,    self->thirty_minutes_button },
-      { 60,    self->one_hour_button },
-      { 1440,  self->one_day_button },
-      { 2880,  self->two_days_button },
-      { 4320,  self->three_days_button },
-      { 10080, self->one_week_button }
-  };
+  guint i;
 
   for (i = 0; i < G_N_ELEMENTS (minutes_button); i++)
     {
       if (minutes_button[i].minutes == minutes)
-        return minutes_button[i].button;
+        return WIDGET_FROM_OFFSET (minutes_button[i].button_offset);
     }
 
   return NULL;
@@ -862,22 +866,7 @@ static void
 setup_alarms (GcalEditDialog *self)
 {
   GList *alarms, *l;
-  gint i;
-
-  struct
-  {
-    gint       minutes;
-    GtkWidget *button;
-  } minutes_button[] = {
-      { 5,     self->five_minutes_button },
-      { 10,    self->ten_minutes_button },
-      { 30,    self->thirty_minutes_button },
-      { 60,    self->one_hour_button },
-      { 1440,  self->one_day_button },
-      { 2880,  self->two_days_button },
-      { 4320,  self->three_days_button },
-      { 10080, self->one_week_button }
-  };
+  guint i;
 
   gtk_widget_set_visible (self->alarms_listbox, gcal_event_has_alarms (self->event));
 
@@ -893,7 +882,7 @@ setup_alarms (GcalEditDialog *self)
    * and only make them insensitive when needed.
    */
   for (i = 0; i < G_N_ELEMENTS (minutes_button); i++)
-    gtk_widget_set_sensitive (minutes_button[i].button, TRUE);
+    gtk_widget_set_sensitive (WIDGET_FROM_OFFSET (minutes_button[i].button_offset), TRUE);
 
   for (l = alarms; l != NULL; l = l->next)
     {
@@ -911,7 +900,7 @@ setup_alarms (GcalEditDialog *self)
       for (i = 0; i < G_N_ELEMENTS (minutes_button); i++)
         {
           if (minutes_button[i].minutes == minutes)
-            gtk_widget_set_sensitive (minutes_button[i].button, FALSE);
+            gtk_widget_set_sensitive (WIDGET_FROM_OFFSET (minutes_button[i].button_offset), FALSE);
         }
 
       /* Add the row */
@@ -925,32 +914,16 @@ static void
 add_alarm_button_clicked (GtkWidget      *button,
                           GcalEditDialog *self)
 {
-  gint i, minutes;
-
-  struct
-  {
-    GtkWidget *button;
-    gint       minutes;
-  } button_minutes[] = {
-      { self->five_minutes_button,   5 },
-      { self->ten_minutes_button,    10 },
-      { self->thirty_minutes_button, 30 },
-      { self->one_hour_button,       60 },
-      { self->one_day_button,        1440 },
-      { self->two_days_button,       2880 },
-      { self->three_days_button,     4320 },
-      { self->one_week_button,       10080 },
-      { NULL, 0 }
-  };
+  guint i, minutes;
 
   /* Search for the button minute */
   minutes = 0;
 
-  for (i = 0; i < G_N_ELEMENTS (button_minutes); i++)
+  for (i = 0; i < G_N_ELEMENTS (minutes_button); i++)
     {
-      if (button_minutes[i].button == button)
+      if (WIDGET_FROM_OFFSET (minutes_button[i].button_offset) == button)
         {
-          minutes = button_minutes[i].minutes;
+          minutes = minutes_button[i].minutes;
           break;
         }
     }
diff --git a/src/gcal-event.c b/src/gcal-event.c
index 6e6b27a..408604b 100644
--- a/src/gcal-event.c
+++ b/src/gcal-event.c
@@ -957,8 +957,6 @@ gcal_event_add_alarm (GcalEvent *self,
   /* Only 1 alarm per relative time */
   if (g_hash_table_contains (self->alarms, GINT_TO_POINTER (type)))
     {
-      const gchar *alarm_uid;
-
       alarm_uid = g_hash_table_lookup (self->alarms, GINT_TO_POINTER (type));
 
       e_cal_component_remove_alarm (self->component, alarm_uid);
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index 635457d..a7c07e0 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -925,9 +925,10 @@ gcal_manager_set_property (GObject      *object,
       if (g_set_object (&self->settings, g_value_get_object (value)))
         g_object_notify (object, "settings");
       return;
-    }
 
-  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
 }
 
 static void
@@ -943,6 +944,9 @@ gcal_manager_get_property (GObject    *object,
     case PROP_SETTINGS:
       g_value_set_object (value, self->settings);
       return;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
 
   G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1250,7 +1254,7 @@ gcal_manager_enable_source (GcalManager *manager,
 {
   GcalManagerUnit *unit;
   gchar **new_disabled_sources;
-  gint i;
+  guint i;
 
   unit = g_hash_table_lookup (manager->clients, source);
 
@@ -1293,7 +1297,7 @@ gcal_manager_disable_source (GcalManager *manager,
 {
   GcalManagerUnit *unit;
   gchar **new_disabled_sources;
-  gint i;
+  guint i;
   const gchar *source_uid;
 
   unit = g_hash_table_lookup (manager->clients, source);
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 9896802..36f23a4 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -2099,7 +2099,7 @@ gcal_month_view_motion_notify_event (GtkWidget      *widget,
 
       if (new_end_cell >= priv->days_delay && new_end_cell < days)
         {
-          guint previous_end_cell;
+          gint previous_end_cell;
 
           previous_end_cell = new_end_cell;
 
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index b05d299..ca5f187 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -511,8 +511,8 @@ description_label_link_activated (GtkWidget *widget,
                                   gchar     *uri,
                                   gpointer   user_data)
 {
-  gchar *command[] = {"gnome-control-center", "online-accounts", NULL};
-  g_spawn_async (NULL, command, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
+  const gchar* const command[] = { "gnome-control-center", "online-accounts", NULL };
+  g_spawn_async (NULL, (gchar**) command, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
 
   return TRUE;
 }
@@ -653,11 +653,14 @@ name_entry_text_changed (GObject    *object,
 }
 
 static void
-spawn_goa_with_args (gchar *action,
-                     gchar *arg)
+spawn_goa_with_args (const gchar *action,
+                     const gchar *arg)
 {
-  gchar *command[] = {"gnome-control-center", "online-accounts", action, arg, NULL};
-  g_spawn_async (NULL, command, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL, NULL, NULL, NULL, 
NULL);
+  const gchar* const command[] = { "gnome-control-center", "online-accounts", action, arg, NULL };
+  g_spawn_async (NULL, (gchar**) command,
+                 NULL,
+                 G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,
+                 NULL, NULL, NULL, NULL);
 }
 
 /**
@@ -1094,8 +1097,7 @@ static void
 online_accounts_settings_button_clicked (GtkWidget *button,
                                          gpointer   user_data)
 {
-  gchar *command[] = {"gnome-control-center", "online-accounts", NULL};
-  g_spawn_async (NULL, command, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
+  spawn_goa_with_args (NULL, NULL);
 }
 
 static void
@@ -1979,7 +1981,7 @@ add_goa_account (GcalSourceDialog *dialog,
   GtkWidget *enabled_label;
   GtkWidget *row;
   GtkWidget *icon;
-  gchar *icon_name = "goa";
+  const gchar *icon_name;
 
   type = get_account_type (account);
 
@@ -2011,6 +2013,8 @@ add_goa_account (GcalSourceDialog *dialog,
       break;
 
     case GCAL_ACCOUNT_TYPE_NOT_SUPPORTED:
+    default:
+      icon_name = "goa";
       g_assert_not_reached ();
     }
 
@@ -2098,6 +2102,7 @@ goa_account_removed_cb (GoaClient *client,
           gtk_widget_show (self->owncloud_stub_row);
           break;
 
+        case GCAL_ACCOUNT_TYPE_NOT_SUPPORTED:
         default:
           g_assert_not_reached ();
         }
diff --git a/src/gcal-subscriber-view.c b/src/gcal-subscriber-view.c
index e020add..550ad41 100644
--- a/src/gcal-subscriber-view.c
+++ b/src/gcal-subscriber-view.c
@@ -262,7 +262,6 @@ gcal_subscriber_view_remove (GtkContainer *container,
 
               while (g_hash_table_iter_next (&iter, &key, &value))
                 {
-                  GList *aux;
                   gboolean should_break;
 
                   should_break = FALSE;
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index 4d9323d..264ab89 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -1148,11 +1148,11 @@ gcal_week_view_add (GtkContainer *container,
 
   for (l = priv->days[day]; l != NULL; l = l->next)
     {
-      GtkWidget *event;
+      GtkWidget *event_widget;
 
-      event = GTK_WIDGET (((GcalWeekViewChild*) l->data)->widget);
+      event_widget = GTK_WIDGET (((GcalWeekViewChild*) l->data)->widget);
       if (gcal_event_widget_equal (GCAL_EVENT_WIDGET (widget),
-                                   GCAL_EVENT_WIDGET (event)))
+                                   GCAL_EVENT_WIDGET (event_widget)))
         {
           //TODO: remove once the main-dev phase its over
           g_warning ("Trying to add an event with the same uuid to the view");
diff --git a/src/gcal-window.c b/src/gcal-window.c
index b7fe5bd..3864ce3 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -450,6 +450,8 @@ update_today_button_sensitive (GcalWindow *window)
       sensitive = window->active_date->year != window->current_date->year;
       break;
 
+    case GCAL_WINDOW_VIEW_LIST:
+    case GCAL_WINDOW_VIEW_SEARCH:
     default:
       sensitive = TRUE;
       break;
@@ -498,6 +500,7 @@ date_updated (GtkButton  *button,
           break;
         case GCAL_WINDOW_VIEW_LIST:
         case GCAL_WINDOW_VIEW_SEARCH:
+        default:
           break;
         }
 
@@ -1141,6 +1144,7 @@ edit_dialog_closed (GtkDialog *dialog,
       break;
 
     case GTK_RESPONSE_CANCEL:
+    default:
       break;
 
     }
@@ -1513,9 +1517,10 @@ gcal_window_set_property (GObject      *object,
           g_object_notify (object, "manager");
         }
       return;
-    }
 
-  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
 }
 
 static void
@@ -1540,9 +1545,10 @@ gcal_window_get_property (GObject    *object,
     case PROP_NEW_EVENT_MODE:
       g_value_set_boolean (value, self->new_event_mode);
       return;
-    }
 
-  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
 }
 
 static gboolean
@@ -1656,6 +1662,7 @@ gcal_window_new_event (GcalWindow *window)
       break;
     case GCAL_WINDOW_VIEW_LIST:
     case GCAL_WINDOW_VIEW_SEARCH:
+    default:
       break;
     }
 


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