From 13a56b2801b8a562519d5c90fb038d3d4f5d0f74 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sun, 3 Mar 2019 10:43:16 +0100 Subject: Fix -Werror=cast-function-type with GCC 8 In addition, it removes unnecessary function type casts like: (GDestroyNotify) g_object_unref (GDestroyNotify) g_free --- baobab/src/baobab-remote-connect-dialog.c | 8 ++++- baobab/src/baobab.c | 8 ++--- .../libmateui-deprecated/gsearchtool-entry.c | 3 +- gsearchtool/src/gsearchtool-callbacks.c | 34 ++++++++-------------- gsearchtool/src/gsearchtool.c | 4 +-- logview/src/logview-app.c | 3 +- logview/src/logview-log.c | 11 +++---- logview/src/logview-manager.c | 5 ++-- logview/src/logview-prefs.c | 4 +-- mate-dictionary/libgdict/gdict-client-context.c | 14 +++------ mate-dictionary/libgdict/gdict-context.c | 4 +-- mate-dictionary/libgdict/gdict-defbox.c | 10 ++----- mate-dictionary/libgdict/gdict-source-loader.c | 27 +++++------------ mate-dictionary/src/gdict-app.c | 13 ++------- mate-dictionary/src/gdict-sidebar.c | 5 ++-- 15 files changed, 55 insertions(+), 98 deletions(-) diff --git a/baobab/src/baobab-remote-connect-dialog.c b/baobab/src/baobab-remote-connect-dialog.c index c78725ca..6c901f3d 100644 --- a/baobab/src/baobab-remote-connect-dialog.c +++ b/baobab/src/baobab-remote-connect-dialog.c @@ -383,6 +383,12 @@ baobab_remote_connect_dialog_class_init (BaobabRemoteConnectDialogClass *class) gobject_class = G_OBJECT_CLASS (class); gobject_class->finalize = baobab_remote_connect_dialog_finalize; } +static void +destroy_label (GtkWidget *widget, + gpointer user_data) +{ + gtk_widget_destroy (widget); +} static void setup_for_type (BaobabRemoteConnectDialog *dialog) @@ -429,7 +435,7 @@ setup_for_type (BaobabRemoteConnectDialog *dialog) } /* Destroy all labels */ gtk_container_foreach (GTK_CONTAINER (dialog->details->grid), - (GtkCallback) gtk_widget_destroy, NULL); + destroy_label, NULL); i = 1; grid = dialog->details->grid; diff --git a/baobab/src/baobab.c b/baobab/src/baobab.c index ff4f0bfa..33ef384e 100644 --- a/baobab/src/baobab.c +++ b/baobab/src/baobab.c @@ -721,8 +721,7 @@ baobab_set_excluded_locations (gchar **uris) { gint i; - g_slist_foreach (baobab.excluded_locations, (GFunc) g_object_unref, NULL); - g_slist_free (baobab.excluded_locations); + g_slist_free_full (baobab.excluded_locations, g_object_unref); baobab.excluded_locations = NULL; for (i = 0; uris[i] != NULL; ++i) { baobab.excluded_locations = g_slist_prepend (baobab.excluded_locations, @@ -896,8 +895,7 @@ baobab_shutdown (void) g_free (baobab.selected_path); - g_slist_foreach (baobab.excluded_locations, (GFunc) g_object_unref, NULL); - g_slist_free (baobab.excluded_locations); + g_slist_free_full (baobab.excluded_locations, g_object_unref); if (baobab.ui_settings) { g_object_unref (baobab.ui_settings); @@ -1319,7 +1317,7 @@ main (int argc, char *argv[]) g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) start_proc_on_command_line, file, - (GDestroyNotify) g_object_unref); + g_object_unref); } g_strfreev (directories); diff --git a/gsearchtool/libmateui-deprecated/gsearchtool-entry.c b/gsearchtool/libmateui-deprecated/gsearchtool-entry.c index daa3c9aa..7b12466f 100644 --- a/gsearchtool/libmateui-deprecated/gsearchtool-entry.c +++ b/gsearchtool/libmateui-deprecated/gsearchtool-entry.c @@ -268,8 +268,7 @@ gsearch_history_entry_save_history (GsearchHistoryEntry *entry) "search-history", g_variant_new ("a{sas}", &history_builder)); - g_slist_foreach (items, (GFunc) g_free, NULL); - g_slist_free (items); + g_slist_free_full (items, g_free); g_free (key); } diff --git a/gsearchtool/src/gsearchtool-callbacks.c b/gsearchtool/src/gsearchtool-callbacks.c index 6f064a82..da8b7bda 100644 --- a/gsearchtool/src/gsearchtool-callbacks.c +++ b/gsearchtool/src/gsearchtool-callbacks.c @@ -478,8 +478,7 @@ open_file_cb (GtkMenuItem * action, response = display_dialog_file_open_limit (gsearch->window, g_list_length (list)); if (response == GTK_RESPONSE_CANCEL) { - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); return; } } @@ -535,8 +534,7 @@ open_file_cb (GtkMenuItem * action, g_free (utf8_name); g_free (locale_file); } - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); } static gint @@ -616,8 +614,7 @@ open_folder_cb (GtkAction * action, response = display_dialog_folder_open_limit (gsearch->window, g_list_length (list)); if (response == GTK_RESPONSE_CANCEL) { - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); return; } } @@ -651,8 +648,7 @@ open_folder_cb (GtkAction * action, display_dialog_could_not_open_folder (gsearch->window, utf8_folder); - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); g_free (locale_folder); g_free (utf8_folder); g_object_unref (g_file); @@ -665,8 +661,7 @@ open_folder_cb (GtkAction * action, g_free (locale_file); g_free (utf8_folder); } - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); g_object_unref (g_file); g_object_unref (g_file_info); g_object_unref (g_app_info); @@ -918,8 +913,7 @@ move_to_trash_cb (GtkAction * action, g_free (message); } } - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); g_free (locale_filename); g_free (utf8_filename); g_free (utf8_basename); @@ -1098,7 +1092,7 @@ build_popup_menu_for_file (GSearchWindow * gsearch, gtk_widget_show (new1); g_object_set_data_full (G_OBJECT (new1), "app", (GAppInfo *)list->data, - (GDestroyNotify) g_object_unref); + g_object_unref); gtk_container_add (GTK_CONTAINER (gsearch->search_results_popup_menu), new1); g_signal_connect ((gpointer) new1, "activate", G_CALLBACK (open_file_cb), @@ -1138,7 +1132,7 @@ build_popup_menu_for_file (GSearchWindow * gsearch, gtk_widget_show (new1); g_object_set_data_full (G_OBJECT (new1), "app", (GAppInfo *)list->data, - (GDestroyNotify) g_object_unref); + g_object_unref); if (list_length >= 4) { @@ -1393,8 +1387,7 @@ file_button_release_event_cb (GtkWidget * widget, } g_free (locale_file_first); g_free (utf8_name_first); - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); } else if (event->button == 1 || event->button == 2) { if (gsearch->is_search_results_single_click_to_activate == TRUE) { @@ -1546,8 +1539,7 @@ drag_begin_file_cb (GtkWidget * widget, gtk_tree_model_get (GTK_TREE_MODEL (gsearch->search_results_list_store), &iter, COLUMN_ICON, &pixbuf, -1); - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); if (pixbuf) { gtk_drag_set_icon_pixbuf (context, pixbuf, 0, 0); @@ -1617,8 +1609,7 @@ drag_file_cb (GtkWidget * widget, g_free (utf8_name); g_free (locale_file); } - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); g_free (uri_list); } @@ -1882,8 +1873,7 @@ key_press_cb (GtkWidget * widget, gtk_tree_model_get (GTK_TREE_MODEL (gsearch->search_results_list_store), &iter, COLUMN_NO_FILES_FOUND, &no_files_found, -1); - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); if (!no_files_found) { gtk_menu_popup_at_pointer (GTK_MENU (gsearch->search_results_popup_menu), diff --git a/gsearchtool/src/gsearchtool.c b/gsearchtool/src/gsearchtool.c index 27ea4200..68c14b80 100644 --- a/gsearchtool/src/gsearchtool.c +++ b/gsearchtool/src/gsearchtool.c @@ -2968,7 +2968,7 @@ gsearch_window_finalize (GObject * object) } static void -gsearch_window_class_init (GSearchWindowClass * klass) +gsearch_window_class_init (GSearchWindowClass * klass, void * dara) { GObjectClass * object_class = (GObjectClass *) klass; @@ -2991,7 +2991,7 @@ gsearch_window_get_type (void) NULL, sizeof (GSearchWindow), 0, - (GInstanceInitFunc) gsearch_app_create + (GInstanceInitFunc)(void (*)(void)) gsearch_app_create }; object_type = g_type_register_static (GTK_TYPE_WINDOW, "GSearchWindow", &object_info, 0); } diff --git a/logview/src/logview-app.c b/logview/src/logview-app.c index ffa37ec7..6d30e682 100644 --- a/logview/src/logview-app.c +++ b/logview/src/logview-app.c @@ -145,8 +145,7 @@ enumerate_job_finish (EnumerateJob *job) logview_manager_add_logs_from_name_list (app->priv->manager, files, files->data); - g_slist_foreach (files, (GFunc) g_free, NULL); - g_slist_free (files); + g_slist_free_full (files, g_free); g_object_unref (job->app); g_slice_free (EnumerateJob, job); diff --git a/logview/src/logview-log.c b/logview/src/logview-log.c index 272fb463..2bd0224c 100644 --- a/logview/src/logview-log.c +++ b/logview/src/logview-log.c @@ -115,9 +115,8 @@ do_finalize (GObject *obj) } if (log->priv->days) { - g_slist_foreach (log->priv->days, - (GFunc) logview_utils_day_free, NULL); - g_slist_free (log->priv->days); + g_slist_free_full (log->priv->days, + (GDestroyNotify) logview_utils_day_free); log->priv->days = NULL; } @@ -256,8 +255,7 @@ new_lines_job_done (gpointer data) g_clear_object (&job->cancellable); - g_slist_foreach (job->new_days, (GFunc) logview_utils_day_free, NULL); - g_slist_free (job->new_days); + g_slist_free_full (job->new_days, (GDestroyNotify) logview_utils_day_free); /* drop the reference we acquired before */ g_object_unref (job->log); @@ -757,8 +755,7 @@ log_load (GIOSchedulerJob *io_job, if ((days = log_read_dates (parse_data, time (NULL))) != NULL) { log->priv->has_days = TRUE; - g_slist_foreach (days, (GFunc) logview_utils_day_free, NULL); - g_slist_free (days); + g_slist_free_full (days, (GDestroyNotify) logview_utils_day_free); } else { log->priv->has_days = FALSE; } diff --git a/logview/src/logview-manager.c b/logview/src/logview-manager.c index 54b5320b..ca1c423f 100644 --- a/logview/src/logview-manager.c +++ b/logview/src/logview-manager.c @@ -128,7 +128,7 @@ logview_manager_init (LogviewManager *self) priv->active_log = NULL; priv->logs = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); + g_free, g_object_unref); } static MultipleCreation * @@ -147,9 +147,8 @@ multiple_creation_op_new (int total) static void multiple_creation_op_free (MultipleCreation *mc) { - g_ptr_array_foreach (mc->errors, (GFunc) g_strfreev, NULL); + g_ptr_array_set_free_func (mc->errors, (GDestroyNotify) g_strfreev); g_ptr_array_free (mc->errors, TRUE); - g_slice_free (MultipleCreation, mc); } diff --git a/logview/src/logview-prefs.c b/logview/src/logview-prefs.c index e0fe79c2..877936a8 100644 --- a/logview/src/logview-prefs.c +++ b/logview/src/logview-prefs.c @@ -161,8 +161,8 @@ load_filters (LogviewPrefs *prefs) PREF_FILTERS); prefs->priv->filters = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) g_object_unref); + g_free, + g_object_unref); for (idx = 0; filters[idx] != NULL; idx++) { str = filters[idx]; diff --git a/mate-dictionary/libgdict/gdict-client-context.c b/mate-dictionary/libgdict/gdict-client-context.c index af13e800..1728b474 100644 --- a/mate-dictionary/libgdict/gdict-client-context.c +++ b/mate-dictionary/libgdict/gdict-client-context.c @@ -478,11 +478,8 @@ gdict_client_context_finalize (GObject *object) if (priv->commands_queue) { - g_queue_foreach (priv->commands_queue, - (GFunc) gdict_command_free, - NULL); - g_queue_free (priv->commands_queue); - + g_queue_free_full (priv->commands_queue, + (GDestroyNotify) gdict_command_free); priv->commands_queue = NULL; } @@ -925,11 +922,8 @@ clear_command_queue (GdictClientContext *context) if (priv->commands_queue) { - g_queue_foreach (priv->commands_queue, - (GFunc) gdict_command_free, - NULL); - - g_queue_free (priv->commands_queue); + g_queue_free_full (priv->commands_queue, + (GDestroyNotify) gdict_command_free); } /* renew */ diff --git a/mate-dictionary/libgdict/gdict-context.c b/mate-dictionary/libgdict/gdict-context.c index c9dc1eb4..958dcc93 100644 --- a/mate-dictionary/libgdict/gdict-context.c +++ b/mate-dictionary/libgdict/gdict-context.c @@ -50,7 +50,7 @@ #include "gdict-private.h" -static void gdict_context_class_init (gpointer g_iface); +static void gdict_context_class_init (gpointer g_iface, void *user_data); GType @@ -79,7 +79,7 @@ gdict_context_get_type (void) static void -gdict_context_class_init (gpointer g_iface) +gdict_context_class_init (gpointer g_iface, void *user_data) { GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); diff --git a/mate-dictionary/libgdict/gdict-defbox.c b/mate-dictionary/libgdict/gdict-defbox.c index ee48c3e5..49a35e9a 100644 --- a/mate-dictionary/libgdict/gdict-defbox.c +++ b/mate-dictionary/libgdict/gdict-defbox.c @@ -215,9 +215,7 @@ gdict_defbox_finalize (GObject *object) if (priv->definitions) { - g_slist_foreach (priv->definitions, (GFunc) definition_free, NULL); - g_slist_free (priv->definitions); - + g_slist_free_full (priv->definitions, (GDestroyNotify) definition_free); priv->definitions = NULL; } @@ -2592,11 +2590,7 @@ gdict_defbox_clear (GdictDefbox *defbox) /* destroy previously found definitions */ if (priv->definitions) { - g_slist_foreach (priv->definitions, - (GFunc) definition_free, - NULL); - g_slist_free (priv->definitions); - + g_slist_free_full (priv->definitions, (GDestroyNotify) definition_free); priv->definitions = NULL; } diff --git a/mate-dictionary/libgdict/gdict-source-loader.c b/mate-dictionary/libgdict/gdict-source-loader.c index f0e7f740..80004d95 100644 --- a/mate-dictionary/libgdict/gdict-source-loader.c +++ b/mate-dictionary/libgdict/gdict-source-loader.c @@ -89,11 +89,8 @@ gdict_source_loader_finalize (GObject *object) if (priv->paths) { - g_slist_foreach (priv->paths, - (GFunc) g_free, - NULL); - g_slist_free (priv->paths); - + g_slist_free_full (priv->paths, + g_free); priv->paths = NULL; } @@ -102,11 +99,8 @@ gdict_source_loader_finalize (GObject *object) if (priv->sources) { - g_slist_foreach (priv->sources, - (GFunc) g_object_unref, - NULL); - g_slist_free (priv->sources); - + g_slist_free_full (priv->sources, + g_object_unref); priv->sources = NULL; } @@ -222,7 +216,7 @@ gdict_source_loader_init (GdictSourceLoader *loader) priv->sources = NULL; priv->sources_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, + g_free, NULL); /* ensure that the sources list will be updated */ @@ -366,10 +360,8 @@ gdict_source_loader_update_sources (GdictSourceLoader *loader) g_assert (GDICT_IS_SOURCE_LOADER (loader)); - g_slist_foreach (loader->priv->sources, - (GFunc) g_object_unref, - NULL); - g_slist_free (loader->priv->sources); + g_slist_free_full (loader->priv->sources, + g_object_unref); loader->priv->sources = NULL; filenames = build_source_filenames (loader); @@ -404,10 +396,7 @@ gdict_source_loader_update_sources (GdictSourceLoader *loader) g_signal_emit (loader, loader_signals[SOURCE_LOADED], 0, source); } - g_slist_foreach (filenames, - (GFunc) g_free, - NULL); - g_slist_free (filenames); + g_slist_free_full (filenames, g_free); loader->priv->paths_dirty = FALSE; } diff --git a/mate-dictionary/src/gdict-app.c b/mate-dictionary/src/gdict-app.c index cd751baa..a8b79b38 100644 --- a/mate-dictionary/src/gdict-app.c +++ b/mate-dictionary/src/gdict-app.c @@ -61,16 +61,9 @@ gdict_app_finalize (GObject *object) app->current_window = NULL; - g_slist_foreach (app->windows, - (GFunc) gtk_widget_destroy, - NULL); - g_slist_free (app->windows); - - g_slist_foreach (app->lookup_words, (GFunc) g_free, NULL); - g_slist_free (app->lookup_words); - - g_slist_foreach (app->match_words, (GFunc) g_free, NULL); - g_slist_free (app->match_words); + g_slist_free_full (app->windows, (GDestroyNotify) gtk_widget_destroy); + g_slist_free_full (app->lookup_words, g_free); + g_slist_free_full (app->match_words, g_free); g_free (app->database); g_free (app->source_name); diff --git a/mate-dictionary/src/gdict-sidebar.c b/mate-dictionary/src/gdict-sidebar.c index f2b46d5c..b903677c 100644 --- a/mate-dictionary/src/gdict-sidebar.c +++ b/mate-dictionary/src/gdict-sidebar.c @@ -116,8 +116,7 @@ gdict_sidebar_finalize (GObject *object) if (priv->pages) { - g_slist_foreach (priv->pages, (GFunc) sidebar_page_free, NULL); - g_slist_free (priv->pages); + g_slist_free_full (priv->pages, (GDestroyNotify) sidebar_page_free); } G_OBJECT_CLASS (gdict_sidebar_parent_class)->finalize (object); @@ -419,7 +418,7 @@ gdict_sidebar_add_page (GdictSidebar *sidebar, g_object_set_qdata_full (G_OBJECT (menu_item), sidebar_page_id_quark, g_strdup (page_id), - (GDestroyNotify) g_free); + g_free); g_signal_connect (menu_item, "activate", G_CALLBACK (gdict_sidebar_menu_item_activate), sidebar); -- cgit v1.2.1