[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220324072607.63594-1-jakobkoschel@gmail.com>
Date: Thu, 24 Mar 2022 08:26:07 +0100
From: Jakob Koschel <jakobkoschel@...il.com>
To: Vinicius Costa Gomes <vinicius.gomes@...el.com>
Cc: Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Mike Rapoport <rppt@...nel.org>,
"Brian Johannesmeyer" <bjohannesmeyer@...il.com>,
Cristiano Giuffrida <c.giuffrida@...nl>,
"Bos, H.J." <h.j.bos@...nl>, Jakob Koschel <jakobkoschel@...il.com>
Subject: [PATCH] taprio: replace usage of found with 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 instead of a
found boolean [1].
This removes the need to use a found variable and simply checking if
the variable was set, can determine if the break/goto was hit.
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Signed-off-by: Jakob Koschel <jakobkoschel@...il.com>
---
net/sched/sch_cbs.c | 11 +++++------
net/sched/sch_taprio.c | 11 +++++------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
index 459cc240eda9..4ea93a5d46cf 100644
--- a/net/sched/sch_cbs.c
+++ b/net/sched/sch_cbs.c
@@ -333,9 +333,8 @@ static int cbs_dev_notifier(struct notifier_block *nb, unsigned long event,
void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
- struct cbs_sched_data *q;
+ struct cbs_sched_data *q = NULL, *iter;
struct net_device *qdev;
- bool found = false;
ASSERT_RTNL();
@@ -343,16 +342,16 @@ static int cbs_dev_notifier(struct notifier_block *nb, unsigned long event,
return NOTIFY_DONE;
spin_lock(&cbs_list_lock);
- list_for_each_entry(q, &cbs_list, cbs_list) {
- qdev = qdisc_dev(q->qdisc);
+ list_for_each_entry(iter, &cbs_list, cbs_list) {
+ qdev = qdisc_dev(iter->qdisc);
if (qdev == dev) {
- found = true;
+ q = iter;
break;
}
}
spin_unlock(&cbs_list_lock);
- if (found)
+ if (q)
cbs_set_port_rate(dev, q);
return NOTIFY_DONE;
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 377f896bdedc..9403ae4bf107 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1096,9 +1096,8 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+ struct taprio_sched *q = NULL, *iter;
struct net_device *qdev;
- struct taprio_sched *q;
- bool found = false;
ASSERT_RTNL();
@@ -1106,16 +1105,16 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
return NOTIFY_DONE;
spin_lock(&taprio_list_lock);
- list_for_each_entry(q, &taprio_list, taprio_list) {
- qdev = qdisc_dev(q->root);
+ list_for_each_entry(iter, &taprio_list, taprio_list) {
+ qdev = qdisc_dev(iter->root);
if (qdev == dev) {
- found = true;
+ q = iter;
break;
}
}
spin_unlock(&taprio_list_lock);
- if (found)
+ if (q)
taprio_set_picos_per_byte(dev, q);
return NOTIFY_DONE;
base-commit: f443e374ae131c168a065ea1748feac6b2e76613
--
2.25.1
Powered by blists - more mailing lists