From: Erick Archer Date: Fri, 17 May 2024 17:21:50 +0000 (+0200) Subject: tty: rfcomm: prefer array indexing over pointer arithmetic X-Git-Tag: v6.11-rc1~163^2~12^2~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1c7cd6caaf6209ed9f7df59b61a2ac885eb79b3;p=thirdparty%2Fkernel%2Flinux.git tty: rfcomm: prefer array indexing over pointer arithmetic Refactor the list_for_each_entry() loop of rfcomm_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/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 44b781e7569e3..af80d599c3371 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -527,12 +527,12 @@ static int rfcomm_get_dev_list(void __user *arg) list_for_each_entry(dev, &rfcomm_dev_list, list) { if (!tty_port_get(&dev->port)) continue; - (di + n)->id = dev->id; - (di + n)->flags = dev->flags; - (di + n)->state = dev->dlc->state; - (di + n)->channel = dev->channel; - bacpy(&(di + n)->src, &dev->src); - bacpy(&(di + n)->dst, &dev->dst); + di[n].id = dev->id; + di[n].flags = dev->flags; + di[n].state = dev->dlc->state; + di[n].channel = dev->channel; + bacpy(&di[n].src, &dev->src); + bacpy(&di[n].dst, &dev->dst); tty_port_put(&dev->port); if (++n >= dev_num) break;