* PATCH [1/2] batostr(): Switch byte order before converting
@ 2011-02-16 13:07 David Herrmann
2011-02-17 19:04 ` Johan Hedberg
0 siblings, 1 reply; 3+ messages in thread
From: David Herrmann @ 2011-02-16 13:07 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 826 bytes --]
The library function batostr() computes incorrect results because it
does not swap byte-ordering before converting the address. This patch
fixes this behaviour. It tries to make batostr() look like ba2str() to
be consistent.
Patch is also attached as x-patch file. Patch is done against most
recent git version.
diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index 4af2ef6..dd7ca06 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -50,13 +50,14 @@ void baswap(bdaddr_t *dst, const bdaddr_t *src)
char *batostr(const bdaddr_t *ba)
{
+ uint8_t b[6];
char *str = bt_malloc(18);
if (!str)
return NULL;
+ baswap((bdaddr_t *) b, ba);
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]);
+ b[0], b[1], b[2], b[3], b[4], b[5]);
return str;
}
[-- Attachment #2: bluez1.diff --]
[-- Type: text/x-patch, Size: 514 bytes --]
diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index 4af2ef6..dd7ca06 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -50,13 +50,14 @@ void baswap(bdaddr_t *dst, const bdaddr_t *src)
char *batostr(const bdaddr_t *ba)
{
+ uint8_t b[6];
char *str = bt_malloc(18);
if (!str)
return NULL;
+ baswap((bdaddr_t *) b, ba);
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]);
+ b[0], b[1], b[2], b[3], b[4], b[5]);
return str;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: PATCH [1/2] batostr(): Switch byte order before converting
2011-02-16 13:07 PATCH [1/2] batostr(): Switch byte order before converting David Herrmann
@ 2011-02-17 19:04 ` Johan Hedberg
2011-02-17 23:10 ` David Herrmann
0 siblings, 1 reply; 3+ messages in thread
From: Johan Hedberg @ 2011-02-17 19:04 UTC (permalink / raw)
To: David Herrmann; +Cc: linux-bluetooth
Hi David,
On Wed, Feb 16, 2011, David Herrmann wrote:
> The library function batostr() computes incorrect results because it
> does not swap byte-ordering before converting the address. This patch
> fixes this behaviour. It tries to make batostr() look like ba2str() to
> be consistent.
We can't go ahead and change the behavior of existing libbluetooth
functions like that since it would break any applications relying on the
old behavior (without baswap). So this patch isn't acceptable upstream.
Johan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH [1/2] batostr(): Switch byte order before converting
2011-02-17 19:04 ` Johan Hedberg
@ 2011-02-17 23:10 ` David Herrmann
0 siblings, 0 replies; 3+ messages in thread
From: David Herrmann @ 2011-02-17 23:10 UTC (permalink / raw)
To: David Herrmann, linux-bluetooth
Hi Johan,
On Thu, Feb 17, 2011 at 8:04 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> We can't go ahead and change the behavior of existing libbluetooth
> functions like that since it would break any applications relying on the
> old behavior (without baswap). So this patch isn't acceptable upstream.
I thought of this more like a bug because it doesn't make sense to me
why there should be a function returning the string without swapping
the bytes first. So I didn't think of this as breaking the API, but
more like fixing a function that is not used because it produces
incorrect results.
Anyway, your explanation makes sense and I don't use this function so
I am totally ok with that.
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-17 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-16 13:07 PATCH [1/2] batostr(): Switch byte order before converting David Herrmann
2011-02-17 19:04 ` Johan Hedberg
2011-02-17 23:10 ` David Herrmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox