Bluetooth: hci_core: Prefer array indexing over pointer arithmetic
authorErick Archer <erick.archer@outlook.com>
Sat, 18 May 2024 08:30:39 +0000 (10:30 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 15 Jul 2024 01:33:30 +0000 (21:33 -0400)
Refactor the list_for_each_entry() loop of hci_get_dev_list()
function to use array indexing instead of pointer arithmetic.

This way, the code is more readable and idiomatic.

Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Erick Archer <erick.archer@outlook.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_core.c

index a2cad8a..55bdc36 100644 (file)
@@ -828,8 +828,8 @@ int hci_get_dev_list(void __user *arg)
                if (hci_dev_test_flag(hdev, HCI_AUTO_OFF))
                        flags &= ~BIT(HCI_UP);
 
-               (dr + n)->dev_id  = hdev->id;
-               (dr + n)->dev_opt = flags;
+               dr[n].dev_id  = hdev->id;
+               dr[n].dev_opt = flags;
 
                if (++n >= dev_num)
                        break;