All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/3] SDP build warning and EIR parsing
@ 2012-04-16 13:01 Syam Sidhardhan
  2012-04-16 13:01 ` [PATCH BlueZ 1/3] sdp: Fix compilation warning due to data type mismatch Syam Sidhardhan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Syam Sidhardhan @ 2012-04-16 13:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Syam Sidhardhan

This patchset is sending as per my discussion with Johan over the IRC#bluez.
The first patch is: While building the code with the maintainer mode enable,
is throwing warning and further it leads to a build break in different cross
compilation environment.

The second and third patch is related to the EIR parsing.
Since the eir_length() parsing return value is incorrect, we are appending
the COD at incorrect location. As a result, while retrieving back we are
unable to get the COD back during emiting device found signal during discovery.

The same fix is required in the eir_has_data_type() aswell.



Syam Sidhardhan (3):
  sdp: Fix compilation warning due to data type mismatch
  eir: Fix incorrect eir_length() parsing
  eir: Fix incorrect eir_has_data_type() parsing

 lib/sdp.c |    2 +-
 src/eir.c |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 1/3] sdp: Fix compilation warning due to data type mismatch
  2012-04-16 13:01 [PATCH BlueZ 0/3] SDP build warning and EIR parsing Syam Sidhardhan
@ 2012-04-16 13:01 ` Syam Sidhardhan
  2012-04-16 13:01 ` [PATCH BlueZ 2/3] eir: Fix incorrect eir_length() parsing Syam Sidhardhan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Syam Sidhardhan @ 2012-04-16 13:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Syam Sidhardhan

In certain cross compiling environment, if we build the code with
enabling the maintainer mode, the following error happens.

cc1: warnings being treated as errors
lib/sdp.c: In function 'sdp_process':
lib/sdp.c:4111:6: error: comparison between signed and unsigned integer
expressions
make[2]: *** [lib/sdp.lo] Error 1
make[1]: *** [all] Error 2
---
 lib/sdp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/sdp.c b/lib/sdp.c
index eaf8d00..81e328e 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -4108,7 +4108,7 @@ int sdp_process(sdp_session_t *session)
 	}
 
 	if (n == 0 || reqhdr->tid != rsphdr->tid ||
-		(n != (ntohs(rsphdr->plen) + (int) sizeof(sdp_pdu_hdr_t)))) {
+		(n != (int) (ntohs(rsphdr->plen) + sizeof(sdp_pdu_hdr_t)))) {
 		t->err = EPROTO;
 		SDPERR("Protocol error.");
 		goto end;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 2/3] eir: Fix incorrect eir_length() parsing
  2012-04-16 13:01 [PATCH BlueZ 0/3] SDP build warning and EIR parsing Syam Sidhardhan
  2012-04-16 13:01 ` [PATCH BlueZ 1/3] sdp: Fix compilation warning due to data type mismatch Syam Sidhardhan
