From: Erick Archer Date: Sat, 18 May 2024 08:30:39 +0000 (+0200) Subject: Bluetooth: hci_core: Prefer array indexing over pointer arithmetic X-Git-Tag: v6.11-rc1~163^2~12^2~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c61e41121036aa610e904ef60f8520e10455ee8c;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Erick Archer Signed-off-by: Luiz Augusto von Dentz --- diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index a2cad8a982f6c..55bdc365916fd 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -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;