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.

parport: Use list_for_each() helper

Convert hard to read custom code to list_for_each().
No functional changes intended.

Note, we may not use list_for_each_entry() as at the end of the list
the iterator will point to an invalid entry and may not be dereferenced.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016133135.1203643-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
b8cb855d 8d8ae17e

+4 -2
+4 -2
drivers/parport/share.c
··· 469 469 /* Search for the lowest free parport number. */ 470 470 471 471 spin_lock(&full_list_lock); 472 - for (l = all_ports.next, num = 0; l != &all_ports; l = l->next, num++) { 472 + num = 0; 473 + list_for_each(l, &all_ports) { 473 474 struct parport *p = list_entry(l, struct parport, full_list); 474 - if (p->number != num) 475 + 476 + if (p->number != num++) 475 477 break; 476 478 } 477 479 tmp->portnum = tmp->number = num;