[gnome-bluetooth] lib: make initial checks similar when registering/unregister agent
- From: Daniele Forsi <dforsi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] lib: make initial checks similar when registering/unregister agent
- Date: Wed, 25 Apr 2012 15:23:50 +0000 (UTC)
commit b0d022fb267902de7c3b2fd86cec4926a5544625
Author: Daniele Forsi <dforsi src gnome org>
Date: Wed Apr 25 15:37:50 2012 +0200
lib: make initial checks similar when registering/unregister agent
This avoid executing some code before validating the arguments.
lib/bluetooth-agent.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index 35d381a..01273e1 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -434,22 +434,24 @@ get_default_adapter (void)
gboolean bluetooth_agent_register(BluetoothAgent *agent)
{
- BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
+ BluetoothAgentPrivate *priv;
GError *error = NULL;
char *path;
g_return_val_if_fail (BLUETOOTH_IS_AGENT (agent), FALSE);
- if (priv->path != NULL) {
- g_warning ("Agent already setup on '%s'", priv->path);
- return FALSE;
- }
+ priv = BLUETOOTH_AGENT_GET_PRIVATE (agent);
priv->adapter = get_default_adapter ();
if (priv->adapter == NULL)
return FALSE;
+ if (priv->path != NULL) {
+ g_warning ("Agent already setup on '%s'", priv->path);
+ return FALSE;
+ }
+
path = g_path_get_basename(g_dbus_proxy_get_object_path(priv->adapter));
priv->path = g_strdup_printf("/org/bluez/agent/%s", path);
g_free(path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]