[PATCH 1/4] core: remove explicit GDestroyNotify cast on g_free / g_object_unref

Ben Chan benchan at chromium.org
Wed Mar 29 01:35:54 UTC 2017


g_free and g_object_unref are in form of  `void (*)(gpointer)`, which
matches the GDestroyNotify signature. An explicit GDestroyNotify cast on
g_free and g_object_unref is thus not needed.
---
 src/kerneldevice/mm-kernel-device-generic-rules.c |  2 +-
 src/mm-bearer-list.c                              |  4 ++--
 src/mm-broadband-bearer.c                         |  2 +-
 src/mm-broadband-modem-mbim.c                     |  2 +-
 src/mm-broadband-modem-qmi.c                      | 18 +++++++++---------
 src/mm-broadband-modem.c                          | 10 +++++-----
 src/mm-call-list.c                                |  2 +-
 src/mm-device.c                                   |  4 ++--
 src/mm-iface-modem-firmware.c                     |  2 +-
 src/mm-iface-modem-simple.c                       |  2 +-
 src/mm-iface-modem-time.c                         |  2 +-
 src/mm-plugin-manager.c                           | 10 +++++-----
 src/mm-port-probe.c                               |  2 +-
 src/mm-port-qmi.c                                 |  4 ++--
 src/mm-sim-mbim.c                                 |  4 ++--
 src/mm-sim-qmi.c                                  | 10 +++++-----
 src/mm-sms-list.c                                 |  2 +-
 17 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/kerneldevice/mm-kernel-device-generic-rules.c b/src/kerneldevice/mm-kernel-device-generic-rules.c
index 608ca9f1..d8a2ab13 100644
--- a/src/kerneldevice/mm-kernel-device-generic-rules.c
+++ b/src/kerneldevice/mm-kernel-device-generic-rules.c
@@ -434,7 +434,7 @@ mm_kernel_device_generic_rules_load (const gchar  *rules_dir,
 
 out:
     if (rule_files)
-        g_list_free_full (rule_files, (GDestroyNotify) g_free);
+        g_list_free_full (rule_files, g_free);
 
     if (inner_error) {
         g_propagate_error (error, inner_error);
diff --git a/src/mm-bearer-list.c b/src/mm-bearer-list.c
index 205193ae..e021e34a 100644
--- a/src/mm-bearer-list.c
+++ b/src/mm-bearer-list.c
@@ -189,7 +189,7 @@ disconnect_all_context_complete_and_free (DisconnectAllContext *ctx)
     g_object_unref (ctx->result);
     if (ctx->current)
         g_object_unref (ctx->current);
-    g_list_free_full (ctx->pending, (GDestroyNotify) g_object_unref);
+    g_list_free_full (ctx->pending, g_object_unref);
     g_free (ctx);
 }
 
@@ -339,7 +339,7 @@ dispose (GObject *object)
     MMBearerList *self = MM_BEARER_LIST (object);
 
     if (self->priv->bearers) {
-        g_list_free_full (self->priv->bearers, (GDestroyNotify) g_object_unref);
+        g_list_free_full (self->priv->bearers, g_object_unref);
         self->priv->bearers = NULL;
     }
 
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 9491f5a8..0565eee3 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -583,7 +583,7 @@ atd_ready (MMBaseModem *modem,
 
     g_simple_async_result_set_op_res_gpointer (ctx->result,
                                                g_object_ref (ctx->dial_port),
-                                               (GDestroyNotify)g_object_unref);
+                                               g_object_unref);
     dial_3gpp_context_complete_and_free (ctx);
 }
 
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index 7188d2f8..c5286a3f 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -387,7 +387,7 @@ modem_load_device_identifier (MMIfaceModem *self,
     device_identifier = mm_broadband_modem_create_device_identifier (MM_BROADBAND_MODEM (self), "", "");
     g_simple_async_result_set_op_res_gpointer (result,
                                                device_identifier,
-                                               (GDestroyNotify)g_free);
+                                               g_free);
     g_simple_async_result_complete_in_idle (result);
     g_object_unref (result);
 }
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 280f98fb..bd8ff3ff 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -967,7 +967,7 @@ dms_get_manufacturer_ready (QmiClientDms *client,
         qmi_message_dms_get_manufacturer_output_get_manufacturer (output, &str, NULL);
         g_simple_async_result_set_op_res_gpointer (simple,
                                                    g_strdup (str),
-                                                   (GDestroyNotify)g_free);
+                                                   g_free);
     }
 
     if (output)
