[PATCH 1/5] core: use g_list_copy_deep for deep copying a GList
Aleksander Morgado
aleksander at aleksander.es
Fri Jun 23 20:41:23 UTC 2017
On 23/06/17 18:11, Ben Chan wrote:
> ---
> src/mm-base-modem.c | 6 +-----
> src/mm-bearer-list.c | 5 +++--
> src/mm-broadband-modem-qmi.c | 3 +--
> src/mm-device.c | 8 +++-----
> 4 files changed, 8 insertions(+), 14 deletions(-)
>
Pushed to git master, thanks!
> diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
> index d4f94495..29df53c3 100644
> --- a/src/mm-base-modem.c
> +++ b/src/mm-base-modem.c
> @@ -706,13 +706,9 @@ mm_base_modem_peek_best_data_port (MMBaseModem *self,
> GList *
> mm_base_modem_get_data_ports (MMBaseModem *self)
> {
> - GList *copy;
> -
> g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
>
> - copy = g_list_copy (self->priv->data);
> - g_list_foreach (copy, (GFunc)g_object_ref, NULL);
> - return copy;
> + return g_list_copy_deep (self->priv->data, (GCopyFunc)g_object_ref, NULL);
> }
>
> GList *
> diff --git a/src/mm-bearer-list.c b/src/mm-bearer-list.c
> index 9ad98aeb..81e847a7 100644
> --- a/src/mm-bearer-list.c
> +++ b/src/mm-bearer-list.c
> @@ -250,8 +250,9 @@ mm_bearer_list_disconnect_all_bearers (MMBearerList *self,
>
> ctx = g_new0 (DisconnectAllContext, 1);
> /* Get a copy of the list */
> - ctx->pending = g_list_copy (self->priv->bearers);
> - g_list_foreach (ctx->pending, (GFunc) g_object_ref, NULL);
> + ctx->pending = g_list_copy_deep (self->priv->bearers,
> + (GCopyFunc)g_object_ref,
> + NULL);
>
> task = g_task_new (self, NULL, callback, user_data);
> g_task_set_task_data (task,
> diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
> index 0e060d9a..38356426 100644
> --- a/src/mm-broadband-modem-qmi.c
> +++ b/src/mm-broadband-modem-qmi.c
> @@ -10353,8 +10353,7 @@ firmware_load_list (MMIfaceModemFirmware *_self,
> firmware_load_list);
>
> /* We'll return the new list of new references we create here */
> - dup = g_list_copy (self->priv->firmware_list);
> - g_list_foreach (dup, (GFunc)g_object_ref, NULL);
> + dup = g_list_copy_deep (self->priv->firmware_list, (GCopyFunc)g_object_ref, NULL);
>
> g_simple_async_result_set_op_res_gpointer (result, dup, NULL);
> g_simple_async_result_complete_in_idle (result);
> diff --git a/src/mm-device.c b/src/mm-device.c
> index 1b69f3de..1e53870a 100644
> --- a/src/mm-device.c
> +++ b/src/mm-device.c
> @@ -509,11 +509,9 @@ mm_device_peek_port_probe_list (MMDevice *self)
> GList *
> mm_device_get_port_probe_list (MMDevice *self)
> {
> - GList *copy;
> -
> - copy = g_list_copy (self->priv->port_probes);
> - g_list_foreach (copy, (GFunc)g_object_ref, NULL);
> - return copy;
> + return g_list_copy_deep (self->priv->port_probes,
> + (GCopyFunc)g_object_ref,
> + NULL);
> }
>
> gboolean
>
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list