Skip to content

Commit 2966a99

Browse files
Jakob-KoschelKAGA-KOKO
authored andcommitted
clockevents: Use dedicated list iterator variable
To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable. Signed-off-by: Jakob Koschel <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ Link: https://lore.kernel.org/r/[email protected]
1 parent a2026e4 commit 2966a99

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kernel/time/clockevents.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,17 +690,18 @@ static ssize_t unbind_device_store(struct device *dev,
690690
{
691691
char name[CS_NAME_LEN];
692692
ssize_t ret = sysfs_get_uname(buf, name, count);
693-
struct clock_event_device *ce;
693+
struct clock_event_device *ce = NULL, *iter;
694694

695695
if (ret < 0)
696696
return ret;
697697

698698
ret = -ENODEV;
699699
mutex_lock(&clockevents_mutex);
700700
raw_spin_lock_irq(&clockevents_lock);
701-
list_for_each_entry(ce, &clockevent_devices, list) {
702-
if (!strcmp(ce->name, name)) {
703-
ret = __clockevents_try_unbind(ce, dev->id);
701+
list_for_each_entry(iter, &clockevent_devices, list) {
702+
if (!strcmp(iter->name, name)) {
703+
ret = __clockevents_try_unbind(iter, dev->id);
704+
ce = iter;
704705
break;
705706
}
706707
}

0 commit comments

Comments
 (0)