[network-manager-applet] all: fix bad function pointer casts



commit 15ac92e6a42317e86ffb6d52a9ce5cacbf9e8c87
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Apr 30 19:05:35 2018 +0200

    all: fix bad function pointer casts
    
    This makes GCC 8 unhappy, almost sad.

 src/ap-menu-item.c                         |    2 +-
 src/applet-device-broadband.c              |    4 +++-
 src/applet-device-wifi.c                   |    6 +++---
 src/applet-vpn-request.c                   |    4 +---
 src/applet.c                               |    9 +++++----
 src/connection-editor/ip4-routes-dialog.c  |    3 +--
 src/connection-editor/ip6-routes-dialog.c  |    3 +--
 src/connection-editor/nm-connection-list.c |    4 +---
 src/connection-editor/page-dcb.c           |    9 +++++++--
 src/connection-editor/page-ip4.c           |   15 ++++++---------
 src/connection-editor/page-ip6.c           |    9 ++++-----
 src/connection-editor/page-master.c        |    4 +---
 src/libnm-gtk/nm-mobile-providers.c        |    3 +--
 src/libnma/nma-mobile-providers.c          |    3 +--
 14 files changed, 36 insertions(+), 42 deletions(-)
---
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index b37b4ec..92953c0 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -326,7 +326,7 @@ finalize (GObject *object)
        g_free (priv->hash);
        g_free (priv->ssid_string);
 
-       g_slist_foreach (priv->dupes, (GFunc) g_free, NULL);
+       g_slist_free_full (priv->dupes, g_free);
        g_slist_free (priv->dupes);
 
        G_OBJECT_CLASS (nm_network_menu_item_parent_class)->finalize (object);
diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c
index da1790e..e1907fe 100644
--- a/src/applet-device-broadband.c
+++ b/src/applet-device-broadband.c
@@ -668,8 +668,10 @@ typedef struct {
 } BroadbandMenuItemInfo;
 
 static void
-menu_item_info_destroy (BroadbandMenuItemInfo *info)
+menu_item_info_destroy (gpointer data, GClosure *closure)
 {
+       BroadbandMenuItemInfo *info = data;
+
        g_object_unref (G_OBJECT (info->device));
        if (info->connection)
                g_object_unref (info->connection);
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 08ecef1..d8a31a0 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -294,7 +294,7 @@ typedef struct {
 } WifiMenuItemInfo;
 
 static void
-wifi_menu_item_info_destroy (gpointer data)
+wifi_menu_item_info_destroy (gpointer data, GClosure *closure)
 {
        WifiMenuItemInfo *info = (WifiMenuItemInfo *) data;
 
@@ -652,7 +652,7 @@ create_new_ap_item (NMDeviceWifi *device,
                        g_signal_connect_data (subitem, "activate",
                                               G_CALLBACK (wifi_menu_item_activate),
                                               info,
-                                              (GClosureNotify) wifi_menu_item_info_destroy, 0);
+                                              wifi_menu_item_info_destroy, 0);
 
                        gtk_menu_shell_append (GTK_MENU_SHELL (submenu), GTK_WIDGET (subitem));
                        gtk_widget_show (subitem);
@@ -676,7 +676,7 @@ create_new_ap_item (NMDeviceWifi *device,
                                       "activate",
                                       G_CALLBACK (wifi_menu_item_activate),
                                       info,
-                                      (GClosureNotify) wifi_menu_item_info_destroy,
+                                      wifi_menu_item_info_destroy,
                                       0);
        }
 
diff --git a/src/applet-vpn-request.c b/src/applet-vpn-request.c
index ccd9830..e7ca080 100644
--- a/src/applet-vpn-request.c
+++ b/src/applet-vpn-request.c
@@ -470,8 +470,6 @@ request_data_free (RequestData *req_data)
                }
        }
 
-       g_slist_foreach (req_data->lines, (GFunc) g_free, NULL);
-       g_slist_free (req_data->lines);
-
+       g_slist_free_full (req_data->lines, g_free);
        g_slice_free (RequestData, req_data);
 }
diff --git a/src/applet.c b/src/applet.c
index 3f87165..21e36b6 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -703,8 +703,7 @@ applet_notify_server_has_actions (void)
                        break;
                }
        }
-       g_list_foreach (server_caps, (GFunc) g_free, NULL);
-       g_list_free (server_caps);
+       g_list_free_full (server_caps, g_free);
 
        return has_actions;
 }
@@ -1263,8 +1262,10 @@ struct AppletDeviceMenuInfo {
 };
 
 static void