@@ -1043,7 +1043,7 @@ dms_get_model_ready (QmiClientDms *client,
         qmi_message_dms_get_model_output_get_model (output, &str, NULL);
         g_simple_async_result_set_op_res_gpointer (simple,
                                                    g_strdup (str),
-                                                   (GDestroyNotify)g_free);
+                                                   g_free);
     }
 
     if (output)
@@ -1119,7 +1119,7 @@ dms_get_revision_ready (QmiClientDms *client,
         qmi_message_dms_get_revision_output_get_revision (output, &str, NULL);
         g_simple_async_result_set_op_res_gpointer (simple,
                                                    g_strdup (str),
-                                                   (GDestroyNotify)g_free);
+                                                   g_free);
     }
 
     if (output)
@@ -1262,7 +1262,7 @@ dms_get_ids_ready (QmiClientDms *client,
 
     g_simple_async_result_set_op_res_gpointer (ctx->result,
                                                g_strdup (str),
-                                               (GDestroyNotify)g_free);
+                                               g_free);
 
     qmi_message_dms_get_ids_output_unref (output);
     load_equipment_identifier_context_complete_and_free (ctx);
@@ -1335,7 +1335,7 @@ modem_load_device_identifier (MMIfaceModem *self,
     device_identifier = mm_broadband_modem_create_device_identifier (MM_BROADBAND_MODEM (self), "", "");
     g_simple_async_result_set_op_res_gpointer (result,
                                                device_identifier,
-                                               (GDestroyNotify)g_free);
+                                               g_free);
     g_simple_async_result_complete_in_idle (result);
     g_object_unref (result);
 }
@@ -1380,7 +1380,7 @@ dms_get_msisdn_ready (QmiClientDms *client,
         qmi_message_dms_get_msisdn_output_get_msisdn (output, &str, NULL);
         g_simple_async_result_set_op_res_gpointer (simple,
                                                    g_strdup (str),
-                                                   (GDestroyNotify)g_free);
+                                                   g_free);
     }
 
     if (output)
@@ -3538,7 +3538,7 @@ get_technology_preference_ready (QmiClientNas *client,
     g_simple_async_result_set_op_res_gpointer (
         ctx->result,
         result,
-        (GDestroyNotify)g_free);
+        g_free);
     load_current_modes_context_complete_and_free (ctx);
 }
 
@@ -3606,7 +3606,7 @@ current_modes_get_system_selection_preference_ready (QmiClientNas *client,
     g_simple_async_result_set_op_res_gpointer (
         ctx->result,
         result,
-        (GDestroyNotify)g_free);
+        g_free);
     load_current_modes_context_complete_and_free (ctx);
 }
 
@@ -11372,7 +11372,7 @@ dispose (GObject *object)
 {
     MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (object);
 
-    g_list_free_full (self->priv->firmware_list, (GDestroyNotify)g_object_unref);
+    g_list_free_full (self->priv->firmware_list, g_object_unref);
     self->priv->firmware_list = NULL;
 
     g_clear_object (&self->priv->current_firmware);
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 81943188..39a9bf83 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -280,7 +280,7 @@ broadband_bearer_new_ready (GObject *source,
     else
         g_simple_async_result_set_op_res_gpointer (simple,
                                                    bearer,
-                                                   (GDestroyNotify)g_object_unref);
+                                                   g_object_unref);
     g_simple_async_result_complete (simple);
     g_object_unref (simple);
 }
@@ -7024,7 +7024,7 @@ hdr_subsys_state_info_ready (MMPortSerialQcdm *port,
     qcdm_result_get_u8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ALMP_STATE, &results->almp_state);
     qcdm_result_unref (result);
 
-    g_simple_async_result_set_op_res_gpointer (ctx->result, results, (GDestroyNotify)g_free);
+    g_simple_async_result_set_op_res_gpointer (ctx->result, results, g_free);
     hdr_state_context_complete_and_free (ctx);
 }
 
@@ -7152,7 +7152,7 @@ cm_subsys_state_info_ready (MMPortSerialQcdm *port,
     qcdm_result_get_u32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_SYSTEM_MODE, &results->system_mode);
     qcdm_result_unref (result);
 
-    g_simple_async_result_set_op_res_gpointer (ctx->result, results, (GDestroyNotify)g_free);
+    g_simple_async_result_set_op_res_gpointer (ctx->result, results, g_free);
     call_manager_state_context_complete_and_free (ctx);
 }
 
@@ -7381,7 +7381,7 @@ css_query_ready (MMIfaceModemCdma *self,
     /* No means to get NID with AT commands right now */
     results->nid = MM_MODEM_CDMA_NID_UNKNOWN;
 
-    g_simple_async_result_set_op_res_gpointer (ctx->result, results, (GDestroyNotify)g_free);
+    g_simple_async_result_set_op_res_gpointer (ctx->result, results, g_free);
     cdma1x_serving_system_context_complete_and_free (ctx);
 }
 
@@ -7445,7 +7445,7 @@ qcdm_cdma_status_ready (MMPortSerialQcdm *port,
         results->class = 0;
     }
 
-    g_simple_async_result_set_op_res_gpointer (ctx->result, results, (GDestroyNotify)g_free);
+    g_simple_async_result_set_op_res_gpointer (ctx->result, results, g_free);
     cdma1x_serving_system_context_complete_and_free (ctx);
 }
 
diff --git a/src/mm-call-list.c b/src/mm-call-list.c
index 056e2932..e829ae7b 100644
--- a/src/mm-call-list.c
+++ b/src/mm-call-list.c
@@ -394,7 +394,7 @@ dispose (GObject *object)
     MMCallList *self = MM_CALL_LIST (object);
 
     g_clear_object (&self->priv->modem);
-    g_list_free_full (self->priv->list, (GDestroyNotify)g_object_unref);
+    g_list_free_full (self->priv->list, g_object_unref);
 
     G_OBJECT_CLASS (mm_call_list_parent_class)->dispose (object);
 }
diff --git a/src/mm-device.c b/src/mm-device.c
index 6c856289..aa7a27e0 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -646,8 +646,8 @@ dispose (GObject *object)
     MMDevice *self = MM_DEVICE (object);
 
     g_clear_object (&(self->priv->plugin));
-    g_list_free_full (self->priv->port_probes, (GDestroyNotify)g_object_unref);
-    g_list_free_full (self->priv->ignored_port_probes, (GDestroyNotify)g_object_unref);
+    g_list_free_full (self->priv->port_probes, g_object_unref);
+    g_list_free_full (self->priv->ignored_port_probes, g_object_unref);
 
     clear_modem (self);
 
diff --git a/src/mm-iface-modem-firmware.c b/src/mm-iface-modem-firmware.c
index cf4e1750..0cbdd44e 100644
--- a/src/mm-iface-modem-firmware.c
+++ b/src/mm-iface-modem-firmware.c
@@ -50,7 +50,7 @@ static void
 handle_list_context_free (HandleListContext *ctx)
 {
     if (ctx->list)
-        g_list_free_full (ctx->list, (GDestroyNotify)g_object_unref);
+        g_list_free_full (ctx->list, g_object_unref);
     if (ctx->current)
         g_object_unref (ctx->current);
     g_object_unref (ctx->skeleton);
diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c
index 6dab1d7d..572c4f92 100644
--- a/src/mm-iface-modem-simple.c
+++ b/src/mm-iface-modem-simple.c
@@ -760,7 +760,7 @@ disconnection_context_free (DisconnectionContext *ctx)
     g_free (ctx->bearer_path);
     if (ctx->current)
         g_object_unref (ctx->current);
-    g_list_free_full (ctx->bearers, (GDestroyNotify) g_object_unref);
+    g_list_free_full (ctx->bearers, g_object_unref);
     g_free (ctx);
 }
 
