]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Bluetooth: Don't increment twice in eir_has_data_type()
authorJohan Hedberg <johan.hedberg@intel.com>
Mon, 26 Mar 2012 11:21:41 +0000 (14:21 +0300)
committerGustavo Padovan <gustavo@padovan.org>
Wed, 28 Mar 2012 15:02:40 +0000 (12:02 -0300)
The parsed variable is already incremented inside the for-loop so there
no need to increment it again (not to mention that the code was
incrementing it the wrong amount).

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
include/net/bluetooth/hci_core.h

index 8e103281a09b15702875dde2dd9cc291d7f3de19..220d8e0a75fb3e69ccd3b06b88374939c517fd9c 100644 (file)
@@ -907,11 +907,10 @@ static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
 
 static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
 {
-       u8 field_len;
-       size_t parsed;
+       size_t parsed = 0;
 
-       for (parsed = 0; parsed < data_len - 1; parsed += field_len) {
-               field_len = data[0];
+       while (parsed < data_len - 1) {
+               u8 field_len = data[0];
 
                if (field_len == 0)
                        break;