[dm-devel] [PATCH -next] dm stats: Use list_for_each_entry() helper instead of list_for_each() and container_of()
Jinjie Ruan
ruanjinjie at huawei.com
Wed Aug 30 10:16:42 UTC 2023
Convert list_for_each() and container_of() to list_for_each_entry()
so that the l list_head pointer and container_of() call are no longer
needed, which can reduce a few lines of code. No functional changed.
Signed-off-by: Jinjie Ruan <ruanjinjie at huawei.com>
---
drivers/md/dm-stats.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index db2d997a6c18..06304b0ad906 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -240,12 +240,10 @@ void dm_stats_cleanup(struct dm_stats *stats)
static void dm_stats_recalc_precise_timestamps(struct dm_stats *stats)
{
- struct list_head *l;
struct dm_stat *tmp_s;
bool precise_timestamps = false;
- list_for_each(l, &stats->list) {
- tmp_s = container_of(l, struct dm_stat, list_entry);
+ list_for_each_entry(tmp_s, &stats->list, list_entry) {
if (tmp_s->stat_flags & STAT_PRECISE_TIMESTAMPS) {
precise_timestamps = true;
break;
--
2.34.1
More information about the dm-devel
mailing list