Skip to content

Commit

Permalink
tty: rfcomm: prefer array indexing over pointer arithmetic
Browse files Browse the repository at this point in the history
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 <keescook@chromium.org>
Signed-off-by: Erick Archer <erick.archer@outlook.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Erick Archer authored and Luiz Augusto von Dentz committed Jul 15, 2024
1 parent 7d2c7dd commit b1c7cd6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/bluetooth/rfcomm/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b1c7cd6

Please sign in to comment.