linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Timeout in hciattach
@ 2010-06-17 10:20 Vladimir Davydov
  2010-06-30  9:50 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Davydov @ 2010-06-17 10:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sergey Kovalev

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

Hi, All

I have found that in the latest release of the bluez4 (4.66) timeout in 
hciattach doesn't work.

Look at this code of hciattach.c:

static void bcsp_tshy_sig_alarm(int sig)
{
	unsigned char bcsp_sync_pkt[10] = 
{0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0};
	int len, retries = 0;

	if (retries < bcsp_max_retries) {
		retries++;
		len = write(serial_fd, &bcsp_sync_pkt, 10);
		alarm(1);
		return;
	}

	tcflush(serial_fd, TCIOFLUSH);
	fprintf(stderr, "BCSP initialization timed out\n");
	exit(1);
}

The variable 'retries' will be always 0. Why is it not static? It was static 
in oldest releases (3.33 for example).

I have attached simple patch to fix that.

Best regards,
Vladimir

-- 
Vladimir Davydov
Senior Developer
Promwad Innovation Company
Web: www.promwad.com
22, Olshevskogo St.,
220073, Minsk,
BELARUS
Phone/Fax: +375 (17) 312–1246
E-mail: vladimir.davydov@promwad.com
Skype: v_davydov

[-- Attachment #2: hciattach-timeout.patch --]
[-- Type: text/x-patch, Size: 483 bytes --]

diff -urN bluez-4.42.orig/tools/hciattach.c bluez-4.42/tools/hciattach.c
--- bluez-4.42.orig/tools/hciattach.c	2009-05-19 12:04:10.000000000 +0300
+++ bluez-4.42/tools/hciattach.c	2010-06-16 17:39:01.477248730 +0300
@@ -326,7 +326,8 @@
 static void bcsp_tshy_sig_alarm(int sig)
 {
 	unsigned char bcsp_sync_pkt[10] = {0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0};
-	int len, retries = 0;
+	int len;
+	static int retries = 0;
 
 	if (retries < bcsp_max_retries) {
 		retries++;

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

* Re: Timeout in hciattach
  2010-06-17 10:20 Timeout in hciattach Vladimir Davydov
@ 2010-06-30  9:50 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2010-06-30  9:50 UTC (permalink / raw)
  To: Vladimir Davydov; +Cc: linux-bluetooth, Sergey Kovalev

Hi Vladimir,

On Thu, Jun 17, 2010, Vladimir Davydov wrote:
> I have found that in the latest release of the bluez4 (4.66) timeout in 
> hciattach doesn't work.
> 
> Look at this code of hciattach.c:
> 
> static void bcsp_tshy_sig_alarm(int sig)
> {
> 	unsigned char bcsp_sync_pkt[10] = 
> {0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0};
> 	int len, retries = 0;
> 
> 	if (retries < bcsp_max_retries) {
> 		retries++;
> 		len = write(serial_fd, &bcsp_sync_pkt, 10);
> 		alarm(1);
> 		return;
> 	}
> 
> 	tcflush(serial_fd, TCIOFLUSH);
> 	fprintf(stderr, "BCSP initialization timed out\n");
> 	exit(1);
> }
> 
> The variable 'retries' will be always 0. Why is it not static? It was static 
> in oldest releases (3.33 for example).

It looks to me like this is a regression introduced by commit
72c6ed7e2d619048440ff528fca7fef59887fbaf from Marcel.

> I have attached simple patch to fix that.

Could you please send a patch in git format-patch format and also fix
the issue in in the other _alarm function (if you take a look at
Marcel's patch you'll see both places that need fixing).

Johan

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

end of thread, other threads:[~2010-06-30  9:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-17 10:20 Timeout in hciattach Vladimir Davydov
2010-06-30  9:50 ` 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).