]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Bluetooth: hci_le_adv_report_evt code refactoring
authorAndre Guedes <andre.guedes@openbossa.org>
Mon, 26 Sep 2011 23:48:35 +0000 (20:48 -0300)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 29 Sep 2011 18:25:08 +0000 (15:25 -0300)
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>
net/bluetooth/hci_event.c

index 7390ba9d4f6eeecc54495844dba2dee7b0aa9fad..d7d96b6b1f0d63b338e5ed58fb125fbc6290aff5 100644 (file)
@@ -2838,19 +2838,17 @@ unlock:
 static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
                                                struct sk_buff *skb)
 {
-       struct hci_ev_le_advertising_info *ev;
-       u8 num_reports;
-
-       num_reports = skb->data[0];
-       ev = (void *) &skb->data[1];
+       u8 num_reports = skb->data[0];
+       void *ptr = &skb->data[1];
 
        hci_dev_lock(hdev);
 
-       hci_add_adv_entry(hdev, ev);
+       while (num_reports--) {
+               struct hci_ev_le_advertising_info *ev = ptr;
 
-       while (--num_reports) {
-               ev = (void *) (ev->data + ev->length + 1);
                hci_add_adv_entry(hdev, ev);
+
+               ptr += sizeof(*ev) + ev->length + 1;
        }
 
        hci_dev_unlock(hdev);