summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2012-07-23 18:16:29 +0200
committerTomas Bzatek <tbzatek@redhat.com>2012-07-31 11:59:37 +0200
commit23535a0e56da1640f0d1d4ecd8f65f66880134cf (patch)
tree8d296c97d294e298ebfdef27153ee249a7038dc3 /client
parent02f30b8058e61bd3dc6ab70fab1f3b13bd748043 (diff)
downloadgvfs-23535a0e56da1640f0d1d4ecd8f65f66880134cf.tar.gz
gdbus: Use g_clear_object() where appropriate
Diffstat (limited to 'client')
-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
8 files changed, 48 insertions, 96 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);
}