[PATCH] huawei: avoid calling g_object_unref on NULL

Ben Chan benchan at chromium.org
Wed Jan 8 10:55:02 PST 2014


On Wed, Jan 8, 2014 at 6:14 AM, Dan Williams <dcbw at redhat.com> wrote:

> 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
>
>
I've a second thought. Perhaps connect_3gpp should just call
g_simple_async_result_report_error_in_idle if there is no data port
available. That avoids creating an immediately throw-away
Connect3gppContext and also makes the NULL check on ctx->data in
connect_3gpp_context_complete_and_free unnecessary. How do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/modemmanager-devel/attachments/20140108/a706b43f/attachment.html>


More information about the ModemManager-devel mailing list