After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695877 - online-accounts: Small cleanup about resource releasing
online-accounts: Small cleanup about resource releasing
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Online Accounts
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-03-14 20:45 UTC by Emanuele Aina
Modified: 2013-04-03 14:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
online-accounts: Small cleanup about resource releasing (2.67 KB, patch)
2013-03-14 20:45 UTC, Emanuele Aina
none Details | Review
online-accounts: Small cleanup about resource releasing (2.65 KB, patch)
2013-03-14 22:57 UTC, Emanuele Aina
committed Details | Review
online-accounts: Small cleanup about resource releasing (2.65 KB, patch)
2013-04-03 14:12 UTC, Emanuele Aina
committed Details | Review

Description Emanuele Aina 2013-03-14 20:45:10 UTC
Use g_clear_object() as a NULL-safe g_object_unref() and
g_list_free_full() instead of explicitly iterating the list contents.

I'm less sure about the following change:
-  if (priv->error != NULL)
-    g_error_free (priv->error);
+  g_clear_pointer (&priv->error, g_error_free);

I prefer g_clear_pointer() but it has worse performance because it guarantees
atomic behaviour by taking a lock. OTOH it's not a performance critical path
and I'd rather optimize for legibility with such negligible performance loss.
Comment 1 Emanuele Aina 2013-03-14 20:45:13 UTC
Created attachment 238924 [details] [review]
online-accounts: Small cleanup about resource releasing

Use g_clear_object() as a NULL-safe g_object_unref() and
g_list_free_full() instead of explicitly iterating the list contents.
Comment 2 Rui Matos 2013-03-14 22:44:11 UTC
Drive-by comment:

(In reply to comment #0)
> I'm less sure about the following change:
> -  if (priv->error != NULL)
> -    g_error_free (priv->error);
> +  g_clear_pointer (&priv->error, g_error_free);

glib also has g_clear_error()
Comment 3 Emanuele Aina 2013-03-14 22:57:50 UTC
Created attachment 238944 [details] [review]
online-accounts: Small cleanup about resource releasing

Use g_clear_error() as it is shorter and clears any doubt as it doesn't take
any lock.
Comment 4 Bastien Nocera 2013-04-03 13:51:52 UTC
Review of attachment 238944 [details] [review]:

Looks good.
Comment 5 Emanuele Aina 2013-04-03 14:11:51 UTC
The following fix has been pushed:
397181e online-accounts: Small cleanup about resource releasing
Comment 6 Emanuele Aina 2013-04-03 14:12:04 UTC
Created attachment 240477 [details] [review]
online-accounts: Small cleanup about resource releasing

Use g_clear_object() as a NULL-safe g_object_unref() and
g_list_free_full() instead of explicitly iterating the list contents.