summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/gdaemonfile.c86
-rw-r--r--client/gdaemonfileenumerator.c3
-rw-r--r--client/gdaemonfilemonitor.c6
-rw-r--r--client/gdaemonmount.c18
-rw-r--r--client/gdaemonvfs.c7
-rw-r--r--client/gvfsdaemondbus.c9
-rw-r--r--client/gvfsfusedaemon.c3
-rw-r--r--client/gvfsiconloadable.c12
-rw-r--r--common/gmounttracker.c10
-rw-r--r--daemon/daemon-main.c3
-rw-r--r--daemon/gvfsbackend.c12
-rw-r--r--daemon/gvfsjobdbus.c7
-rw-r--r--daemon/gvfsjobmount.c6
-rw-r--r--daemon/main.c3
-rw-r--r--daemon/mount.c3
15 files changed, 62 insertions, 126 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index b647a6d4..cef7cb57 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -500,18 +500,14 @@ async_proxy_create_free (AsyncProxyCreate *data)
if (data->notify)
data->notify (data->callback_data);
- if (data->result)
- g_object_unref (data->result);
- g_object_unref (data->file);
+ g_clear_object (&data->result);
+ g_clear_object (&data->file);
g_free (data->op);
- if (data->cancellable)
- g_object_unref (data->cancellable);
+ g_clear_object (&data->cancellable);
if (data->mount_info)
g_mount_info_unref (data->mount_info);
- if (data->connection)
- g_object_unref (data->connection);
- if (data->proxy)
- g_object_unref (data->proxy);
+ g_clear_object (&data->connection);
+ g_clear_object (&data->proxy);
g_free (data);
}
@@ -734,8 +730,7 @@ g_daemon_file_enumerate_children (GFile *file,
return G_FILE_ENUMERATOR (enumerator);
out:
- if (enumerator != NULL)
- g_object_unref (enumerator);
+ g_clear_object (&enumerator);
return NULL;
}
@@ -875,12 +870,9 @@ typedef struct {
static void
async_call_query_info_free (AsyncCallQueryInfo *data)
{
- if (data->file)
- g_object_unref (data->file);
- if (data->result)
- g_object_unref (data->result);
- if (data->cancellable)
- g_object_unref (data->cancellable);
+ g_clear_object (&data->file);
+ g_clear_object (&data->result);
+ g_clear_object (&data->cancellable);
g_free (data->attributes);
g_free (data);
}
@@ -1019,12 +1011,9 @@ typedef struct {
static void
async_call_file_read_write_free (AsyncCallFileReadWrite *data)
{
- if (data->file)
- g_object_unref (data->file);
- if (data->result)
- g_object_unref (data->result);
- if (data->cancellable)
- g_object_unref (data->cancellable);
+ g_clear_object (&data->file);
+ g_clear_object (&data->result);
+ g_clear_object (&data->cancellable);
g_free (data->etag);
g_free (data);
}
@@ -1333,12 +1322,9 @@ typedef struct {
static void
free_async_mount_op (AsyncMountOp *data)
{
- if (data->result)
- g_object_unref (data->result);
- if (data->cancellable)
- g_object_unref (data->cancellable);
- if (data->mount_operation)
- g_object_unref (data->mount_operation);
+ g_clear_object (&data->result);
+ g_clear_object (&data->cancellable);
+ g_clear_object (&data->mount_operation);
g_free (data);
}
@@ -2001,10 +1987,8 @@ static void
free_mount_data (MountData *data)
{
g_object_unref (data->file);
- if (data->cancellable)
- g_object_unref (data->cancellable);
- if (data->mount_operation)
- g_object_unref (data->mount_operation);
+ g_clear_object (&data->cancellable);
+ g_clear_object (&data->mount_operation);
g_free (data);
}
@@ -2188,12 +2172,9 @@ typedef struct {
static void
async_call_query_fs_info_free (AsyncCallQueryFsInfo *data)
{
- if (data->file)
- g_object_unref (data->file);
- if (data->result)
- g_object_unref (data->result);
- if (data->cancellable)
- g_object_unref (data->cancellable);
+ g_clear_object (&data->file);
+ g_clear_object (&data->result);
+ g_clear_object (&data->cancellable);
g_free (data->attributes);
g_free (data);
}
@@ -3034,8 +3015,7 @@ retry:
g_propagate_error (error, my_error);
}
- if (proxy)
- g_object_unref (proxy);
+ g_clear_object (&proxy);
g_free (local_path);
g_free (obj_path);
@@ -3392,14 +3372,10 @@ async_call_enumerate_free (AsyncCallEnumerate *data)
{
g_print ("async_call_enumerate_free\n");
- if (data->file)
- g_object_unref (data->file);
- if (data->result)
- g_object_unref (data->result);
- if (data->cancellable)
- g_object_unref (data->cancellable);
- if (data->enumerator)
- g_object_unref (data->enumerator);
+ g_clear_object (&data->file);
+ g_clear_object (&data->result);
+ g_clear_object (&data->cancellable);
+ g_clear_object (&data->enumerator);
g_free (data->attributes);
g_free (data);
}
@@ -3571,8 +3547,7 @@ out:
if (my_error)
g_error_free (my_error);
- if (data->cancellable)
- g_object_unref (data->cancellable);
+ g_clear_object (&data->cancellable);
g_object_unref (data->file);
g_object_unref (data->result);
g_free (data);
@@ -3665,12 +3640,9 @@ typedef struct {
static void
async_call_set_display_name_free (AsyncCallSetDisplayName *data)
{
- if (data->file)
- g_object_unref (data->file);
- if (data->result)
- g_object_unref (data->result);
- if (data->cancellable)
- g_object_unref (data->cancellable);
+ g_clear_object (&data->file);
+ g_clear_object (&data->result);
+ g_clear_object (&data->cancellable);
if (data->mount_info)
g_mount_info_unref (data->mount_info);
g_free (data->display_name);
diff --git a/client/gdaemonfileenumerator.c b/client/gdaemonfileenumerator.c
index 54c76620..e7d48b0f 100644
--- a/client/gdaemonfileenumerator.c
+++ b/client/gdaemonfileenumerator.c
@@ -121,8 +121,7 @@ g_daemon_file_enumerator_finalize (GObject *object)
if (daemon->metadata_tree)
meta_tree_unref (daemon->metadata_tree);
- if (daemon->sync_connection)
- g_object_unref (daemon->sync_connection);
+ g_clear_object (&daemon->sync_connection);
if (daemon->next_files_context)
g_main_context_unref (daemon->next_files_context);
diff --git a/client/gdaemonfilemonitor.c b/client/gdaemonfilemonitor.c
index 739adcad..71de50e5 100644
--- a/client/gdaemonfilemonitor.c
+++ b/client/gdaemonfilemonitor.c
@@ -60,8 +60,7 @@ g_daemon_file_monitor_finalize (GObject* object)
_g_dbus_unregister_vfs_filter (daemon_monitor->object_path);
- if (daemon_monitor->connection)
- g_object_unref (daemon_monitor->connection);
+ g_clear_object (&daemon_monitor->connection);
g_free (daemon_monitor->object_path);
g_free (daemon_monitor->remote_id);
@@ -173,8 +172,7 @@ static void
async_proxy_create_free (AsyncProxyCreate *data)
{
g_object_unref (data->monitor);
- if (data->connection)
- g_object_unref (data->connection);
+ g_clear_object (&data->connection);
g_free (data);
}
diff --git a/client/gdaemonmount.c b/client/gdaemonmount.c
index fa29e07b..e3e32c10 100644
--- a/client/gdaemonmount.c
+++ b/client/gdaemonmount.c
@@ -188,18 +188,12 @@ typedef struct {
static void
async_proxy_create_free (AsyncProxyCreate *data)
{
- if (data->mount)
- g_object_unref (data->mount);
- if (data->result)
- g_object_unref (data->result);
- if (data->cancellable)
- g_object_unref (data->cancellable);
- if (data->mount_operation)
- g_object_unref (data->mount_operation);
- if (data->connection)
- g_object_unref (data->connection);
- if (data->proxy)
- g_object_unref (data->proxy);
+ g_clear_object (&data->mount);
+ g_clear_object (&data->result);
+ g_clear_object (&data->cancellable);
+ g_clear_object (&data->mount_operation);
+ g_clear_object (&data->connection);
+ g_clear_object (&data->proxy);
g_free (data);
}
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index 04af48d2..8be89591 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -98,11 +98,8 @@ g_daemon_vfs_finalize (GObject *object)
g_strfreev (vfs->supported_uri_schemes);
- if (vfs->async_bus)
- g_object_unref (vfs->async_bus);
-
- if (vfs->wrapped_vfs)
- g_object_unref (vfs->wrapped_vfs);
+ g_clear_object (&vfs->async_bus);
+ g_clear_object (&vfs->wrapped_vfs);
/* must chain up */
G_OBJECT_CLASS (g_daemon_vfs_parent_class)->finalize (object);
diff --git a/client/gvfsdaemondbus.c b/client/gvfsdaemondbus.c
index 9c843560..3ed9fd4e 100644
--- a/client/gvfsdaemondbus.c
+++ b/client/gvfsdaemondbus.c
@@ -298,10 +298,8 @@ async_call_finish (AsyncDBusCall *async_call)
async_call->io_error,
async_call->callback_data);
- if (async_call->connection)
- g_object_unref (async_call->connection);
- if (async_call->cancellable)
- g_object_unref (async_call->cancellable);
+ g_clear_object (&async_call->connection);
+ g_clear_object (&async_call->cancellable);
if (async_call->io_error)
g_error_free (async_call->io_error);
g_free (async_call);
@@ -595,8 +593,7 @@ free_local_connections (ThreadLocalConnections *local)
{
g_print ("free_local_connections()\n");
g_hash_table_destroy (local->connections);
- if (local->session_bus)
- g_object_unref (local->session_bus);
+ g_clear_object (&local->session_bus);
g_free (local);
}
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index aa26a390..b0ec1dde 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -2413,8 +2413,7 @@ vfs_destroy (gpointer param)
{
if (daemon_name_watcher)
g_bus_unwatch_name (daemon_name_watcher);
- if (dbus_conn)
- g_object_unref (dbus_conn);
+ g_clear_object (&dbus_conn);
mount_list_free ();
if (subthread_main_loop != NULL)
diff --git a/client/gvfsiconloadable.c b/client/gvfsiconloadable.c
index 987bdbc6..919eb62b 100644
--- a/client/gvfsiconloadable.c
+++ b/client/gvfsiconloadable.c
@@ -162,17 +162,13 @@ typedef struct {
static void
async_path_call_free (AsyncPathCall *data)
{
- if (data->connection)
- g_object_unref (data->connection);
+ g_clear_object (&data->connection);
if (data->mount_info)
g_mount_info_unref (data->mount_info);
- if (data->result)
- g_object_unref (data->result);
+ g_clear_object (&data->result);
g_object_unref (data->vfs_icon);
- if (data->cancellable)
- g_object_unref (data->cancellable);
- if (data->proxy)
- g_object_unref (data->proxy);
+ g_clear_object (&data->cancellable);
+ g_clear_object (&data->proxy);
g_free (data);
}
diff --git a/common/gmounttracker.c b/common/gmounttracker.c
index d18aa4e1..0f710941 100644
--- a/common/gmounttracker.c
+++ b/common/gmounttracker.c
@@ -254,10 +254,8 @@ g_mount_tracker_finalize (GObject *object)
(GFunc)g_mount_info_unref, NULL);
g_list_free (tracker->mounts);
- if (tracker->proxy)
- g_object_unref (tracker->proxy);
- if (tracker->connection)
- g_object_unref (tracker->connection);
+ g_clear_object (&tracker->proxy);
+ g_clear_object (&tracker->connection);
if (G_OBJECT_CLASS (g_mount_tracker_parent_class)->finalize)
(*G_OBJECT_CLASS (g_mount_tracker_parent_class)->finalize) (object);
@@ -310,9 +308,7 @@ g_mount_tracker_set_property (GObject *object,
switch (prop_id)
{
case PROP_CONNECTION:
- if (tracker->connection)
- g_object_unref (tracker->connection);
- tracker->connection = NULL;
+ g_clear_object (&tracker->connection);
if (g_value_get_pointer (value))
tracker->connection = g_object_ref (g_value_get_pointer (value));
break;
diff --git a/daemon/daemon-main.c b/daemon/daemon-main.c
index d218f26a..40d327ad 100644
--- a/daemon/daemon-main.c
+++ b/daemon/daemon-main.c
@@ -413,8 +413,7 @@ daemon_main (int argc,
g_main_loop_run (loop);
- if (data->daemon != NULL)
- g_object_unref (data->daemon);
+ g_clear_object (&data->daemon);
g_free (data->mountable_name);
g_free (data);
if (name_owner_id != 0)
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index 242a7fe7..4f9c0121 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -147,8 +147,7 @@ g_vfs_backend_finalize (GObject *object)
g_free (backend->priv->display_name);
g_free (backend->priv->stable_name);
g_strfreev (backend->priv->x_content_types);
- if (backend->priv->icon != NULL)
- g_object_unref (backend->priv->icon);
+ g_clear_object (&backend->priv->icon);
g_free (backend->priv->prefered_filename_encoding);
g_free (backend->priv->default_location);
if (backend->priv->mount_spec)
@@ -388,8 +387,7 @@ void
g_vfs_backend_set_icon_name (GVfsBackend *backend,
const char *icon_name)
{
- if (backend->priv->icon != NULL)
- g_object_unref (backend->priv->icon);
+ g_clear_object (&backend->priv->icon);
backend->priv->icon = g_themed_icon_new_with_default_fallbacks (icon_name);
}
@@ -397,8 +395,7 @@ void
g_vfs_backend_set_icon (GVfsBackend *backend,
GIcon *icon)
{
- if (backend->priv->icon != NULL)
- g_object_unref (backend->priv->icon);
+ g_clear_object (&backend->priv->icon);
backend->priv->icon = g_object_ref (icon);
}
@@ -599,8 +596,7 @@ typedef struct {
static void
async_proxy_create_free (AsyncProxyCreate *data)
{
- if (data->backend)
- g_object_unref (data->backend);
+ g_clear_object (&data->backend);
g_free (data);
}
diff --git a/daemon/gvfsjobdbus.c b/daemon/gvfsjobdbus.c
index d80e8e98..57852a4f 100644
--- a/daemon/gvfsjobdbus.c
+++ b/daemon/gvfsjobdbus.c
@@ -59,11 +59,8 @@ g_vfs_job_dbus_finalize (GObject *object)
job = G_VFS_JOB_DBUS (object);
- if (job->invocation)
- g_object_unref (job->invocation);
-
- if (job->object)
- g_object_unref (job->object);
+ g_clear_object (&job->invocation);
+ g_clear_object (&job->object);
if (G_OBJECT_CLASS (g_vfs_job_dbus_parent_class)->finalize)
(*G_OBJECT_CLASS (g_vfs_job_dbus_parent_class)->finalize) (object);
diff --git a/daemon/gvfsjobmount.c b/daemon/gvfsjobmount.c
index fcca9457..1cd9e289 100644
--- a/daemon/gvfsjobmount.c
+++ b/daemon/gvfsjobmount.c
@@ -47,10 +47,8 @@ g_vfs_job_mount_finalize (GObject *object)
g_mount_spec_unref (job->mount_spec);
g_object_unref (job->mount_source);
g_object_unref (job->backend);
- if (job->object)
- g_object_unref (job->object);
- if (job->invocation)
- g_object_unref (job->invocation);
+ g_clear_object (&job->object);
+ g_clear_object (&job->invocation);
if (G_OBJECT_CLASS (g_vfs_job_mount_parent_class)->finalize)
(*G_OBJECT_CLASS (g_vfs_job_mount_parent_class)->finalize) (object);
diff --git a/daemon/main.c b/daemon/main.c
index 4cf5f5be..4b52e34e 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -200,8 +200,7 @@ main (int argc, char *argv[])
mount_finalize ();
- if (daemon != NULL)
- g_object_unref (daemon);
+ g_clear_object (&daemon);
if (name_owner_id != 0)
g_bus_unown_name (name_owner_id);
if (loop != NULL)
diff --git a/daemon/mount.c b/daemon/mount.c
index d872c019..a96d7f74 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -258,8 +258,7 @@ mount_data_free (MountData *data)
g_object_unref (data->source);
g_mount_spec_unref (data->mount_spec);
g_free (data->obj_path);
- if (data->spawner)
- g_object_unref (data->spawner);
+ g_clear_object (&data->spawner);
g_print ("mount_data_free\n");