-applet_device_info_destroy (struct AppletDeviceMenuInfo *info)
+applet_device_info_destroy (gpointer data, GClosure *closure)
 {
+       struct AppletDeviceMenuInfo *info = data;
+
        g_return_if_fail (info != NULL);
 
        if (info->device)
@@ -1324,7 +1325,7 @@ nma_menu_device_get_menu_item (NMDevice *device,
                g_signal_connect_data (item, "activate",
                                       G_CALLBACK (applet_device_disconnect_db),
                                       info,
-                                      (GClosureNotify) applet_device_info_destroy, 0);
+                                      applet_device_info_destroy, 0);
                gtk_widget_set_sensitive (item, TRUE);
                break;
        }
diff --git a/src/connection-editor/ip4-routes-dialog.c b/src/connection-editor/ip4-routes-dialog.c
index 0b21bf5..daed6df 100644
--- a/src/connection-editor/ip4-routes-dialog.c
+++ b/src/connection-editor/ip4-routes-dialog.c
@@ -161,8 +161,7 @@ route_delete_clicked (GtkButton *button, gpointer user_data)
        if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data))
                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 
-       g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
-       g_list_free (selected_rows);
+       g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
 
        num_rows = gtk_tree_model_iter_n_children (model, NULL);
        if (num_rows && gtk_tree_model_iter_nth_child (model, &iter, NULL, num_rows - 1)) {
diff --git a/src/connection-editor/ip6-routes-dialog.c b/src/connection-editor/ip6-routes-dialog.c
index 64e060a..e92464d 100644
--- a/src/connection-editor/ip6-routes-dialog.c
+++ b/src/connection-editor/ip6-routes-dialog.c
@@ -196,8 +196,7 @@ route_delete_clicked (GtkButton *button, gpointer user_data)
        if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data))
                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 
-       g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
-       g_list_free (selected_rows);
+       g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
 
        num_rows = gtk_tree_model_iter_n_children (model, NULL);
        if (num_rows && gtk_tree_model_iter_nth_child (model, &iter, NULL, num_rows - 1)) {
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 79fadd2..6eba04d 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -95,9 +95,7 @@ get_active_connection (GtkTreeView *treeview)
        if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data))
                gtk_tree_model_get (model, &iter, COL_CONNECTION, &connection, -1);
 
-       /* free memory */
-       g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
-       g_list_free (selected_rows);
+       g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
 
        /* gtk_tree_model_get() will have reffed connection, but we don't
         * need that since we know the model will continue to hold a ref.
diff --git a/src/connection-editor/page-dcb.c b/src/connection-editor/page-dcb.c
index f739cac..74b6b43 100644
--- a/src/connection-editor/page-dcb.c
+++ b/src/connection-editor/page-dcb.c
@@ -502,6 +502,12 @@ enable_toggled_cb (GtkToggleButton *button, EnableInfo *info)
 }
 
 static void
+free_enable_info (gpointer data, GClosure *closure)
+{
+       g_free (data);
+}
+
+static void
 feature_setup (CEPageDcb *self, NMSettingDcb *s_dcb, const Feature *f)
 {
        CEPage *parent = CE_PAGE (self);
@@ -521,8 +527,7 @@ feature_setup (CEPageDcb *self, NMSettingDcb *s_dcb, const Feature *f)
        info = g_malloc0 (sizeof (EnableInfo));
        info->f = f;
        info->page = parent;
-       g_signal_connect (widget, "toggled", G_CALLBACK (enable_toggled_cb), info);
-       g_object_weak_ref (G_OBJECT (widget), (GWeakNotify) g_free, info);
+       g_signal_connect_data (widget, "toggled", G_CALLBACK (enable_toggled_cb), info, free_enable_info, 0);
 
        /* Advertise */
        widget = get_widget (parent->builder, f->prefix, "_advertise_checkbutton");
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index b345691..dd42bd7 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -559,8 +559,7 @@ addr_delete_clicked (GtkButton *button, gpointer user_data)
        if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data))
                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 
-       g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
-       g_list_free (selected_rows);
+       g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
 
        num_rows = gtk_tree_model_iter_n_children (model, NULL);
        if (num_rows && gtk_tree_model_iter_nth_child (model, &iter, NULL, num_rows - 1)) {
@@ -924,9 +923,9 @@ key_pressed_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 }
 
 static void
-address_line_info_destroy (AddressLineInfo *info)
+address_line_info_destroy (gpointer data, GClosure *closure)
 {
-       g_slice_free (AddressLineInfo, info);
+       g_slice_free (AddressLineInfo, data);
 }
 
 static void
@@ -972,7 +971,7 @@ cell_editing_started (GtkCellRenderer *cell,
        g_signal_connect_data (G_OBJECT (editable), "changed",
                               (GCallback) cell_changed_cb,
                               info,
-                              (GClosureNotify) address_line_info_destroy, 0);
+                              address_line_info_destroy, 0);
 
        /* Set up key pressed handler - need to handle Tab key */
        g_signal_connect (G_OBJECT (editable), "key-press-event",
@@ -1303,7 +1302,7 @@ ui_to_setting (CEPageIP4 *self, GError **error)
        model = gtk_tree_view_get_model (priv->addr_list);
        iter_valid = gtk_tree_model_get_iter_first (model, &tree_iter);
 
-       addresses = g_ptr_array_sized_new (1);
+       addresses = g_ptr_array_new_with_free_func (free_one_addr);
        while (iter_valid) {
                char *addr = NULL, *netmask = NULL, *addr_gw = NULL;
                NMIPAddress *nm_addr;
@@ -1428,10 +1427,8 @@ ui_to_setting (CEPageIP4 *self, GError **error)
        valid = TRUE;
 
 out:
-       if (addresses) {
-               g_ptr_array_foreach (addresses, (GFunc) free_one_addr, NULL);
+       if (addresses)
                g_ptr_array_free (addresses, TRUE);
-       }
        g_free (gateway);
 
        g_strfreev (dns_servers);
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index d8c0b7c..1f45200 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -589,8 +589,7 @@ addr_delete_clicked (GtkButton *button, gpointer user_data)
        if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data))
                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 
-       g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
-       g_list_free (selected_rows);
+       g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
 
        num_rows = gtk_tree_model_iter_n_children (model, NULL);
        if (num_rows && gtk_tree_model_iter_nth_child (model, &iter, NULL, num_rows - 1)) {
@@ -902,9 +901,9 @@ key_pressed_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 }
 
 static void
-address_line_info_destroy (AddressLineInfo *info)
+address_line_info_destroy (gpointer data, GClosure *closure)
 {
-       g_slice_free (AddressLineInfo, info);
+       g_slice_free (AddressLineInfo, data);
 }
 
 static void
@@ -955,7 +954,7 @@ cell_editing_started (GtkCellRenderer *cell,
        g_signal_connect_data (G_OBJECT (editable), "changed",
                               (GCallback) cell_changed_cb,
                               info,
-                              (GClosureNotify) address_line_info_destroy, 0);
+                              address_line_info_destroy, 0);
 
        /* Set up key pressed handler - need to handle Tab key */
        g_signal_connect (G_OBJECT (editable), "key-press-event",
diff --git a/src/connection-editor/page-master.c b/src/connection-editor/page-master.c
index deafa5b..40820b3 100644
--- a/src/connection-editor/page-master.c
+++ b/src/connection-editor/page-master.c
@@ -431,9 +431,7 @@ get_selected_connection (CEPageMaster *self)
        if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data))
                gtk_tree_model_get (model, &iter, 0, &connection, -1);
 
-       /* free memory */
-       g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
-       g_list_free (selected_rows);
+       g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
 
        return connection;
 }
diff --git a/src/libnm-gtk/nm-mobile-providers.c b/src/libnm-gtk/nm-mobile-providers.c
index a6c0600..2061182 100644
--- a/src/libnm-gtk/nm-mobile-providers.c
+++ b/src/libnm-gtk/nm-mobile-providers.c
@@ -253,8 +253,7 @@ nma_mobile_provider_unref (NMAMobileProvider *provider)
                g_free (provider->name);
                g_hash_table_destroy (provider->lcl_names);
 
-               g_slist_foreach (provider->methods, (GFunc) nma_mobile_access_method_unref, NULL);
-               g_slist_free (provider->methods);
+               g_slist_free_full (provider->methods, (GDestroyNotify) nma_mobile_access_method_unref);
 
                if (provider->mcc_mnc)
                        g_ptr_array_unref (provider->mcc_mnc);
diff --git a/src/libnma/nma-mobile-providers.c b/src/libnma/nma-mobile-providers.c
index dbd5c72..8e3f9be 100644
--- a/src/libnma/nma-mobile-providers.c
+++ b/src/libnma/nma-mobile-providers.c
@@ -256,8 +256,7 @@ nma_mobile_provider_unref (NMAMobileProvider *provider)
                g_free (provider->name);
                g_hash_table_destroy (provider->lcl_names);
 
-               g_slist_foreach (provider->methods, (GFunc) nma_mobile_access_method_unref, NULL);
-               g_slist_free (provider->methods);
+               g_slist_free_full (provider->methods, (GDestroyNotify) nma_mobile_access_method_unref);
 
                if (provider->mcc_mnc)
                        g_ptr_array_unref (provider->mcc_mnc);


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