* [PATCH] android/client: Fix incorrect casts of addresses @ 2013-10-25 8:51 Jerzy Kasenberg 2013-10-25 9:32 ` Andrei Emeltchenko 0 siblings, 1 reply; 5+ messages in thread From: Jerzy Kasenberg @ 2013-10-25 8:51 UTC (permalink / raw) To: linux-bluetooth; +Cc: Jerzy Kasenberg This fixes printing of addresses. If char is set to be signed (as it should) some addresses were printed with leading FFFFFF. --- This issue did not showed up before due to unsigned char for Android build on Qualcomm platform. android/client/textconv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/client/textconv.c b/android/client/textconv.c index 1188477..bcdf4d9 100644 --- a/android/client/textconv.c +++ b/android/client/textconv.c @@ -137,7 +137,7 @@ int int2str_findstr(const char *str, const struct int2str m[]) */ char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) { - const char *p = (const char *) bd_addr; + const uint8_t *p = bd_addr->address; snprintf(buf, MAX_ADDR_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", p[0], p[1], p[2], p[3], p[4], p[5]); @@ -148,7 +148,7 @@ char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) /* converts string to bt_bdaddr_t */ void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr) { - char *p = (char *) bd_addr; + uint8_t *p = bd_addr->address; sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5]); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] android/client: Fix incorrect casts of addresses 2013-10-25 8:51 [PATCH] android/client: Fix incorrect casts of addresses Jerzy Kasenberg @ 2013-10-25 9:32 ` Andrei Emeltchenko 2013-10-25 9:50 ` Jerzy Kasenberg 0 siblings, 1 reply; 5+ messages in thread From: Andrei Emeltchenko @ 2013-10-25 9:32 UTC (permalink / raw) To: Jerzy Kasenberg; +Cc: linux-bluetooth Hi Jerzy, On Fri, Oct 25, 2013 at 10:51:10AM +0200, Jerzy Kasenberg wrote: > This fixes printing of addresses. > If char is set to be signed (as it should) some addresses were > printed with leading FFFFFF. > --- > This issue did not showed up before due to unsigned char for Android build > on Qualcomm platform. > > android/client/textconv.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/android/client/textconv.c b/android/client/textconv.c > index 1188477..bcdf4d9 100644 > --- a/android/client/textconv.c > +++ b/android/client/textconv.c > @@ -137,7 +137,7 @@ int int2str_findstr(const char *str, const struct int2str m[]) > */ > char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) > { > - const char *p = (const char *) bd_addr; > + const uint8_t *p = bd_addr->address; > > snprintf(buf, MAX_ADDR_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", > p[0], p[1], p[2], p[3], p[4], p[5]); is this correct order btw? Best regards Andrei Emeltchenko > @@ -148,7 +148,7 @@ char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) > /* converts string to bt_bdaddr_t */ > void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr) > { > - char *p = (char *) bd_addr; > + uint8_t *p = bd_addr->address; > > sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", > &p[0], &p[1], &p[2], &p[3], &p[4], &p[5]); > -- > 1.7.9.5 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] android/client: Fix incorrect casts of addresses 2013-10-25 9:32 ` Andrei Emeltchenko @ 2013-10-25 9:50 ` Jerzy Kasenberg 2013-10-25 10:08 ` Andrei Emeltchenko 0 siblings, 1 reply; 5+ messages in thread From: Jerzy Kasenberg @ 2013-10-25 9:50 UTC (permalink / raw) To: Andrei Emeltchenko, Jerzy Kasenberg, linux-bluetooth Hi Andrei, On 25 October 2013 11:32, Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com> wrote: > Hi Jerzy, > > On Fri, Oct 25, 2013 at 10:51:10AM +0200, Jerzy Kasenberg wrote: >> This fixes printing of addresses. >> If char is set to be signed (as it should) some addresses were >> printed with leading FFFFFF. >> --- >> This issue did not showed up before due to unsigned char for Android build >> on Qualcomm platform. >> >> android/client/textconv.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/android/client/textconv.c b/android/client/textconv.c >> index 1188477..bcdf4d9 100644 >> --- a/android/client/textconv.c >> +++ b/android/client/textconv.c >> @@ -137,7 +137,7 @@ int int2str_findstr(const char *str, const struct int2str m[]) >> */ >> char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) >> { >> - const char *p = (const char *) bd_addr; >> + const uint8_t *p = bd_addr->address; >> >> snprintf(buf, MAX_ADDR_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", >> p[0], p[1], p[2], p[3], p[4], p[5]); > > is this correct order btw? Tool print same address for my mouse as I see printed on the mouse so I guess it's correct. > > Best regards > Andrei Emeltchenko > >> @@ -148,7 +148,7 @@ char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) >> /* converts string to bt_bdaddr_t */ >> void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr) >> { >> - char *p = (char *) bd_addr; >> + uint8_t *p = bd_addr->address; >> >> sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", >> &p[0], &p[1], &p[2], &p[3], &p[4], &p[5]); >> -- >> 1.7.9.5 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html -- Best regards Jerzy ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] android/client: Fix incorrect casts of addresses 2013-10-25 9:50 ` Jerzy Kasenberg @ 2013-10-25 10:08 ` Andrei Emeltchenko 2013-10-25 10:34 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 5+ messages in thread From: Andrei Emeltchenko @ 2013-10-25 10:08 UTC (permalink / raw) To: Jerzy Kasenberg; +Cc: linux-bluetooth Hi Jerzy, On Fri, Oct 25, 2013 at 11:50:22AM +0200, Jerzy Kasenberg wrote: > Hi Andrei, > > On 25 October 2013 11:32, Andrei Emeltchenko > <andrei.emeltchenko.news@gmail.com> wrote: > > Hi Jerzy, > > > > On Fri, Oct 25, 2013 at 10:51:10AM +0200, Jerzy Kasenberg wrote: > >> This fixes printing of addresses. > >> If char is set to be signed (as it should) some addresses were > >> printed with leading FFFFFF. > >> --- > >> This issue did not showed up before due to unsigned char for Android build > >> on Qualcomm platform. > >> > >> android/client/textconv.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/android/client/textconv.c b/android/client/textconv.c > >> index 1188477..bcdf4d9 100644 > >> --- a/android/client/textconv.c > >> +++ b/android/client/textconv.c > >> @@ -137,7 +137,7 @@ int int2str_findstr(const char *str, const struct int2str m[]) > >> */ > >> char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) > >> { > >> - const char *p = (const char *) bd_addr; > >> + const uint8_t *p = bd_addr->address; > >> > >> snprintf(buf, MAX_ADDR_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", > >> p[0], p[1], p[2], p[3], p[4], p[5]); > > > > is this correct order btw? > > Tool print same address for my mouse as I see printed on the mouse so > I guess it's correct. OK, those are addresses sent through HAL, they are in different format. Best regards Andrei Emeltchenko > > > > > Best regards > > Andrei Emeltchenko > > > >> @@ -148,7 +148,7 @@ char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) > >> /* converts string to bt_bdaddr_t */ > >> void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr) > >> { > >> - char *p = (char *) bd_addr; > >> + uint8_t *p = bd_addr->address; > >> > >> sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", > >> &p[0], &p[1], &p[2], &p[3], &p[4], &p[5]); > >> -- > >> 1.7.9.5 > >> > >> -- > >> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in > >> the body of a message to majordomo@vger.kernel.org > >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- > Best regards > Jerzy ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] android/client: Fix incorrect casts of addresses 2013-10-25 10:08 ` Andrei Emeltchenko @ 2013-10-25 10:34 ` Luiz Augusto von Dentz 0 siblings, 0 replies; 5+ messages in thread From: Luiz Augusto von Dentz @ 2013-10-25 10:34 UTC (permalink / raw) To: Andrei Emeltchenko, Jerzy Kasenberg, linux-bluetooth@vger.kernel.org Hi Jerzy, On Fri, Oct 25, 2013 at 1:08 PM, Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com> wrote: > Hi Jerzy, > > On Fri, Oct 25, 2013 at 11:50:22AM +0200, Jerzy Kasenberg wrote: >> Hi Andrei, >> >> On 25 October 2013 11:32, Andrei Emeltchenko >> <andrei.emeltchenko.news@gmail.com> wrote: >> > Hi Jerzy, >> > >> > On Fri, Oct 25, 2013 at 10:51:10AM +0200, Jerzy Kasenberg wrote: >> >> This fixes printing of addresses. >> >> If char is set to be signed (as it should) some addresses were >> >> printed with leading FFFFFF. >> >> --- >> >> This issue did not showed up before due to unsigned char for Android build >> >> on Qualcomm platform. >> >> >> >> android/client/textconv.c | 4 ++-- >> >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> >> >> diff --git a/android/client/textconv.c b/android/client/textconv.c >> >> index 1188477..bcdf4d9 100644 >> >> --- a/android/client/textconv.c >> >> +++ b/android/client/textconv.c >> >> @@ -137,7 +137,7 @@ int int2str_findstr(const char *str, const struct int2str m[]) >> >> */ >> >> char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) >> >> { >> >> - const char *p = (const char *) bd_addr; >> >> + const uint8_t *p = bd_addr->address; >> >> >> >> snprintf(buf, MAX_ADDR_STR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", >> >> p[0], p[1], p[2], p[3], p[4], p[5]); >> > >> > is this correct order btw? >> >> Tool print same address for my mouse as I see printed on the mouse so >> I guess it's correct. > > OK, those are addresses sent through HAL, they are in different format. > > Best regards > Andrei Emeltchenko > >> >> > >> > Best regards >> > Andrei Emeltchenko >> > >> >> @@ -148,7 +148,7 @@ char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf) >> >> /* converts string to bt_bdaddr_t */ >> >> void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr) >> >> { >> >> - char *p = (char *) bd_addr; >> >> + uint8_t *p = bd_addr->address; >> >> >> >> sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", >> >> &p[0], &p[1], &p[2], &p[3], &p[4], &p[5]); >> >> -- >> >> 1.7.9.5 >> >> >> >> -- >> >> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in >> >> the body of a message to majordomo@vger.kernel.org >> >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> -- >> Best regards >> Jerzy > -- Applied, please rebase since I had done a code style fix since str2bt_bdaddr_t was mixing spaces with tabs. -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-25 10:34 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-10-25 8:51 [PATCH] android/client: Fix incorrect casts of addresses Jerzy Kasenberg 2013-10-25 9:32 ` Andrei Emeltchenko 2013-10-25 9:50 ` Jerzy Kasenberg 2013-10-25 10:08 ` Andrei Emeltchenko 2013-10-25 10:34 ` Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox