From: Johan Hedberg Date: Mon, 26 Mar 2012 11:21:41 +0000 (+0300) Subject: Bluetooth: Don't increment twice in eir_has_data_type() X-Git-Tag: next-20120402~35^2~8 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2ac980970d78de43dcfa9a111d9b43d339db062d;p=karo-tx-linux.git Bluetooth: Don't increment twice in eir_has_data_type() 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 Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo Padovan --- diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 8dc07fa49fa1..83cd30182118 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -911,11 +911,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;