[PATCH BlueZ 08/11] attrib: Remove unnecessary local variables from dec_find_by_type_req()

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

 



Use number instead of "min_len", which is easier to review (with help of
the documented parameter sizes).

valuelen is redundant as *vlen can be used directly.
---
 attrib/att.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/attrib/att.c b/attrib/att.c
index 435a26d..d367918 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -281,14 +281,10 @@ uint16_t dec_find_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
 						uint16_t *end, bt_uuid_t *uuid,
 						uint8_t *value, size_t *vlen)
 {
-	size_t valuelen;
-	uint16_t min_len = sizeof(pdu[0]) + sizeof(*start) +
-						sizeof(*end) + sizeof(uint16_t);
-
 	if (pdu == NULL)
 		return 0;
 
-	if (len < min_len)
+	if (len < 7)
 		return 0;
 
 	/* Attribute Opcode (1 octet) */
@@ -302,12 +298,10 @@ uint16_t dec_find_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
 	/* 16-bit UUID to find (2 octets) */
 	*uuid = att_get_uuid16(&pdu[5]);
 
-	valuelen = len - min_len;
-	*vlen = valuelen;
-
 	/* Attribute value to find */
-	if (valuelen > 0)
-		memcpy(value, pdu + min_len, valuelen);
+	*vlen = len - 7;
+	if (*vlen > 0)
+		memcpy(value, pdu + 7, *vlen);
 
 	return len;
 }
-- 
1.8.3.2

--
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