[PATCH] huawei: avoid calling g_object_unref on NULL

Dan Williams dcbw at redhat.com
Wed Jan 8 06:14:03 PST 2014


On Tue, 2014-01-07 at 23:55 -0800, Ben Chan wrote:
> This patch prevents connect_3gpp_context_complete_and_free from calling
> 'g_object_unref (ctx->data)' when connect_3gpp finds no data port (i.e.
> ctx->data is set to NULL).

There is "g_clear_object (&object)" which handles NULL and zeroes the
location of the pointer too.  Saves a LoC here and there and sometimes
looks cleaner.  No need to use that here, but for future reference.

Dan

> ---
>  plugins/huawei/mm-broadband-bearer-huawei.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/plugins/huawei/mm-broadband-bearer-huawei.c b/plugins/huawei/mm-broadband-bearer-huawei.c
> index b39839f..be84ff8 100644
> --- a/plugins/huawei/mm-broadband-bearer-huawei.c
> +++ b/plugins/huawei/mm-broadband-bearer-huawei.c
> @@ -69,7 +69,8 @@ connect_3gpp_context_complete_and_free (Connect3gppContext *ctx)
>      g_simple_async_result_complete_in_idle (ctx->result);
>      g_object_unref (ctx->cancellable);
>      g_object_unref (ctx->result);
> -    g_object_unref (ctx->data);
> +    if (ctx->data)
> +        g_object_unref (ctx->data);
>      g_object_unref (ctx->primary);
>      g_object_unref (ctx->modem);
>      g_object_unref (ctx->self);




More information about the ModemManager-devel mailing list