diff --git a/src/mm-iface-modem-time.c b/src/mm-iface-modem-time.c
index 91be855e..85588d3f 100644
--- a/src/mm-iface-modem-time.c
+++ b/src/mm-iface-modem-time.c
@@ -690,7 +690,7 @@ interface_enabling_step (EnablingContext *ctx)
         g_object_set_qdata_full (G_OBJECT (ctx->self),
                                  network_timezone_cancellable_quark,
                                  cancellable,
-                                 (GDestroyNotify)g_object_unref);
+                                 g_object_unref);
 
         update_network_timezone (ctx->self,
                                  cancellable,
diff --git a/src/mm-plugin-manager.c b/src/mm-plugin-manager.c
index 058c5be0..9239b7f7 100644
--- a/src/mm-plugin-manager.c
+++ b/src/mm-plugin-manager.c
@@ -87,7 +87,7 @@ plugin_manager_build_plugins_list (MMPluginManager *self,
         case MM_PLUGIN_SUPPORTS_HINT_SUPPORTED:
             /* Really supported, clean existing list and add it alone */
             if (list) {
-                g_list_free_full (list, (GDestroyNotify) g_object_unref);
+                g_list_free_full (list, g_object_unref);
                 list = NULL;
             }
             list = g_list_prepend (list, g_object_ref (l->data));
@@ -224,7 +224,7 @@ port_context_unref (PortContext *port_context)
         if (port_context->suggested_plugin)
             g_object_unref (port_context->suggested_plugin);
         if (port_context->plugins)
-            g_list_free_full (port_context->plugins, (GDestroyNotify) g_object_unref);
+            g_list_free_full (port_context->plugins, g_object_unref);
         if (port_context->cancellable)
             g_object_unref (port_context->cancellable);
         g_free (port_context->name);
@@ -837,7 +837,7 @@ device_context_complete (DeviceContext *device_context)
         g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
                                  "not supported by any plugin");
     else
-        g_task_return_pointer (task, g_object_ref (device_context->best_plugin), (GDestroyNotify) g_object_unref);
+        g_task_return_pointer (task, g_object_ref (device_context->best_plugin), g_object_unref);
     g_object_unref (task);
 }
 
@@ -1401,7 +1401,7 @@ device_context_run_ready (MMPluginManager    *self,
     if (!best_plugin)
         g_task_return_error (common->task, error);
     else
-        g_task_return_pointer (common->task, best_plugin, (GDestroyNotify) g_object_unref);
+        g_task_return_pointer (common->task, best_plugin, g_object_unref);
     common_async_context_free (common);
 }
 
@@ -1690,7 +1690,7 @@ dispose (GObject *object)
 
     /* Cleanup list of plugins */
     if (self->priv->plugins) {
-        g_list_free_full (self->priv->plugins, (GDestroyNotify)g_object_unref);
+        g_list_free_full (self->priv->plugins, g_object_unref);
         self->priv->plugins = NULL;
     }
     g_clear_object (&self->priv->generic);
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index c6c5897f..cfe0763c 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -1406,7 +1406,7 @@ mm_port_probe_run (MMPortProbe                *self,
             ctx->at_probing_cancellable_linked = g_cancellable_connect (cancellable,
                                                                         (GCallback) at_cancellable_cancel,
                                                                         g_object_ref (ctx->at_probing_cancellable),
-                                                                        (GDestroyNotify) g_object_unref);
+                                                                        g_object_unref);
         ctx->source_id = g_idle_add ((GSourceFunc) serial_open_at, self);
         return;
     }
diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c
index 3252cab4..eb163006 100644
--- a/src/mm-port-qmi.c
+++ b/src/mm-port-qmi.c
@@ -572,7 +572,7 @@ mm_port_qmi_close (MMPortQmi *self)
                                    3, NULL, NULL, NULL);
         g_clear_object (&info->client);
     }
-    g_list_free_full (self->priv->services, (GDestroyNotify)g_free);
+    g_list_free_full (self->priv->services, g_free);
     self->priv->services = NULL;
 
     /* Close and release the device */
@@ -616,7 +616,7 @@ dispose (GObject *object)
         if (info->client)
             g_object_unref (info->client);
     }
-    g_list_free_full (self->priv->services, (GDestroyNotify)g_free);
+    g_list_free_full (self->priv->services, g_free);
     self->priv->services = NULL;
 
     /* Clear device object */
