Skip to contentSkip to conversation

GCC-4 Patch for btsco

Bluez-devel Applied Bastien Nocera 4 participants 11 messages Jun 17, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Heya,

As it looks like the btsco people hang out here, I posted a patch earlier this week on the sourceforce page.

The patch is at:
http://makeashorterlink.com/?A3F66174B

- Fixes "argument differ in signedness issues"
- Fix hci_switch_role expecting a bdaddr_t as the second argument (not a "bdaddr_t *")
- Fix compilation with 2.6 kernels where /lib/modules/<kernel-version>/build is a symlink to the necessary headers to compile a kernel module

Cheers

PS: Please CC: me on the answers as I'm not subscribed to the list.

Index: a2play.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2play.c,v retrieving revision 1.80

a2play.c +2 -1
diff -u -r1.80 a2play.c
@@ -278,7 +278,8 @@
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	int sk, opt;
+	int sk;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {

Index: a2recv.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2recv.c,v retrieving revision 1.13

a2recv.c +4 -5
diff -u -r1.13 a2recv.c
@@ -152,9 +152,8 @@
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	
 	int sk;
-	int opt;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {
@@ -205,8 +204,8 @@
 	struct l2cap_options opts;
 	socklen_t addrlen;
 	int nsk;
-	int opt;
-	
+	unsigned int opt;
+
 	memset(&addr, 0, sizeof(addr));
 	addrlen = sizeof(addr);
 
@@ -278,7 +277,7 @@
 		return;
         }
 
-        if (hci_switch_role(dd, &bdaddr, role, 10000) < 0) {
+        if (hci_switch_role(dd, bdaddr, role, 10000) < 0) {
                 perror("Switch role request failed");
         }
 

Index: btsco.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco.c,v
retrieving revision 1.27

btsco.c +4 -3
diff -u -r1.27 btsco.c
@@ -139,7 +139,8 @@
 	struct sockaddr_sco addr;
 	struct sco_conninfo conn;
 	struct sco_options opts;
-	int s, size;
+	int s;
+	unsigned int size;
 
 	if ((s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) {
 		return -1;
@@ -443,7 +444,7 @@
 	struct sigaction sa;
 
 	//struct timeval timeout;
-	unsigned char buf[2048];
+	char buf[2048];
 	//int sel, rlen, wlen;
 	int rlen, wlen;
 
@@ -640,7 +641,7 @@
 			perror("poll");
 			sleep(1); /* Don't steal the CPU in case of non-transient errors. */
 		} else if (ret > 0) {
-			short revents;
+			unsigned short revents;
 
 			/*printf("inner loop\n"); */
 			/* Volume polling (sound card) */

Index: btsco2.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco2.c,v retrieving revision 1.2

btsco2.c +2 -2
diff -u -r1.2 btsco2.c
@@ -377,7 +377,7 @@
 
 static int headset_from_bt(struct s_headset *headset)
 {
-	unsigned char buf[2048];
+	char buf[2048];
 	int rlen;
 	int opdone;
 	
@@ -535,7 +535,7 @@
 
 	/* we are not yet connected */
 	while (!terminate) {
-		short revents;
+		unsigned short revents;
 		int nfds;
 		nfds = 0;
 		/* set up data polling description */

Index: kernel/Makefile
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/kernel/Makefile,v retrieving revision 1.3

Makefile +3 -3
diff -u -r1.3 Makefile
@@ -10,10 +10,10 @@
 
 
 default:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules
 
 install:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules_install
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules_install
 
 clean:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` clean
+	@make -C /lib/modules/`uname -r`/build M=`pwd` clean

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#1 lore raw

Hi Bastien,

Quoted 2 lines

- Fix hci_switch_role expecting a bdaddr_t as the second argument (not a "bdaddr_t *")

this was a bug in the earlier library versions. The correct argument is a "bdaddr_t *" as for all other functions.

Regards

Marcel

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw

Marcel Holtmann <marcel <at> holtmann.org> writes:

Hey Marcel,

Quoted 7 lines

Hi Bastien,

Quoted 2 lines

- Fix hci_switch_role expecting a bdaddr_t as the second argument (not a "bdaddr_t *")

this was a bug in the earlier library versions. The correct argument is a "bdaddr_t *" as for all other functions.

I believe you mean that there was a bug in the headers. In which version of the bluez-libs was this fixed?

Slightly updated patch attached, we would want to require a newer version of bluez-libs in the configure.

Index: a2play.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2play.c,v retrieving revision 1.80

a2play.c +2 -1
diff -u -p -r1.80 a2play.c
@@ -278,7 +278,8 @@ static int do_connect(bdaddr_t *src, bda
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	int sk, opt;
+	int sk;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {

Index: a2recv.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2recv.c,v retrieving revision 1.13

a2recv.c +6 -4
diff -u -p -r1.13 a2recv.c
@@ -152,9 +152,8 @@ static int do_listen(bdaddr_t *src, unsi
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	
 	int sk;
-	int opt;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {
@@ -205,8 +204,8 @@ static int do_accept(int serverfd, bdadd
 	struct l2cap_options opts;
 	socklen_t addrlen;
 	int nsk;
-	int opt;
-	
+	unsigned int opt;
+
 	memset(&addr, 0, sizeof(addr));
 	addrlen = sizeof(addr);
 
@@ -278,6 +277,9 @@ static void make_master(bdaddr_t bdaddr)
 		return;
         }
 
+	/* Older versions of bluez-libs got the second argument
+	 * wrong, hci_switch_role is expecting a pointer to
+	 * a bdaddr_t */
         if (hci_switch_role(dd, &bdaddr, role, 10000) < 0) {
                 perror("Switch role request failed");
         }

Index: btsco.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco.c,v
retrieving revision 1.27

btsco.c +4 -3
diff -u -p -r1.27 btsco.c
@@ -139,7 +139,8 @@ static int sco_connect(bdaddr_t * src, b
 	struct sockaddr_sco addr;
 	struct sco_conninfo conn;
 	struct sco_options opts;
-	int s, size;
+	int s;
+	unsigned int size;
 
 	if ((s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) {
 		return -1;
@@ -443,7 +444,7 @@ int main(int argc, char *argv[])
 	struct sigaction sa;
 
 	//struct timeval timeout;
-	unsigned char buf[2048];
+	char buf[2048];
 	//int sel, rlen, wlen;
 	int rlen, wlen;
 
@@ -640,7 +641,7 @@ int main(int argc, char *argv[])
 			perror("poll");
 			sleep(1); /* Don't steal the CPU in case of non-transient errors. */
 		} else if (ret > 0) {
-			short revents;
+			unsigned short revents;
 
 			/*printf("inner loop\n"); */
 			/* Volume polling (sound card) */

Index: btsco2.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco2.c,v retrieving revision 1.2

btsco2.c +2 -2
diff -u -p -r1.2 btsco2.c
@@ -377,7 +377,7 @@ static int headset_micro(struct s_headse
 
 static int headset_from_bt(struct s_headset *headset)
 {
-	unsigned char buf[2048];
+	char buf[2048];
 	int rlen;
 	int opdone;
 	
@@ -535,7 +535,7 @@ int main(int argc, char *argv[])
 
 	/* we are not yet connected */
 	while (!terminate) {
-		short revents;
+		unsigned short revents;
 		int nfds;
 		nfds = 0;
 		/* set up data polling description */

Index: kernel/Makefile
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/kernel/Makefile,v retrieving revision 1.3

Makefile +3 -3
diff -u -p -r1.3 Makefile
@@ -10,10 +10,10 @@ endif
 
 
 default:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules
 
 install:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules_install
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules_install
 
 clean:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` clean
+	@make -C /lib/modules/`uname -r`/build M=`pwd` clean

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#3 lore raw

Hi Bastian,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

- Fix hci_switch_role expecting a bdaddr_t as the second argument (not a "bdaddr_t *")

this was a bug in the earlier library versions. The correct argument is a "bdaddr_t *" as for all other functions.

I believe you mean that there was a bug in the headers. In which version of the bluez-libs was this fixed?

the bug was also present in the function itself. I have no idea how it slipped into the source. I fixed it with the bluez-libs-2.11 release.

Regards

Marcel

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw
Quoted 2 lines · Marcel Holtmann <marcel <at> holtmann.org> writes:

the bug was also present in the function itself. I have no idea how it slipped into the source. I fixed it with the bluez-libs-2.11 release.

Excellent, here's a patch to btsco to require bluez-libs 2.11.

$ ./configure
<snip
checking for hci_open_dev in -lbluetooth... yes
checking for sdp_connect in -lbluetooth... yes
configure: error: bluez-libs 2.11 or better is required to compile btsco
make: *** [config.status] Error 1
$ grep hci_switch_role config.log
conftest.c:35: error: incompatible type for argument 2 of 'hci_switch_role'
|       hci_switch_role(dd, addr, role, to);

Index: configure.in
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/configure.in,v retrieving revision 1.8

configure.in 17 Jun 2005 11:36:39 -0000 renamed from configure.in 22 Apr 2005 17:17:25 -0000 1.8 +16 -0
diff -u -r1.8 configure.in
@@ -19,6 +19,22 @@
 AC_PROG_RANLIB
 AC_PATH_BLUEZ
 
+AC_TRY_COMPILE([
+       #include <bluetooth/bluetooth.h>
+       #include <sys/socket.h>
+       #include <bluetooth/hci.h>
+       #include <bluetooth/hci_lib.h>
+       ],[
+       bdaddr_t *addr;
+       int dd = 0;
+       int role = 0;
+       int to = 0;
+       hci_switch_role(dd, addr, role, to);
+       ],HAVE_BLUEZ=yes,HAVE_BLUEZ=no)
+if test x$HAVE_BLUEZ != xyes; then
+       AC_MSG_ERROR(bluez-libs 2.11 or better is required to compile btsco)
+fi
+
 AM_PATH_ALSA(1.0.3)
 
 XIPH_PATH_AO

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#5 lore raw

Bastien,

Could you help to just disable the role switch call at compile time if bluez-libs is too old? Most people don't need it. I don't know the autoconf stuff well enough to make it a conditional compile.

Brad

Quoted 54 lines · Bastien Nocera
Quoted 2 lines · Marcel Holtmann <marcel <at> holtmann.org> writes:

the bug was also present in the function itself. I have no idea how it slipped into the source. I fixed it with the bluez-libs-2.11 release.

Excellent, here's a patch to btsco to require bluez-libs 2.11.

$ ./configure
<snip
checking for hci_open_dev in -lbluetooth... yes
checking for sdp_connect in -lbluetooth... yes
configure: error: bluez-libs 2.11 or better is required to compile btsco
make: *** [config.status] Error 1
$ grep hci_switch_role config.log
conftest.c:35: error: incompatible type for argument 2 of 'hci_switch_role'
|       hci_switch_role(dd, addr, role, to);

Index: configure.in
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/configure.in,v retrieving revision 1.8
diff -u -r1.8 configure.in

configure.in 17 Jun 2005 11:36:39 -0000 renamed from configure.in 22 Apr 2005 17:17:25 -0000 1.8 +16 -1
@@ -19,6 +19,22 @@
 AC_PROG_RANLIB
 AC_PATH_BLUEZ
 
+AC_TRY_COMPILE([
+       #include <bluetooth/bluetooth.h>
+       #include <sys/socket.h>
+       #include <bluetooth/hci.h>
+       #include <bluetooth/hci_lib.h>
+       ],[
+       bdaddr_t *addr;
+       int dd = 0;
+       int role = 0;
+       int to = 0;
+       hci_switch_role(dd, addr, role, to);
+       ],HAVE_BLUEZ=yes,HAVE_BLUEZ=no)
+if test x$HAVE_BLUEZ != xyes; then
+       AC_MSG_ERROR(bluez-libs 2.11 or better is required to compile btsco)
+fi
+
 AM_PATH_ALSA(1.0.3)
 
 XIPH_PATH_AO
 
 
 
 
-------------------------------------------------------
Quoted 8 lines

SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#9 lore raw
In reply to Bastien Nocera

Guys,

Should we just require bluez-libs 2.11 or use hci_switch_role conditionally? We seem to be very demanding :)

(current kernel, etc)

Brad

Quoted 54 lines · Bastien Nocera
Quoted 2 lines · Marcel Holtmann <marcel <at> holtmann.org> writes:

the bug was also present in the function itself. I have no idea how it slipped into the source. I fixed it with the bluez-libs-2.11 release.

Excellent, here's a patch to btsco to require bluez-libs 2.11.

$ ./configure
<snip
checking for hci_open_dev in -lbluetooth... yes
checking for sdp_connect in -lbluetooth... yes
configure: error: bluez-libs 2.11 or better is required to compile btsco
make: *** [config.status] Error 1
$ grep hci_switch_role config.log
conftest.c:35: error: incompatible type for argument 2 of 'hci_switch_role'
|       hci_switch_role(dd, addr, role, to);

Index: configure.in
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/configure.in,v retrieving revision 1.8
diff -u -r1.8 configure.in

configure.in 17 Jun 2005 11:36:39 -0000 renamed from configure.in 22 Apr 2005 17:17:25 -0000 1.8 +16 -1
@@ -19,6 +19,22 @@
 AC_PROG_RANLIB
 AC_PATH_BLUEZ
 
+AC_TRY_COMPILE([
+       #include <bluetooth/bluetooth.h>
+       #include <sys/socket.h>
+       #include <bluetooth/hci.h>
+       #include <bluetooth/hci_lib.h>
+       ],[
+       bdaddr_t *addr;
+       int dd = 0;
+       int role = 0;
+       int to = 0;
+       hci_switch_role(dd, addr, role, to);
+       ],HAVE_BLUEZ=yes,HAVE_BLUEZ=no)
+if test x$HAVE_BLUEZ != xyes; then
+       AC_MSG_ERROR(bluez-libs 2.11 or better is required to compile btsco)
+fi
+
 AM_PATH_ALSA(1.0.3)
 
 XIPH_PATH_AO
 
 
 
 
-------------------------------------------------------
Quoted 8 lines

SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#10 lore raw
Quoted 3 lines · Brad Midgley

Guys,

Should we just require bluez-libs 2.11 or use hci_switch_role conditionally? We seem to be very demanding :)

Require a library version is a common pratice, I don't see any problem with that.

Pre-Processor conditional compile macros makes your code a bit harder to understand and to mantain, it's not reasonable to do that without a good reason.

Well, my 2 cents. :)

Signature · 12 lines
Luiz Fernando N. Capitulino


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
#6 lore raw
In reply to Brad Midgley

Here's goes patch #3.

It won't yell at you anymore if you have a broken bluez-libs, but will just disable the hci_switch_role call.
Previous fixes also included.

Cheers

PS: Please CC: me on the answer, again :)
---
Bastien Nocera <[email protected]>

Index: a2play.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2play.c,v retrieving revision 1.80

a2play.c +2 -1
diff -u -p -r1.80 a2play.c
@@ -278,7 +278,8 @@ static int do_connect(bdaddr_t *src, bda
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	int sk, opt;
+	int sk;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {

Index: a2recv.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2recv.c,v retrieving revision 1.13

a2recv.c +8 -5
diff -u -p -r1.13 a2recv.c
@@ -152,9 +152,8 @@ static int do_listen(bdaddr_t *src, unsi
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	
 	int sk;
-	int opt;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {
@@ -205,8 +204,8 @@ static int do_accept(int serverfd, bdadd
 	struct l2cap_options opts;
 	socklen_t addrlen;
 	int nsk;
-	int opt;
-	
+	unsigned int opt;
+
 	memset(&addr, 0, sizeof(addr));
 	addrlen = sizeof(addr);
 
@@ -278,10 +277,14 @@ static void make_master(bdaddr_t bdaddr)
 		return;
         }
 
+#ifndef HAVE_NO_HCI_SWITCH_ROLE
+	/* Older versions of bluez-libs got the second argument
+	 * wrong, hci_switch_role is expecting a pointer to
+	 * a bdaddr_t */
         if (hci_switch_role(dd, &bdaddr, role, 10000) < 0) {
                 perror("Switch role request failed");
         }
-
+#endif
         close(dd);
 }
 

Index: btsco.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco.c,v
retrieving revision 1.27

btsco.c +4 -3
diff -u -p -r1.27 btsco.c
@@ -139,7 +139,8 @@ static int sco_connect(bdaddr_t * src, b
 	struct sockaddr_sco addr;
 	struct sco_conninfo conn;
 	struct sco_options opts;
-	int s, size;
+	int s;
+	unsigned int size;
 
 	if ((s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) {
 		return -1;
@@ -443,7 +444,7 @@ int main(int argc, char *argv[])
 	struct sigaction sa;
 
 	//struct timeval timeout;
-	unsigned char buf[2048];
+	char buf[2048];
 	//int sel, rlen, wlen;
 	int rlen, wlen;
 
@@ -640,7 +641,7 @@ int main(int argc, char *argv[])
 			perror("poll");
 			sleep(1); /* Don't steal the CPU in case of non-transient errors. */
 		} else if (ret > 0) {
-			short revents;
+			unsigned short revents;
 
 			/*printf("inner loop\n"); */
 			/* Volume polling (sound card) */

Index: btsco2.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco2.c,v retrieving revision 1.2

btsco2.c +2 -2
diff -u -p -r1.2 btsco2.c
@@ -377,7 +377,7 @@ static int headset_micro(struct s_headse
 
 static int headset_from_bt(struct s_headset *headset)
 {
-	unsigned char buf[2048];
+	char buf[2048];
 	int rlen;
 	int opdone;
 	
@@ -535,7 +535,7 @@ int main(int argc, char *argv[])
 
 	/* we are not yet connected */
 	while (!terminate) {
-		short revents;
+		unsigned short revents;
 		int nfds;
 		nfds = 0;
 		/* set up data polling description */

Index: configure.in
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/configure.in,v retrieving revision 1.8

configure.in +17 -0
diff -u -p -r1.8 configure.in
@@ -19,6 +19,23 @@ AC_PROG_INSTALL
 AC_PROG_RANLIB
 AC_PATH_BLUEZ
 
+AC_TRY_COMPILE([
+	#include <bluetooth/bluetooth.h>
+	#include <sys/socket.h>
+	#include <bluetooth/hci.h>
+	#include <bluetooth/hci_lib.h>
+	],[
+	bdaddr_t *addr;
+	int dd = 0;
+	int role = 0;
+	int to = 0;
+	hci_switch_role(dd, addr, role, to);
+	],HAVE_HCI_SWITCH_ROLE=yes,HAVE_HCI_SWITCH_ROLE=no)
+
+if test x$HAVE_HCI_SWITCH_ROLE != xyes; then
+	AC_DEFINE(HAVE_NO_HCI_SWITCH_ROLE, 1, [defined if hci_switch_role is broken])
+fi
+
 AM_PATH_ALSA(1.0.3)
 
 XIPH_PATH_AO

Index: kernel/Makefile
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/kernel/Makefile,v retrieving revision 1.3

Makefile +3 -3
diff -u -p -r1.3 Makefile
@@ -10,10 +10,10 @@ endif
 
 
 default:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules
 
 install:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules_install
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules_install
 
 clean:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` clean
+	@make -C /lib/modules/`uname -r`/build M=`pwd` clean
Applied
#7 lore raw

thanks, applied. will show up in the anon tree shortly.

Quoted 180 lines · Bastien Nocera

Here's goes patch #3.

It won't yell at you anymore if you have a broken bluez-libs, but will just disable the hci_switch_role call.
Previous fixes also included.

Cheers

PS: Please CC: me on the answer, again :)
---
Bastien Nocera <[email protected]>

------------------------------------------------------------------------

Index: a2play.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2play.c,v retrieving revision 1.80
diff -u -p -r1.80 a2play.c

a2play.c +2 -1
@@ -278,7 +278,8 @@ static int do_connect(bdaddr_t *src, bda
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	int sk, opt;
+	int sk;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {

Index: a2recv.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/a2recv.c,v retrieving revision 1.13
diff -u -p -r1.13 a2recv.c

a2recv.c +8 -5
@@ -152,9 +152,8 @@ static int do_listen(bdaddr_t *src, unsi
 {
 	struct sockaddr_l2 addr;
 	struct l2cap_options opts;
-	
 	int sk;
-	int opt;
+	unsigned int opt;
 
 	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
 	if (sk < 0) {
@@ -205,8 +204,8 @@ static int do_accept(int serverfd, bdadd
 	struct l2cap_options opts;
 	socklen_t addrlen;
 	int nsk;
-	int opt;
-	
+	unsigned int opt;
+
 	memset(&addr, 0, sizeof(addr));
 	addrlen = sizeof(addr);
 
@@ -278,10 +277,14 @@ static void make_master(bdaddr_t bdaddr)
 		return;
         }
 
+#ifndef HAVE_NO_HCI_SWITCH_ROLE
+	/* Older versions of bluez-libs got the second argument
+	 * wrong, hci_switch_role is expecting a pointer to
+	 * a bdaddr_t */
         if (hci_switch_role(dd, &bdaddr, role, 10000) < 0) {
                 perror("Switch role request failed");
         }
-
+#endif
         close(dd);
 }
 

Index: btsco.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco.c,v
retrieving revision 1.27
diff -u -p -r1.27 btsco.c

btsco.c +4 -3
@@ -139,7 +139,8 @@ static int sco_connect(bdaddr_t * src, b
 	struct sockaddr_sco addr;
 	struct sco_conninfo conn;
 	struct sco_options opts;
-	int s, size;
+	int s;
+	unsigned int size;
 
 	if ((s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) {
 		return -1;
@@ -443,7 +444,7 @@ int main(int argc, char *argv[])
 	struct sigaction sa;
 
 	//struct timeval timeout;
-	unsigned char buf[2048];
+	char buf[2048];
 	//int sel, rlen, wlen;
 	int rlen, wlen;
 
@@ -640,7 +641,7 @@ int main(int argc, char *argv[])
 			perror("poll");
 			sleep(1); /* Don't steal the CPU in case of non-transient errors. */
 		} else if (ret > 0) {
-			short revents;
+			unsigned short revents;
 
 			/*printf("inner loop\n"); */
 			/* Volume polling (sound card) */

Index: btsco2.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/btsco2.c,v retrieving revision 1.2
diff -u -p -r1.2 btsco2.c

btsco2.c +2 -2
@@ -377,7 +377,7 @@ static int headset_micro(struct s_headse
 
 static int headset_from_bt(struct s_headset *headset)
 {
-	unsigned char buf[2048];
+	char buf[2048];
 	int rlen;
 	int opdone;
 
@@ -535,7 +535,7 @@ int main(int argc, char *argv[])
 
 	/* we are not yet connected */
 	while (!terminate) {
-		short revents;
+		unsigned short revents;
 		int nfds;
 		nfds = 0;
 		/* set up data polling description */

Index: configure.in
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/configure.in,v retrieving revision 1.8
diff -u -p -r1.8 configure.in

configure.in +17 -0
@@ -19,6 +19,23 @@ AC_PROG_INSTALL
 AC_PROG_RANLIB
 AC_PATH_BLUEZ
 
+AC_TRY_COMPILE([
+	#include <bluetooth/bluetooth.h>
+	#include <sys/socket.h>
+	#include <bluetooth/hci.h>
+	#include <bluetooth/hci_lib.h>
+	],[
+	bdaddr_t *addr;
+	int dd = 0;
+	int role = 0;
+	int to = 0;
+	hci_switch_role(dd, addr, role, to);
+	],HAVE_HCI_SWITCH_ROLE=yes,HAVE_HCI_SWITCH_ROLE=no)
+
+if test x$HAVE_HCI_SWITCH_ROLE != xyes; then
+	AC_DEFINE(HAVE_NO_HCI_SWITCH_ROLE, 1, [defined if hci_switch_role is broken])
+fi
+
 AM_PATH_ALSA(1.0.3)
 
 XIPH_PATH_AO

Index: kernel/Makefile
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/kernel/Makefile,v retrieving revision 1.3
diff -u -p -r1.3 Makefile

Makefile +0 -0
@@ -10,10 +10,10 @@ endif
 
 
 default:

Makefile endif · line 19

Quoted 10 lines
Makefile +3 -3
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules
 
 install:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` modules_install
+	@make -C /lib/modules/`uname -r`/build M=`pwd` modules_install
 
 clean:
-	@make -C /lib/modules/`uname -r`/source M=`pwd` clean
+	@make -C /lib/modules/`uname -r`/build M=`pwd` clean

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#8 lore raw
Quoted 1 line · Brad Midgley

thanks, applied. will show up in the anon tree shortly.

Excellent, thanks very much.

---
Bastien Nocera <[email protected]>

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel