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@xxxxxxxxxxxxxx/ [1] Signed-off-by: Jakob Koschel <jakobkoschel@xxxxxxxxx> --- 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 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel