linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix setting of mode after discovery times out.
@ 2011-04-06  0:44 Jaikumar Ganesh
  2011-04-09 17:35 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Jaikumar Ganesh @ 2011-04-06  0:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jaikumar Ganesh

When discovery times out, we were not setting the mode appropriately.
Thus, if the adapter is turned off and on, we will get the incorrect mode.
Also add a forward declaration for the introduced circular dependency.
---
 src/adapter.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index c400bfd..014cc0c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -156,6 +156,8 @@ struct btd_adapter {
 
 static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
 					guint interval);
+static DBusMessage *set_discoverable(DBusConnection *conn, DBusMessage *msg,
+				gboolean discoverable, void *data);
 
 static int found_device_cmp(const struct remote_dev_info *d1,
 			const struct remote_dev_info *d2)
@@ -374,7 +376,7 @@ static gboolean discov_timeout_handler(gpointer user_data)
 
 	adapter->discov_timeout_id = 0;
 
-	adapter_ops->set_discoverable(adapter->dev_id, FALSE);
+	set_discoverable(NULL, NULL, FALSE, user_data);
 
 	return FALSE;
 }
-- 
1.7.3.1


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

* Re: [PATCH] Fix setting of mode after discovery times out.
  2011-04-06  0:44 [PATCH] Fix setting of mode after discovery times out Jaikumar Ganesh
@ 2011-04-09 17:35 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2011-04-09 17:35 UTC (permalink / raw)
  To: Jaikumar Ganesh; +Cc: linux-bluetooth

Hi Jaikumar,

On Tue, Apr 05, 2011, Jaikumar Ganesh wrote:
> diff --git a/src/adapter.c b/src/adapter.c
> index c400bfd..014cc0c 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -156,6 +156,8 @@ struct btd_adapter {
>  
>  static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
>  					guint interval);
> +static DBusMessage *set_discoverable(DBusConnection *conn, DBusMessage *msg,
> +				gboolean discoverable, void *data);
>  
>  static int found_device_cmp(const struct remote_dev_info *d1,
>  			const struct remote_dev_info *d2)
> @@ -374,7 +376,7 @@ static gboolean discov_timeout_handler(gpointer user_data)
>  
>  	adapter->discov_timeout_id = 0;
>  
> -	adapter_ops->set_discoverable(adapter->dev_id, FALSE);
> +	set_discoverable(NULL, NULL, FALSE, user_data);
>  
>  	return FALSE;

I don't think it's appropriate to reuse set_discoverable here since it's
a D-Bus method callback. It can e.g. result in passing the DBusMessage
parameter to btd_error_failed which might cause a crash with a NULL
pointer. I think duplicating some code from set_discoverable would make
more sense, either within discov_timeout_handler or as a separate static
function.

Johan

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

end of thread, other threads:[~2011-04-09 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-06  0:44 [PATCH] Fix setting of mode after discovery times out Jaikumar Ganesh
2011-04-09 17:35 ` Johan Hedberg

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).