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

Configure Feed

Select the types of activity you want to include in your feed.

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 <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
b1c7cd6c 7d2c7ddb

+6 -6
+6 -6
net/bluetooth/rfcomm/tty.c
··· 527 527 list_for_each_entry(dev, &rfcomm_dev_list, list) { 528 528 if (!tty_port_get(&dev->port)) 529 529 continue; 530 - (di + n)->id = dev->id; 531 - (di + n)->flags = dev->flags; 532 - (di + n)->state = dev->dlc->state; 533 - (di + n)->channel = dev->channel; 534 - bacpy(&(di + n)->src, &dev->src); 535 - bacpy(&(di + n)->dst, &dev->dst); 530 + di[n].id = dev->id; 531 + di[n].flags = dev->flags; 532 + di[n].state = dev->dlc->state; 533 + di[n].channel = dev->channel; 534 + bacpy(&di[n].src, &dev->src); 535 + bacpy(&di[n].dst, &dev->dst); 536 536 tty_port_put(&dev->port); 537 537 if (++n >= dev_num) 538 538 break;