[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20220331220236.884887-2-jakobkoschel@gmail.com>
Date: Fri, 1 Apr 2022 00:02:36 +0200
From: Jakob Koschel <jakobkoschel@...il.com>
To: Alasdair Kergon <agk@...hat.com>
Cc: Mike Snitzer <snitzer@...hat.com>, dm-devel@...hat.com,
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 2/2] dm: 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/ [1]
Signed-off-by: Jakob Koschel <jakobkoschel@...il.com>
---
drivers/md/dm-table.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 03541cfc2317..9cf87954c05a 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -424,17 +424,16 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
*/
void dm_put_device(struct dm_target *ti, struct dm_dev *d)
{
- int found = 0;
struct list_head *devices = &ti->table->devices;
- struct dm_dev_internal *dd;
+ struct dm_dev_internal *dd = NULL, *iter;
- list_for_each_entry(dd, devices, list) {
- if (dd->dm_dev == d) {
- found = 1;
+ list_for_each_entry(iter, devices, list) {
+ if (iter->dm_dev == d) {
+ dd = iter;
break;
}
}
- if (!found) {
+ if (!dd) {
DMWARN("%s: device %s not in table devices list",
dm_device_name(ti->table->md), d->name);
return;
--
2.25.1
Powered by blists - more mailing lists