Re: patch for irmc bluetooth on linuxppc

Armin Bauer <[email protected]> Thu, 12 May 2005 16:19:42 +0200
Newsgroups gmane.comp.gnome.apps.multisync.devel
Message-ID <[email protected]>
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigB11CB576FD48DC1C4FD83C91
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit



Nathan Hand wrote:
> 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.
>

Thanks for your patch!

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

Maybe it just always returns the result of this inquiry as a string so
we should do a atoi to get the correct integer... i think we should
check this before commiting the patch since i would consider 48 false
scans a pretty bad bug.

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

--------------enigB11CB576FD48DC1C4FD83C91
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCg2YAq9z7v9k9UakRAt3eAJ40irJfYzhll8R7LrldrrLwDWI2EgCfclGX
9vEdKSy8p62qOviZdo4H3NM=
=klnm
-----END PGP SIGNATURE-----

--------------enigB11CB576FD48DC1C4FD83C91--


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click