This code in irmc_bluetooth.c isn't endian safe. On a PowerPC it was
searching over 16 million devices on the piconet.

  94   if (!sdp_general_inquiry(ii, 10, 10000, (uint8_t*)&numfound))  
  (gdb) next
  ...
  (gdb) print numfound
  $25 = 16777216.

The search effectively never finishes and the list remains empty.

Simple patch fixes the problem. Search now correctly detects my Sony
T360 using LinuxPPC. Syncing with Evolution works beaut. 

One last point, after adding the patch I notice that numfound is not
equal to 1 but is equal to '1' (aka 0x31).

  (gdb) print numfound
  $1 = 49 '1'

Maybe that's a libbluetooth bug? Anyway, doesn't hurt, it takes mere
seconds to scan through 48 non-existent devices.

--- plugins/irmc_sync/src/irmc_bluetooth.c.orig	2005-05-12 23:40:54.000000000 +1000
+++ plugins/irmc_sync/src/irmc_bluetooth.c	2005-05-12 23:41:25.000000000 +1000
@@ -90,10 +90,10 @@
 GList *find_bt_units() {
   GList *unitlist = NULL;
   inquiry_info ii[10];
-  int numfound = 0;
-  if (!sdp_general_inquiry(ii, 10, 10000, (uint8_t*)&numfound)) {
+  uint8_t numfound = 0;
+  if (!sdp_general_inquiry(ii, 10, 10000, &numfound)) {
     int t;
-    for (t = 0; t < numfound; t++) {
+    for (t = 0; t < (int) numfound; t++) {
       bdaddr_t tmp;
       int retries = 3;
       irmc_bt_unit *irbt = g_malloc0(sizeof(irmc_bt_unit));

Reply via email to