[PATCH 3/4] android/avrcp: Fix PDU length calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 android/avrcp.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/android/avrcp.c b/android/avrcp.c
index a763b88..e428486 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -167,25 +167,28 @@ static void handle_get_player_values_text(const void *buf, uint16_t len)
 			HAL_OP_AVRCP_GET_PLAYER_VALUES_TEXT, HAL_STATUS_FAILED);
 }
 
-static void write_element_text(uint8_t id, uint8_t text_len, uint8_t *text,
-						uint8_t *pdu, size_t *len)
+static size_t write_element_text(uint8_t id, uint8_t text_len, uint8_t *text,
+						uint8_t *pdu)
 {
 	uint16_t charset = 106;
+	size_t len = 0;
 
 	bt_put_be32(id, pdu);
 	pdu += 4;
-	*len += 4;
+	len += 4;
 
 	bt_put_be16(charset, pdu);
 	pdu += 2;
-	*len += 2;
+	len += 2;
 
 	bt_put_be16(text_len, pdu);
 	pdu += 2;
-	*len += 2;
+	len += 2;
 
 	memcpy(pdu, text, text_len);
-	*len += text_len;
+	len += text_len;
+
+	return len;
 }
 
 static void write_element_attrs(uint8_t *ptr, uint8_t number, uint8_t *pdu,
@@ -199,11 +202,13 @@ static void write_element_attrs(uint8_t *ptr, uint8_t number, uint8_t *pdu,
 
 	for (i = 0; i < number; i++) {
 		struct hal_avrcp_player_setting_text *text = (void *) ptr;
+		size_t ret;
 
-		write_element_text(text->id, text->len, text->text, pdu, len);
+		ret = write_element_text(text->id, text->len, text->text, pdu);
 
 		ptr += sizeof(*text) + text->len;
-		pdu += *len;
+		pdu += ret;
+		*len += ret;
 	}
 }
 
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux