linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] client: Fix removing all devices
@ 2016-02-12 13:46 Szymon Janc
  2016-02-12 19:02 ` Szymon Janc
  0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2016-02-12 13:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

cmd_remove takes address string not device path.
---
 client/main.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/client/main.c b/client/main.c
index be785c5..b18bedd 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1333,10 +1333,24 @@ static void remove_device_setup(DBusMessageIter *iter, void *user_data)
 	dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
 }
 
+static void remove_device(GDBusProxy *proxy)
+{
+	char *path;
+
+	path = g_strdup(g_dbus_proxy_get_path(proxy));
+
+	if (g_dbus_proxy_method_call(default_ctrl, "RemoveDevice",
+						remove_device_setup,
+						remove_device_reply,
+						path, g_free) == FALSE) {
+		rl_printf("Failed to remove device\n");
+		g_free(path);
+	}
+}
+
 static void cmd_remove(const char *arg)
 {
 	GDBusProxy *proxy;
-	char *path;
 
 	if (!arg || !strlen(arg)) {
 		rl_printf("Missing device address argument\n");
@@ -1351,7 +1365,7 @@ static void cmd_remove(const char *arg)
 
 		for (list = g_list_first(dev_list); list; list = g_list_next(list)) {
 			GDBusProxy *proxy = list->data;
-			cmd_remove(g_dbus_proxy_get_path(proxy));
+			remove_device(proxy);
 		}
 
 		return;
@@ -1363,16 +1377,7 @@ static void cmd_remove(const char *arg)
 		return;
 	}
 
-	path = g_strdup(g_dbus_proxy_get_path(proxy));
-
-	if (g_dbus_proxy_method_call(default_ctrl, "RemoveDevice",
-						remove_device_setup,
-						remove_device_reply,
-						path, g_free) == FALSE) {
-		rl_printf("Failed to remove device\n");
-		g_free(path);
-		return;
-	}
+	remove_device(proxy);
 }
 
 static void connect_reply(DBusMessage *message, void *user_data)
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] client: Fix removing all devices
  2016-02-12 13:46 [PATCH] client: Fix removing all devices Szymon Janc
@ 2016-02-12 19:02 ` Szymon Janc
  0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2016-02-12 19:02 UTC (permalink / raw)
  To: linux-bluetooth

On Friday 12 February 2016 14:46:41 Szymon Janc wrote:
> cmd_remove takes address string not device path.
> ---
>  client/main.c | 29 +++++++++++++++++------------
>  1 file changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/client/main.c b/client/main.c
> index be785c5..b18bedd 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -1333,10 +1333,24 @@ static void remove_device_setup(DBusMessageIter
> *iter, void *user_data) dbus_message_iter_append_basic(iter,
> DBUS_TYPE_OBJECT_PATH, &path); }
> 
> +static void remove_device(GDBusProxy *proxy)
> +{
> +	char *path;
> +
> +	path = g_strdup(g_dbus_proxy_get_path(proxy));
> +
> +	if (g_dbus_proxy_method_call(default_ctrl, "RemoveDevice",
> +						remove_device_setup,
> +						remove_device_reply,
> +						path, g_free) == FALSE) {
> +		rl_printf("Failed to remove device\n");
> +		g_free(path);
> +	}
> +}
> +
>  static void cmd_remove(const char *arg)
>  {
>  	GDBusProxy *proxy;
> -	char *path;
> 
>  	if (!arg || !strlen(arg)) {
>  		rl_printf("Missing device address argument\n");
> @@ -1351,7 +1365,7 @@ static void cmd_remove(const char *arg)
> 
>  		for (list = g_list_first(dev_list); list; list = g_list_next(list)) {
>  			GDBusProxy *proxy = list->data;
> -			cmd_remove(g_dbus_proxy_get_path(proxy));
> +			remove_device(proxy);
>  		}
> 
>  		return;
> @@ -1363,16 +1377,7 @@ static void cmd_remove(const char *arg)
>  		return;
>  	}
> 
> -	path = g_strdup(g_dbus_proxy_get_path(proxy));
> -
> -	if (g_dbus_proxy_method_call(default_ctrl, "RemoveDevice",
> -						remove_device_setup,
> -						remove_device_reply,
> -						path, g_free) == FALSE) {
> -		rl_printf("Failed to remove device\n");
> -		g_free(path);
> -		return;
> -	}
> +	remove_device(proxy);
>  }
> 
>  static void connect_reply(DBusMessage *message, void *user_data)

Applied.

-- 
pozdrawiam
Szymon Janc

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-12 19:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-12 13:46 [PATCH] client: Fix removing all devices Szymon Janc
2016-02-12 19:02 ` Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).