* [PATCH] clockevents: use dedicated list iterator variable
@ 2022-03-31 21:57 Jakob Koschel
2022-04-10 10:47 ` [tip: timers/core] clockevents: Use " tip-bot2 for Jakob Koschel
0 siblings, 1 reply; 2+ messages in thread
From: Jakob Koschel @ 2022-03-31 21:57 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-kernel, Mike Rapoport, Brian Johannesmeyer,
Cristiano Giuffrida, Bos, H.J.,
Jakob Koschel
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 [1].
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
kernel/time/clockevents.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 003ccf338d20..5d85014d59b5 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -690,7 +690,7 @@ static ssize_t unbind_device_store(struct device *dev,
{
char name[CS_NAME_LEN];
ssize_t ret = sysfs_get_uname(buf, name, count);
- struct clock_event_device *ce;
+ struct clock_event_device *ce = NULL, *iter;
if (ret < 0)
return ret;
@@ -698,9 +698,10 @@ static ssize_t unbind_device_store(struct device *dev,
ret = -ENODEV;
mutex_lock(&clockevents_mutex);
raw_spin_lock_irq(&clockevents_lock);
- list_for_each_entry(ce, &clockevent_devices, list) {
- if (!strcmp(ce->name, name)) {
- ret = __clockevents_try_unbind(ce, dev->id);
+ list_for_each_entry(iter, &clockevent_devices, list) {
+ if (!strcmp(iter->name, name)) {
+ ret = __clockevents_try_unbind(iter, dev->id);
+ ce = iter;
break;
}
}
base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip: timers/core] clockevents: Use dedicated list iterator variable
2022-03-31 21:57 [PATCH] clockevents: use dedicated list iterator variable Jakob Koschel
@ 2022-04-10 10:47 ` tip-bot2 for Jakob Koschel
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Jakob Koschel @ 2022-04-10 10:47 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Jakob Koschel, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 2966a9918dfab183a1cb6be6794981ebe2abff83
Gitweb: https://git.kernel.org/tip/2966a9918dfab183a1cb6be6794981ebe2abff83
Author: Jakob Koschel <jakobkoschel@gmail.com>
AuthorDate: Thu, 31 Mar 2022 23:57:07 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Sun, 10 Apr 2022 12:38:45 +02:00
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 <jakobkoschel@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Link: https://lore.kernel.org/r/20220331215707.883957-1-jakobkoschel@gmail.com
---
kernel/time/clockevents.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 003ccf3..5d85014 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -690,7 +690,7 @@ static ssize_t unbind_device_store(struct device *dev,
{
char name[CS_NAME_LEN];
ssize_t ret = sysfs_get_uname(buf, name, count);
- struct clock_event_device *ce;
+ struct clock_event_device *ce = NULL, *iter;
if (ret < 0)
return ret;
@@ -698,9 +698,10 @@ static ssize_t unbind_device_store(struct device *dev,
ret = -ENODEV;
mutex_lock(&clockevents_mutex);
raw_spin_lock_irq(&clockevents_lock);
- list_for_each_entry(ce, &clockevent_devices, list) {
- if (!strcmp(ce->name, name)) {
- ret = __clockevents_try_unbind(ce, dev->id);
+ list_for_each_entry(iter, &clockevent_devices, list) {
+ if (!strcmp(iter->name, name)) {
+ ret = __clockevents_try_unbind(iter, dev->id);
+ ce = iter;
break;
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-10 10:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 21:57 [PATCH] clockevents: use dedicated list iterator variable Jakob Koschel
2022-04-10 10:47 ` [tip: timers/core] clockevents: Use " tip-bot2 for Jakob Koschel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).