diff --git a/src/mm-sim-mbim.c b/src/mm-sim-mbim.c
index 08acf389..3d99c99d 100644
--- a/src/mm-sim-mbim.c
+++ b/src/mm-sim-mbim.c
@@ -97,7 +97,7 @@ simid_subscriber_ready_state_ready (MbimDevice *device,
             NULL, /* telephone_numbers_count */
             NULL, /* telephone_numbers */
             &error))
-        g_simple_async_result_set_op_res_gpointer (simple, sim_iccid, (GDestroyNotify)g_free);
+        g_simple_async_result_set_op_res_gpointer (simple, sim_iccid, g_free);
     else
         g_simple_async_result_take_error (simple, error);
 
@@ -165,7 +165,7 @@ imsi_subscriber_ready_state_ready (MbimDevice *device,
             NULL, /* telephone_numbers_count */
             NULL, /* telephone_numbers */
             &error))
-        g_simple_async_result_set_op_res_gpointer (simple, subscriber_id, (GDestroyNotify)g_free);
+        g_simple_async_result_set_op_res_gpointer (simple, subscriber_id, g_free);
     else
         g_simple_async_result_take_error (simple, error);
 
diff --git a/src/mm-sim-qmi.c b/src/mm-sim-qmi.c
index d8e1c82d..2ae15147 100644
--- a/src/mm-sim-qmi.c
+++ b/src/mm-sim-qmi.c
@@ -118,7 +118,7 @@ dms_uim_get_iccid_ready (QmiClientDms *client,
         const gchar *str = NULL;
 
         qmi_message_dms_uim_get_iccid_output_get_iccid (output, &str, NULL);
-        g_task_return_pointer (task, g_strdup (str), (GDestroyNotify) g_free);
+        g_task_return_pointer (task, g_strdup (str), g_free);
     }
 
     if (output)
@@ -180,7 +180,7 @@ dms_uim_get_imsi_ready (QmiClientDms *client,
         const gchar *str = NULL;
 
         qmi_message_dms_uim_get_imsi_output_get_imsi (output, &str, NULL);
-        g_task_return_pointer (task, g_strdup (str), (GDestroyNotify) g_free);
+        g_task_return_pointer (task, g_strdup (str), g_free);
     }
 
     if (output)
@@ -304,7 +304,7 @@ load_operator_identifier_ready (QmiClientNas *client,
         g_string_append_printf (aux, "%.3" G_GUINT16_FORMAT, mnc);
     else
         g_string_append_printf (aux, "%.2" G_GUINT16_FORMAT, mnc);
-    g_task_return_pointer (task, g_string_free (aux, FALSE), (GDestroyNotify) g_free);
+    g_task_return_pointer (task, g_string_free (aux, FALSE), g_free);
     g_object_unref (task);
 }
 
@@ -353,7 +353,7 @@ load_operator_name_ready (QmiClientNas *client,
     if (!get_home_network (client, res, NULL, NULL, NULL, &operator_name, &error))
         g_task_return_error (task, error);
     else
-        g_task_return_pointer (task, operator_name, (GDestroyNotify) g_free);
+        g_task_return_pointer (task, operator_name, g_free);
     g_object_unref (task);
 }
 
@@ -543,7 +543,7 @@ send_pin (MMBaseSim           *_self,
     self = MM_SIM_QMI (_self);
     task = g_task_new (self, NULL, callback, user_data);
 
-    g_task_set_task_data (task, g_strdup (pin), (GDestroyNotify) g_free);
+    g_task_set_task_data (task, g_strdup (pin), g_free);
 
     mm_dbg ("Verifying PIN...");
     if (!self->priv->dms_uim_deprecated)
diff --git a/src/mm-sms-list.c b/src/mm-sms-list.c
index e98bd8c2..03daaf24 100644
--- a/src/mm-sms-list.c
+++ b/src/mm-sms-list.c
@@ -450,7 +450,7 @@ dispose (GObject *object)
     MMSmsList *self = MM_SMS_LIST (object);
 
     g_clear_object (&self->priv->modem);
-    g_list_free_full (self->priv->list, (GDestroyNotify)g_object_unref);
+    g_list_free_full (self->priv->list, g_object_unref);
 
     G_OBJECT_CLASS (mm_sms_list_parent_class)->dispose (object);
 }
-- 
2.12.2.564.g063fe858b8-goog



More information about the ModemManager-devel mailing list