@ 2012-04-16 13:01 ` Syam Sidhardhan
  2012-04-16 13:01 ` [PATCH BlueZ 3/3] eir: Fix incorrect eir_has_data_type() parsing Syam Sidhardhan
  2012-04-16 19:56 ` [PATCH BlueZ 0/3] SDP build warning and EIR parsing Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Syam Sidhardhan @ 2012-04-16 13:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Syam Sidhardhan

Issue:
The COD value displayed via dbus during inquiry is wrong.
This is because of the incorrect return length of the eir_length(),
which leads to appending the COD at wrong location.

Analysis:
After appending the COD at the end of the eir data, we can see
there are some '00' present in the eir field length in the eir file.
XX:XX:XX:XX:XX:XX 07095359414D5043020A040B0312111F110C110E110311
0000000000000000000000040D000142

Fix:
Corrected the length calculation in eir_length(), which is determining,
which position the COD should append
---
 src/eir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index 7b7b705..d622b08 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -379,9 +379,9 @@ size_t eir_append_data(uint8_t *eir, size_t eir_len, uint8_t type,
 size_t eir_length(uint8_t *eir, size_t maxlen)
 {
 	uint8_t field_len;
-	size_t parsed, length;
+	size_t parsed = 0, length = 0;
 
-	for (parsed = 0, length = 0; parsed < maxlen - 1; parsed += field_len) {
+	while (parsed < maxlen - 1) {
 		field_len = eir[0];
 
 		if (field_len == 0)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 3/3] eir: Fix incorrect eir_has_data_type() parsing
  2012-04-16 13:01 [PATCH BlueZ 0/3] SDP build warning and EIR parsing Syam Sidhardhan
  2012-04-16 13:01 ` [PATCH BlueZ 1/3] sdp: Fix compilation warning due to data type mismatch Syam Sidhardhan
  2012-04-16 13:01 ` [PATCH BlueZ 2/3] eir: Fix incorrect eir_length() parsing Syam Sidhardhan
@ 2012-04-16 13:01 ` Syam Sidhardhan
  2012-04-16 19:56 ` [PATCH BlueZ 0/3] SDP build warning and EIR parsing Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Syam Sidhardhan @ 2012-04-16 13:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Syam Sidhardhan

Updating the "parsed" variable twice inside the for loop, leads to
incorrect parsing.
---
 src/eir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index d622b08..cdf3e8f 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -343,9 +343,9 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 gboolean eir_has_data_type(uint8_t *data, size_t len, uint8_t type)
 {
 	uint8_t field_len;
-	size_t parsed;
+	size_t parsed = 0;
 
-	for (parsed = 0; parsed < len - 1; parsed += field_len) {
+	while (parsed < len - 1) {
 		field_len = data[0];
 
 		if (field_len == 0)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ 0/3] SDP build warning and EIR parsing
  2012-04-16 13:01 [PATCH BlueZ 0/3] SDP build warning and EIR parsing Syam Sidhardhan
                   ` (2 preceding siblings ...)
  2012-04-16 13:01 ` [PATCH BlueZ 3/3] eir: Fix incorrect eir_has_data_type() parsing Syam Sidhardhan
@ 2012-04-16 19:56 ` Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2012-04-16 19:56 UTC (permalink / raw)
  To: Syam Sidhardhan; +Cc: linux-bluetooth

Hi Syam,

On Mon, Apr 16, 2012, Syam Sidhardhan wrote:
> This patchset is sending as per my discussion with Johan over the IRC#bluez.
> The first patch is: While building the code with the maintainer mode enable,
> is throwing warning and further it leads to a build break in different cross
> compilation environment.
> 
> The second and third patch is related to the EIR parsing.
> Since the eir_length() parsing return value is incorrect, we are appending
> the COD at incorrect location. As a result, while retrieving back we are
> unable to get the COD back during emiting device found signal during discovery.
> 
> The same fix is required in the eir_has_data_type() aswell.
> 
> Syam Sidhardhan (3):
>   sdp: Fix compilation warning due to data type mismatch
>   eir: Fix incorrect eir_length() parsing
>   eir: Fix incorrect eir_has_data_type() parsing
> 
>  lib/sdp.c |    2 +-
>  src/eir.c |    8 ++++----
>  2 files changed, 5 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-16 19:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-16 13:01 [PATCH BlueZ 0/3] SDP build warning and EIR parsing Syam Sidhardhan
2012-04-16 13:01 ` [PATCH BlueZ 1/3] sdp: Fix compilation warning due to data type mismatch Syam Sidhardhan
2012-04-16 13:01 ` [PATCH BlueZ 2/3] eir: Fix incorrect eir_length() parsing Syam Sidhardhan
2012-04-16 13:01 ` [PATCH BlueZ 3/3] eir: Fix incorrect eir_has_data_type() parsing Syam Sidhardhan
2012-04-16 19:56 ` [PATCH BlueZ 0/3] SDP build warning and EIR parsing Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.