[PATCH 2/4] plugins: remove explicit GDestroyNotify cast on g_free / g_object_unref
Aleksander Morgado
aleksander at aleksander.es
Wed Mar 29 08:32:24 UTC 2017
On Wed, Mar 29, 2017 at 3:35 AM, Ben Chan <benchan at chromium.org> wrote:
> 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.
> ---
Pushed to git master, thanks!
> plugins/altair/mm-broadband-modem-altair-lte.c | 4 ++--
> plugins/cinterion/mm-broadband-modem-cinterion.c | 6 +++---
> plugins/huawei/mm-broadband-modem-huawei.c | 14 +++++++-------
> plugins/icera/mm-broadband-bearer-icera.c | 2 +-
> plugins/icera/mm-broadband-modem-icera.c | 6 +++---
> plugins/iridium/mm-broadband-modem-iridium.c | 2 +-
> plugins/longcheer/mm-broadband-modem-longcheer.c | 2 +-
> plugins/mbm/mm-broadband-bearer-mbm.c | 4 ++--
> plugins/mbm/mm-broadband-modem-mbm.c | 2 +-
> plugins/mtk/mm-broadband-modem-mtk.c | 2 +-
> plugins/novatel/mm-broadband-modem-novatel-lte.c | 2 +-
> plugins/option/mm-broadband-bearer-hso.c | 4 ++--
> plugins/option/mm-broadband-modem-hso.c | 6 +++---
> plugins/sierra/mm-broadband-bearer-sierra.c | 2 +-
> plugins/sierra/mm-broadband-modem-sierra-icera.c | 2 +-
> plugins/sierra/mm-broadband-modem-sierra.c | 2 +-
> plugins/telit/mm-broadband-modem-telit.c | 2 +-
> plugins/tests/test-fixture.c | 2 +-
> plugins/ublox/mm-broadband-bearer-ublox.c | 4 ++--
> plugins/ublox/mm-broadband-modem-ublox.c | 2 +-
> plugins/zte/mm-broadband-modem-zte.c | 2 +-
> 21 files changed, 37 insertions(+), 37 deletions(-)
>
> diff --git a/plugins/altair/mm-broadband-modem-altair-lte.c b/plugins/altair/mm-broadband-modem-altair-lte.c
> index 1155a7a1..572a1bfd 100644
> --- a/plugins/altair/mm-broadband-modem-altair-lte.c
> +++ b/plugins/altair/mm-broadband-modem-altair-lte.c
> @@ -128,7 +128,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);
> }
> @@ -198,7 +198,7 @@ load_unlock_retries_ready (MMBaseModem *self,
> mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PUK2, puk2);
> g_simple_async_result_set_op_res_gpointer (operation_result,
> retries,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> } else {
> g_simple_async_result_set_error (operation_result,
> MM_CORE_ERROR,
> diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c
> index ae092a0e..4a4e18bf 100644
> --- a/plugins/cinterion/mm-broadband-modem-cinterion.c
> +++ b/plugins/cinterion/mm-broadband-modem-cinterion.c
> @@ -1438,7 +1438,7 @@ load_unlock_retries_context_step (LoadUnlockRetriesContext *ctx)
> if (ctx->i == G_N_ELEMENTS (unlock_retries_map)) {
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> g_object_ref (ctx->retries),
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> load_unlock_retries_context_complete_and_free (ctx);
> return;
> }
> @@ -1643,7 +1643,7 @@ broadband_bearer_cinterion_new_ready (GObject *source,
> if (!bearer)
> g_simple_async_result_take_error (ctx->result, error);
> else
> - g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, (GDestroyNotify)g_object_unref);
> + g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, g_object_unref);
> create_bearer_context_complete_and_free (ctx);
> }
>
> @@ -1659,7 +1659,7 @@ broadband_bearer_new_ready (GObject *source,
> if (!bearer)
> g_simple_async_result_take_error (ctx->result, error);
> else
> - g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, (GDestroyNotify)g_object_unref);
> + g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, g_object_unref);
> create_bearer_context_complete_and_free (ctx);
> }
>
> diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
> index 74e680b4..49c77e9a 100644
> --- a/plugins/huawei/mm-broadband-modem-huawei.c
> +++ b/plugins/huawei/mm-broadband-modem-huawei.c
> @@ -1933,7 +1933,7 @@ set_3gpp_unsolicited_events_handlers (MMBroadbandModemHuawei *self,
> NULL);
> }
>
> - g_list_free_full (ports, (GDestroyNotify)g_object_unref);
> + g_list_free_full (ports, g_object_unref);
> }
>
> static gboolean
> @@ -2266,7 +2266,7 @@ broadband_bearer_huawei_new_ready (GObject *source,
> if (!bearer)
> g_simple_async_result_take_error (ctx->result, error);
> else
> - g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, (GDestroyNotify)g_object_unref);
> + g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, g_object_unref);
> create_bearer_context_complete_and_free (ctx);
> }
>
> @@ -2282,7 +2282,7 @@ broadband_bearer_new_ready (GObject *source,
> if (!bearer)
> g_simple_async_result_take_error (ctx->result, error);
> else
> - g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, (GDestroyNotify)g_object_unref);
> + g_simple_async_result_set_op_res_gpointer (ctx->result, bearer, g_object_unref);
> create_bearer_context_complete_and_free (ctx);
> }
>
> @@ -2667,7 +2667,7 @@ set_cdma_unsolicited_events_handlers (MMBroadbandModemHuawei *self,
> NULL);
> }
>
> - g_list_free_full (ports, (GDestroyNotify)g_object_unref);
> + g_list_free_full (ports, g_object_unref);
> }
>
> static gboolean
> @@ -3158,7 +3158,7 @@ set_voice_unsolicited_events_handlers (MMBroadbandModemHuawei *self,
> NULL, NULL, NULL);
> }
>
> - g_list_free_full (ports, (GDestroyNotify)g_object_unref);
> + g_list_free_full (ports, g_object_unref);
> }
>
> static gboolean
> @@ -3486,7 +3486,7 @@ enable_disable_unsolicited_rfswitch_event_handler (MMBroadbandModemHuawei *self,
> enable);
> }
>
> - g_list_free_full (ports, (GDestroyNotify)g_object_unref);
> + g_list_free_full (ports, g_object_unref);
> }
>
> static void
> @@ -4333,7 +4333,7 @@ set_ignored_unsolicited_events_handlers (MMBroadbandModemHuawei *self)
> NULL, NULL, NULL);
> }
>
> - g_list_free_full (ports, (GDestroyNotify)g_object_unref);
> + g_list_free_full (ports, g_object_unref);
> }
>
> static void
> diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c
> index c08acc4f..3b3a49a0 100644
> --- a/plugins/icera/mm-broadband-bearer-icera.c
> +++ b/plugins/icera/mm-broadband-bearer-icera.c
> @@ -660,7 +660,7 @@ report_connect_status (MMBroadbandBearerIcera *self,
>
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> g_object_ref (ctx->data),
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> dial_3gpp_context_complete_and_free (ctx);
> return;
> }
> diff --git a/plugins/icera/mm-broadband-modem-icera.c b/plugins/icera/mm-broadband-modem-icera.c
> index 730a79fb..562b9e0d 100644
> --- a/plugins/icera/mm-broadband-modem-icera.c
> +++ b/plugins/icera/mm-broadband-modem-icera.c
> @@ -883,7 +883,7 @@ broadband_bearer_icera_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);
> }
> @@ -902,7 +902,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);
> }
> @@ -1090,7 +1090,7 @@ load_unlock_retries_ready (MMBaseModem *self,
> mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PUK2, puk2);
> g_simple_async_result_set_op_res_gpointer (operation_result,
> retries,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> } else {
> g_simple_async_result_set_error (operation_result,
> MM_CORE_ERROR,
> diff --git a/plugins/iridium/mm-broadband-modem-iridium.c b/plugins/iridium/mm-broadband-modem-iridium.c
> index c64e8d2d..0e2d670e 100644
> --- a/plugins/iridium/mm-broadband-modem-iridium.c
> +++ b/plugins/iridium/mm-broadband-modem-iridium.c
> @@ -311,7 +311,7 @@ create_bearer (MMIfaceModem *self,
> properties);
> g_simple_async_result_set_op_res_gpointer (result,
> bearer,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> g_simple_async_result_complete_in_idle (result);
> g_object_unref (result);
> }
> diff --git a/plugins/longcheer/mm-broadband-modem-longcheer.c b/plugins/longcheer/mm-broadband-modem-longcheer.c
> index 27da1868..3bb19190 100644
> --- a/plugins/longcheer/mm-broadband-modem-longcheer.c
> +++ b/plugins/longcheer/mm-broadband-modem-longcheer.c
> @@ -363,7 +363,7 @@ load_unlock_retries_ready (MMBaseModem *self,
> mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PUK2, puk2);
> g_simple_async_result_set_op_res_gpointer (operation_result,
> retries,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> } else {
> g_simple_async_result_set_error (operation_result,
> MM_CORE_ERROR,
> diff --git a/plugins/mbm/mm-broadband-bearer-mbm.c b/plugins/mbm/mm-broadband-bearer-mbm.c
> index 0fea7190..fa1a4902 100644
> --- a/plugins/mbm/mm-broadband-bearer-mbm.c
> +++ b/plugins/mbm/mm-broadband-bearer-mbm.c
> @@ -178,7 +178,7 @@ handle_e2nap_connect_status (Dial3gppContext *ctx)
> mm_dbg ("Connected status indicated already by an unsolicited message");
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> g_object_ref (ctx->data),
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> dial_3gpp_context_complete_and_free (ctx);
> return TRUE;
> case MM_BEARER_CONNECTION_STATUS_DISCONNECTED:
> @@ -220,7 +220,7 @@ connect_poll_ready (MMBaseModem *modem,
> /* Success! Connected... */
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> g_object_ref (ctx->data),
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> dial_3gpp_context_complete_and_free (ctx);
> return;
> }
> diff --git a/plugins/mbm/mm-broadband-modem-mbm.c b/plugins/mbm/mm-broadband-modem-mbm.c
> index c015c669..dcc91699 100644
> --- a/plugins/mbm/mm-broadband-modem-mbm.c
> +++ b/plugins/mbm/mm-broadband-modem-mbm.c
> @@ -111,7 +111,7 @@ broadband_bearer_mbm_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);
> }
> diff --git a/plugins/mtk/mm-broadband-modem-mtk.c b/plugins/mtk/mm-broadband-modem-mtk.c
> index f652a65b..181497bb 100644
> --- a/plugins/mtk/mm-broadband-modem-mtk.c
> +++ b/plugins/mtk/mm-broadband-modem-mtk.c
> @@ -125,7 +125,7 @@ load_unlock_retries_ready (MMBaseModem *self,
>
> g_simple_async_result_set_op_res_gpointer (operation_result,
> retries,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> }
>
> if (match_info)
> diff --git a/plugins/novatel/mm-broadband-modem-novatel-lte.c b/plugins/novatel/mm-broadband-modem-novatel-lte.c
> index e5be522d..94030a97 100644
> --- a/plugins/novatel/mm-broadband-modem-novatel-lte.c
> +++ b/plugins/novatel/mm-broadband-modem-novatel-lte.c
> @@ -98,7 +98,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);
> }
> diff --git a/plugins/option/mm-broadband-bearer-hso.c b/plugins/option/mm-broadband-bearer-hso.c
> index 746f96e5..953277aa 100644
> --- a/plugins/option/mm-broadband-bearer-hso.c
> +++ b/plugins/option/mm-broadband-bearer-hso.c
> @@ -173,7 +173,7 @@ ip_config_ready (MMBaseModem *modem,
>
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> ip_config,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> }
>
> get_ip_config_context_complete_and_free (ctx);
> @@ -378,7 +378,7 @@ report_connection_status (MMBaseBearer *bearer,
>
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> g_object_ref (ctx->data),
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> dial_3gpp_context_complete_and_free (ctx);
> return;
> }
> diff --git a/plugins/option/mm-broadband-modem-hso.c b/plugins/option/mm-broadband-modem-hso.c
> index d2d46891..e48bcbab 100644
> --- a/plugins/option/mm-broadband-modem-hso.c
> +++ b/plugins/option/mm-broadband-modem-hso.c
> @@ -86,7 +86,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);
> }
> @@ -105,7 +105,7 @@ broadband_bearer_hso_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);
> }
> @@ -182,7 +182,7 @@ load_unlock_retries_ready (MMBaseModem *self,
> mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PUK, puk1);
> g_simple_async_result_set_op_res_gpointer (operation_result,
> retries,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> } else {
> g_simple_async_result_set_error (operation_result,
> MM_CORE_ERROR,
> diff --git a/plugins/sierra/mm-broadband-bearer-sierra.c b/plugins/sierra/mm-broadband-bearer-sierra.c
> index 1f590a37..6f999bf2 100644
> --- a/plugins/sierra/mm-broadband-bearer-sierra.c
> +++ b/plugins/sierra/mm-broadband-bearer-sierra.c
> @@ -311,7 +311,7 @@ dial_3gpp_context_step (Dial3gppContext *ctx)
> case DIAL_3GPP_STEP_LAST:
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> g_object_ref (ctx->data),
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> dial_3gpp_context_complete_and_free (ctx);
> return;
> }
> diff --git a/plugins/sierra/mm-broadband-modem-sierra-icera.c b/plugins/sierra/mm-broadband-modem-sierra-icera.c
> index bd01cc4d..5489ddb8 100644
> --- a/plugins/sierra/mm-broadband-modem-sierra-icera.c
> +++ b/plugins/sierra/mm-broadband-modem-sierra-icera.c
> @@ -66,7 +66,7 @@ broadband_bearer_sierra_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);
> }
> diff --git a/plugins/sierra/mm-broadband-modem-sierra.c b/plugins/sierra/mm-broadband-modem-sierra.c
> index 8616f1c9..5d3d5935 100644
> --- a/plugins/sierra/mm-broadband-modem-sierra.c
> +++ b/plugins/sierra/mm-broadband-modem-sierra.c
> @@ -1115,7 +1115,7 @@ broadband_bearer_sierra_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);
> }
> diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c
> index 6ef340f1..8b873106 100644
> --- a/plugins/telit/mm-broadband-modem-telit.c
> +++ b/plugins/telit/mm-broadband-modem-telit.c
> @@ -665,7 +665,7 @@ load_unlock_retries_step (LoadUnlockRetriesContext *ctx)
> } else {
> g_simple_async_result_set_op_res_gpointer (ctx->result,
> g_object_ref (ctx->retries),
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> }
>
> load_unlock_retries_context_complete_and_free (ctx);
> diff --git a/plugins/tests/test-fixture.c b/plugins/tests/test-fixture.c
> index 3013fe04..d496fee7 100644
> --- a/plugins/tests/test-fixture.c
> +++ b/plugins/tests/test-fixture.c
> @@ -135,7 +135,7 @@ common_get_modem (TestFixture *fixture,
> ready = TRUE;
> }
>
> - g_list_free_full (modems, (GDestroyNotify) g_object_unref);
> + g_list_free_full (modems, g_object_unref);
> g_object_unref (manager);
>
> if (ready)
> diff --git a/plugins/ublox/mm-broadband-bearer-ublox.c b/plugins/ublox/mm-broadband-bearer-ublox.c
> index e3ba90d0..62f3d7ea 100644
> --- a/plugins/ublox/mm-broadband-bearer-ublox.c
> +++ b/plugins/ublox/mm-broadband-bearer-ublox.c
> @@ -340,7 +340,7 @@ cgact_activate_ready (MMBaseModem *modem,
> if (!response)
> g_task_return_error (task, error);
> else
> - g_task_return_pointer (task, g_object_ref (ctx->data), (GDestroyNotify) g_object_unref);
> + g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref);
> g_object_unref (task);
> }
>
> @@ -595,7 +595,7 @@ ugcntrd_ready (MMBaseModem *modem,
> result = g_new (StatsResult, 1);
> result->bytes_rx = rx_bytes;
> result->bytes_tx = tx_bytes;
> - g_task_return_pointer (task, result, (GDestroyNotify) g_free);
> + g_task_return_pointer (task, result, g_free);
> }
>
> g_object_unref (task);
> diff --git a/plugins/ublox/mm-broadband-modem-ublox.c b/plugins/ublox/mm-broadband-modem-ublox.c
> index be2e6e22..64dd9dec 100644
> --- a/plugins/ublox/mm-broadband-modem-ublox.c
> +++ b/plugins/ublox/mm-broadband-modem-ublox.c
> @@ -871,7 +871,7 @@ create_bearer_step (GTask *task)
>
> case CREATE_BEARER_STEP_LAST:
> g_assert (ctx->bearer);
> - g_task_return_pointer (task, g_object_ref (ctx->bearer), (GDestroyNotify) g_object_unref);
> + g_task_return_pointer (task, g_object_ref (ctx->bearer), g_object_unref);
> g_object_unref (task);
> return;
> }
> diff --git a/plugins/zte/mm-broadband-modem-zte.c b/plugins/zte/mm-broadband-modem-zte.c
> index 3ea59b59..3d10e389 100644
> --- a/plugins/zte/mm-broadband-modem-zte.c
> +++ b/plugins/zte/mm-broadband-modem-zte.c
> @@ -88,7 +88,7 @@ load_unlock_retries_ready (MMBaseModem *self,
> mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PUK, puk1);
> g_simple_async_result_set_op_res_gpointer (operation_result,
> retries,
> - (GDestroyNotify)g_object_unref);
> + g_object_unref);
> } else {
> g_simple_async_result_set_error (operation_result,
> MM_CORE_ERROR,
> --
> 2.12.2.564.g063fe858b8-goog
>
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list