summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2021-02-10 16:32:40 +0100
committerBastien Nocera <hadess@hadess.net>2021-02-17 12:02:14 +0100
commitf602219f67cafdba41458a89e78982abd107cdb7 (patch)
treeab334b0614ad397feeca168e716787121a2af0e0
parentad5c6921b8206881d5b93c77968202bfb16ec7e4 (diff)
downloadgnome-bluetooth-f602219f67cafdba41458a89e78982abd107cdb7.tar.gz
lib: Use g_autoptr to free short-lived GDBusProxy objects
-rw-r--r--lib/bluetooth-agent.c28
-rw-r--r--lib/bluetooth-client.c8
2 files changed, 9 insertions, 27 deletions
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index 58bf57e2..0fce134b 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -140,7 +140,7 @@ static gboolean bluetooth_agent_request_pincode(BluetoothAgent *agent,
const char *path, GDBusMethodInvocation *invocation)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
if (priv->pincode_func == NULL)
return FALSE;
@@ -151,8 +151,6 @@ static gboolean bluetooth_agent_request_pincode(BluetoothAgent *agent,
priv->pincode_func(invocation, device, priv->pincode_data);
- g_object_unref(device);
-
return TRUE;
}
@@ -160,7 +158,7 @@ static gboolean bluetooth_agent_request_passkey(BluetoothAgent *agent,
const char *path, GDBusMethodInvocation *invocation)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
if (priv->passkey_func == NULL)
return FALSE;
@@ -171,8 +169,6 @@ static gboolean bluetooth_agent_request_passkey(BluetoothAgent *agent,
priv->passkey_func(invocation, device, priv->passkey_data);
- g_object_unref(device);
-
return TRUE;
}
@@ -181,7 +177,7 @@ static gboolean bluetooth_agent_display_passkey(BluetoothAgent *agent,
GDBusMethodInvocation *invocation)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
if (priv->display_func == NULL)
return FALSE;
@@ -193,8 +189,6 @@ static gboolean bluetooth_agent_display_passkey(BluetoothAgent *agent,
priv->display_func(invocation, device, passkey, entered,
priv->display_data);
- g_object_unref(device);
-
return TRUE;
}
@@ -203,7 +197,7 @@ static gboolean bluetooth_agent_display_pincode(BluetoothAgent *agent,
GDBusMethodInvocation *invocation)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
if (priv->display_pincode_func == NULL)
return FALSE;
@@ -215,8 +209,6 @@ static gboolean bluetooth_agent_display_pincode(BluetoothAgent *agent,
priv->display_pincode_func(invocation, device, pincode,
priv->display_data);
- g_object_unref(device);
-
return TRUE;
}
@@ -225,7 +217,7 @@ static gboolean bluetooth_agent_request_confirmation(BluetoothAgent *agent,
GDBusMethodInvocation *invocation)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
if (priv->confirm_func == NULL)
return FALSE;
@@ -236,8 +228,6 @@ static gboolean bluetooth_agent_request_confirmation(BluetoothAgent *agent,
priv->confirm_func(invocation, device, passkey, priv->confirm_data);
- g_object_unref(device);
-
return TRUE;
}
@@ -245,7 +235,7 @@ static gboolean bluetooth_agent_request_authorization(BluetoothAgent *agent,
const char *path, GDBusMethodInvocation *invocation)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
if (priv->authorize_func == NULL)
return FALSE;
@@ -256,8 +246,6 @@ static gboolean bluetooth_agent_request_authorization(BluetoothAgent *agent,
priv->authorize_func(invocation, device, priv->authorize_data);
- g_object_unref(device);
-
return TRUE;
}
@@ -266,7 +254,7 @@ static gboolean bluetooth_agent_authorize_service(BluetoothAgent *agent,
GDBusMethodInvocation *invocation)
{
BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
if (priv->authorize_service_func == NULL)
return FALSE;
@@ -278,8 +266,6 @@ static gboolean bluetooth_agent_authorize_service(BluetoothAgent *agent,
priv->authorize_service_func(invocation, device, uuid,
priv->authorize_service_data);
- g_object_unref(device);
-
return TRUE;
}
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 1cfd30fb..d537cd70 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1422,7 +1422,7 @@ bluetooth_client_setup_device (BluetoothClient *client,
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GSimpleAsyncResult *simple;
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
GtkTreeIter iter, adapter_iter;
gboolean paired;
GError *err = NULL;
@@ -1477,8 +1477,6 @@ bluetooth_client_setup_device (BluetoothClient *client,
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
}
-
- g_object_unref (device);
}
gboolean
@@ -1601,7 +1599,7 @@ bluetooth_client_connect_service (BluetoothClient *client,
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
GSimpleAsyncResult *simple;
- GDBusProxy *device;
+ g_autoptr(GDBusProxy) device = NULL;
g_return_if_fail (BLUETOOTH_IS_CLIENT (client));
g_return_if_fail (path != NULL);
@@ -1630,8 +1628,6 @@ bluetooth_client_connect_service (BluetoothClient *client,
(GAsyncReadyCallback) disconnect_callback,
simple);
}
-
- g_object_unref (device);
}
/**