Skip to content

Commit e95beb4

Browse files
Andre GuedesGustavo F. Padovan
authored andcommitted
Bluetooth: hci_le_adv_report_evt code refactoring
There is no reason to treat the first advertising entry differently from the potential other ones. Besides, the current implementation can easily leads to typos. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent b6f9804 commit e95beb4

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎net/bluetooth/hci_event.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,19 +2838,17 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff
28382838
static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
28392839
struct sk_buff *skb)
28402840
{
2841-
struct hci_ev_le_advertising_info *ev;
2842-
u8 num_reports;
2843-
2844-
num_reports = skb->data[0];
2845-
ev = (void *) &skb->data[1];
2841+
u8 num_reports = skb->data[0];
2842+
void *ptr = &skb->data[1];
28462843

28472844
hci_dev_lock(hdev);
28482845

2849-
hci_add_adv_entry(hdev, ev);
2846+
while (num_reports--) {
2847+
struct hci_ev_le_advertising_info *ev = ptr;
28502848

2851-
while (--num_reports) {
2852-
ev = (void *) (ev->data + ev->length + 1);
28532849
hci_add_adv_entry(hdev, ev);
2850+
2851+
ptr += sizeof(*ev) + ev->length + 1;
28542852
}
28552853

28562854
hci_dev_unlock(hdev);

0 commit comments

Comments
 (0)