2011-09-14 15:46:19

by Antonio Ospite

[permalink] [raw]
Subject: [PATCH BlueZ] Fix batostr(): return the bdaddr in the right order

lib/bluetooth.c::batostr() is returning the bdaddr reversed, fix this
and put more arguments on the same line to look more like ba2str().
---
lib/bluetooth.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index db7bbe1..8509620 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -55,8 +55,7 @@ char *batostr(const bdaddr_t *ba)
return NULL;

sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- ba->b[0], ba->b[1], ba->b[2],
- ba->b[3], ba->b[4], ba->b[5]);
+ ba->b[5], ba->b[4], ba->b[3], ba->b[2], ba->b[1], ba->b[0]);

return str;
}
--
1.7.5.4



2011-09-19 11:14:09

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH BlueZ] Fix batostr(): return the bdaddr in the right order

Hi Antonio,

> > > > lib/bluetooth.c::batostr() is returning the bdaddr reversed, fix this
> > > > and put more arguments on the same line to look more like ba2str().
> > >
> > > this would be breaking existing API. So NAK.
> > >
> >
> > OK, but it is still weird that batostr() and ba2str() work differently.
> > batostr() has no in-tree user AFAICS, just FYI.
> >
>
> Would a batostr_bis() which behaves more like ba2str() wrt. bdaddr
> ordering be accepted, or do I just duplicate the code in my function?

just simply use ba2str. With batostr you have potential side effects
with the lifetime of the return memory anyway. That is also the reason
why none of the official BlueZ utilities or the daemon uses it.

Regards

Marcel



2011-09-19 11:02:00

by Antonio Ospite

[permalink] [raw]
Subject: Re: [PATCH BlueZ] Fix batostr(): return the bdaddr in the right order

On Wed, 14 Sep 2011 21:08:12 +0200
Antonio Ospite <[email protected]> wrote:

> On Wed, 14 Sep 2011 19:53:45 +0200
> Marcel Holtmann <[email protected]> wrote:
>
> > Hi Antonio,
> >
> > > lib/bluetooth.c::batostr() is returning the bdaddr reversed, fix this
> > > and put more arguments on the same line to look more like ba2str().
> >
> > this would be breaking existing API. So NAK.
> >
>
> OK, but it is still weird that batostr() and ba2str() work differently.
> batostr() has no in-tree user AFAICS, just FYI.
>

Would a batostr_bis() which behaves more like ba2str() wrt. bdaddr
ordering be accepted, or do I just duplicate the code in my function?

Thanks,
Antonio

--
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?


Attachments:
(No filename) (916.00 B)
(No filename) (198.00 B)
Download all attachments

2011-09-14 19:08:12

by Antonio Ospite

[permalink] [raw]
Subject: Re: [PATCH BlueZ] Fix batostr(): return the bdaddr in the right order

On Wed, 14 Sep 2011 19:53:45 +0200
Marcel Holtmann <[email protected]> wrote:

> Hi Antonio,
>
> > lib/bluetooth.c::batostr() is returning the bdaddr reversed, fix this
> > and put more arguments on the same line to look more like ba2str().
>
> this would be breaking existing API. So NAK.
>

OK, but it is still weird that batostr() and ba2str() work differently.
batostr() has no in-tree user AFAICS, just FYI.

Regards,
Antonio

--
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?


Attachments:
(No filename) (665.00 B)
(No filename) (198.00 B)
Download all attachments

2011-09-14 17:53:45

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH BlueZ] Fix batostr(): return the bdaddr in the right order

Hi Antonio,

> lib/bluetooth.c::batostr() is returning the bdaddr reversed, fix this
> and put more arguments on the same line to look more like ba2str().

this would be breaking existing API. So NAK.

Regards

Marcel