Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: hci_core: Prefer array indexing over pointer arithmetic

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>

authored by

Erick Archer and committed by
Luiz Augusto von Dentz
c61e4112 8f7dfe17

+2 -2
+2 -2
net/bluetooth/hci_core.c
··· 828 828 if (hci_dev_test_flag(hdev, HCI_AUTO_OFF)) 829 829 flags &= ~BIT(HCI_UP); 830 830 831 - (dr + n)->dev_id = hdev->id; 832 - (dr + n)->dev_opt = flags; 831 + dr[n].dev_id = hdev->id; 832 + dr[n].dev_opt = flags; 833 833 834 834 if (++n >= dev_num) 835 835 break;